Passing a dictionary in a variable


#1

I have been trying to get my getstockquote procedure working, and I have been running into a problem passing a dictionary to another procedure as a parameter, or in a variable. The dictionary looks the same going from one procedure to the other, but the result of trying to extract data from it gives me (null). Is some of the dictionary structure lost in doing this?


#2

You are probably running into issue #492, which causes problems when passing a fileglobal variable (or a field) from one database to another. For now the solution is to copy the fileglobal into a local variable. This bug is pretty high on my list of bugs to fix, but also one I need to be very careful in fixing to make sure that changing this code doesn’t cause other unintended problems. You can read more about this issue here:


#3

All the variables are local.


#4

I got Bruce’s file and it looks like there is a subtle bug in the initializedictionary statement. For now, the initializedictionary( function is a better way to go, and switching to it fixes Bruce’s code, but I will look into it. This has been a problematic statement, this will be the second bug I’ve fixed in it. The function has been rock solid though, and Panorama X uses it extensively internally.


#5

The problem with the initializedictionary statement has been fixed.

https://bitbucket.org/jimrea/panoramax/issues/525/initializedictionarystatement-doesnt-work

The file @BruceDeB sent me (getstockquote procedure) now works perfectly with no changes.


#6

Well, not quite as perfectly as it would with a few changes I have made elsewhere since I sent that to you! But I am glad I was able to help you squash that bug.


#7

Well, my point was that it now works the same as it did in Panorama 6.


#8

This sounds similar to a problem I have just encountered. A procedure transferring information from one database to another works perfectly in Panorama 6, but in Panorama X the variables from text fields return “”, but the number fields, including dates, work fine. I can get around the issue by copying the field and then having the variable = clipboard(), but this feels a bit clunky. Have I missed a programming subtlety, or is it a programme glitch?


#9

This procedure works.

Local x x=A message x

A is a text field, and the message is the same as the content of that field. Perhaps you could post the procedure that doesn’t work.


#10

This is the procedure that is not working. Supplier/Purchaser contains text, as do the Comments fields. I have left in the ‘dodgy’ fix. Also the Message, stop, I put in to test why it wasn’t working.
Appreciate any help you can give. (Also happy to receive any other comments about the programme - I’ve learnt this as I go, so there may be some other obvious things I could do differently!!)

Michele Dunlop

global temp0, temp1,dCapitalA,dCapitalB, dFuelRebate
local temp2, temp3, temp4, temp5, temp6,p,m,s,b,x,y,temp7

;field «Supplier/Purchaser»
;copy
;temp0 = clipboard()

temp0 = «Supplier/Purchaser»
Message temp0
stop

temp1=Date
temp7=0
dCapitalA = CapitalA
dCapitalB = CapitalB
If Amount1=0
call .EnterIncome
opendatabase "DMDFinancials"
goform "ReviewData"
stop
else
p=PPercentA
m=MPercentA
s=SPercentA
b=BuildingA
x=ClaimGSTA
y=InclGSTA
temp2=Category1
temp3=Amount1
temp4=GSTAmended1
temp5=Comments1
temp6=QtyIn1
if Category1 contains “Fuel” and QtyIn1 >0
temp7=val(dFuelRebate)*QtyIn1/100
endif
opendatabase “DMDFinancials”
;gosheet
insertbelow
Supplier=temp0
Date=temp1
call .Dates
PPercent=p
MPercent=m
SPercent=s
Building=b
ClaimGST=x
InclGST=y
Category=temp2
TotalOut=temp3
TotalGSTOut=temp4
Comments=temp5
QtyBought=temp6
FuelRebate=temp7
temp7=0
call Calculate
opendatabase "TaxInput2"
endif
If Amount2=0
call .EnterIncome
opendatabase "DMDFinancials"
goform "ReviewData"
stop
Else
temp2=Category2
temp3=Amount2
temp4=GSTAmended2
temp5=Comments2
temp6=QtyIn2
if Category2 contains “Fuel” and QtyIn2 >0
temp7=val(dFuelRebate)*QtyIn2/100
endif
opendatabase “DMDFinancials”
;gosheet
insertbelow
Supplier=temp0
Date=temp1
call .Dates
PPercent=p
MPercent=m
SPercent=s
Building=b
ClaimGST=x
InclGST=y
Category=temp2
TotalOut=temp3
TotalGSTOut=temp4
Comments=temp5
QtyBought=temp6
FuelRebate=temp7
call Calculate
opendatabase "TaxInput2"
Endif
If Amount3=0
call .EnterIncome
opendatabase "DMDFinancials"
goform "ReviewData"
stop
Else
temp2=Category3
temp3=Amount3
temp4=GSTAmended3
temp5=Comments3
temp6=QtyIn3
if Category3 contains “Fuel” and QtyIn3 >0
temp7=val(dFuelRebate)*QtyIn3/100
endif
opendatabase “DMDFinancials”
;gosheet
insertbelow
Supplier=temp0
Date=temp1
call .Dates
PPercent=p
MPercent=m
SPercent=s
Building=b
ClaimGST=x
InclGST=y
Category=temp2
TotalOut=temp3
TotalGSTOut=temp4
Comments=temp5
QtyBought=temp6
FuelRebate=temp7
call Calculate
opendatabase "TaxInput2"
Endif
If Amount4=0
call .EnterIncome
opendatabase "DMDFinancials"
goform "ReviewData"
stop
Else
temp2=Category4
temp3=Amount4
temp4=GSTAmended4
temp5=Comments4
temp6=QtyIn4
if Category4 contains “Fuel” and QtyIn4 >0
temp7=val(dFuelRebate)*QtyIn4/100
endif
opendatabase “DMDFinancials”
;gosheet
insertbelow
Supplier=temp0
Date=temp1
call .Dates
PPercent=p
MPercent=m
SPercent=s
Building=b
ClaimGST=x
InclGST=y
Category=temp2
TotalOut=temp3
TotalGSTOut=temp4
Comments=temp5
QtyBought=temp6
FuelRebate=temp7
call Calculate
opendatabase "TaxInput2"
Endif
If Amount5=0
call .EnterIncome
opendatabase "DMDFinancials"
goform "ReviewData"
stop
Else
temp2=Category5
temp3=Amount5
temp4=GSTAmended5
temp5=Comments5
temp6=QtyIn5
if Category5 contains “Fuel” and QtyIn5 >0
temp7=val(dFuelRebate)*QtyIn5/100
endif
opendatabase “DMDFinancials”
;gosheet
insertbelow
Supplier=temp0
Date=temp1
call .Dates
PPercent=p
MPercent=m
SPercent=s
Building=b
ClaimGST=x
InclGST=y
Category=temp2
TotalOut=temp3
TotalGSTOut=temp4
Comments=temp5
QtyBought=temp6
FuelRebate=temp7
call Calculate
opendatabase "TaxInput2"
Endif
If Amount6=0
call .EnterIncome
opendatabase "DMDFinancials"
goform "ReviewData"
stop
Else
temp2=Category6
temp3=Amount6
temp4=GSTAmended6
temp5=Comments6
if Category6 contains “Fuel” and QtyIn6 >0
temp7=val(dFuelRebate)*QtyIn6/100
endif
opendatabase “DMDFinancials”
;gosheet
insertbelow
Supplier=temp0
Date=temp1
call .Dates
PPercent=p
MPercent=m
SPercent=s
Building=b
ClaimGST=x
InclGST=y
Category=temp2
TotalOut=temp3
TotalGSTOut=temp4
Comments=temp5
QtyBought=temp6
FuelRebate=temp7
call Calculate
opendatabase "TaxInput2"
Endif
If Amount7=0
call .EnterIncome
opendatabase "DMDFinancials"
goform "ReviewData"
stop
Else
temp2=Category7
temp3=Amount7
temp4=GSTAmended7
temp5=Comments7
temp6=QtyIn7
if Category7 contains “Fuel” and QtyIn7 >0
temp7=val(dFuelRebate)*QtyIn7/100
endif
opendatabase “DMDFinancials”
;gosheet
insertbelow
Supplier=temp0
Date=temp1
call .Dates
PPercent=p
MPercent=m
SPercent=s
Building=b
ClaimGST=x
InclGST=y
Category=temp2
TotalOut=temp3
TotalGSTOut=temp4
Comments=temp5
QtyBought=temp6
FuelRebate=temp7
call Calculate
opendatabase "TaxInput2"
Endif
If Amount8=0
call .EnterIncome
opendatabase "DMDFinancials"
goform "ReviewData"
stop
Else
temp2=Category8
temp3=Amount8
temp4=GSTAmended8
temp5=Comments8
temp6=QtyIn8
if Category8 contains “Fuel” and QtyIn8 >0
temp7=val(dFuelRebate)*QtyIn8/100
endif
opendatabase “DMDFinancials”
;gosheet
insertbelow
Supplier=temp0
Date=temp1
call .Dates
PPercent=p
MPercent=m
SPercent=s
Building=b
ClaimGST=x
InclGST=y
Category=temp2
TotalOut=temp3
TotalGSTOut=temp4
Comments=temp5
QtyBought=temp6
FuelRebate=temp7
call Calculate
opendatabase "TaxInput2"
Endif
If Amount9=0
call .EnterIncome
opendatabase "DMDFinancials"
goform "ReviewData"
stop
Else
temp2=Category9
temp3=Amount9
temp4=GSTAmended9
temp5=Comments9
temp6=QtyIn9
if Category9 contains “Fuel” and QtyIn9 >0
temp7=val(dFuelRebate)*QtyIn9/100
endif
opendatabase “DMDFinancials”
;gosheet
insertbelow
Supplier=temp0
Date=temp1
call .Dates
PPercent=p
MPercent=m
SPercent=s
Building=b
ClaimGST=x
InclGST=y
Category=temp2
TotalOut=temp3
TotalGSTOut=temp4
Comments=temp5
QtyBought=temp6
FuelRebate=temp7
call Calculate
opendatabase "TaxInput2"
Endif
call .EnterIncome


#11

My best guess is that somehow you have acquired some variables with the same names as the problem fields. When you write temp0 = «Supplier/Purchaser», temp0 is getting the value of the variable instead of the field. When you go to that field and copy, the clipboard gets the value of the field.

To test my theory, you could try running something like this.

«Supplier/Purchaser» = "This is a test" message «Supplier/Purchaser»

If I guessed right, the field should remain unchanged, but the message should say “This is a test”

Another way to bypass a variable with the same name, without involving the clipboard would be to use

temp0 = fieldvalue("Supplier/Purchaser")


#12

Just a hint Michele - it would be big help to you and to anybody else reading your code if you put in the occasional explanatory comment line saying what the next dozen or so lines of code are doing.


#13

Theory proven!

I would never have deliberately called a variable those names, but I guess they may turn up as I work through the other procedures post conversion to Panorama X.

Thanks for your help


#14

Found the variable. I had incorrectly set up a text edit field on a form - thought it was going straight to the field, but accidentally made a variable!