Array referencing
Posted: Thu Oct 26, 2023 5:11 pm
Hello.
Small problem that gives me a headache:
I save values in array like
Now, the script in some cases needs to change the array path of "DEFAdvantage" to something like this:
Since there are tens of array references in the same script, instead of having tens of "if then else", I tough of having a function in the stack that changes the reference like this:
The idea was to call the function to replace the array path, like this.
But, as usual, it doesn't work. Any idea?
Thanks
Trevix
Small problem that gives me a headache:
I save values in array like
Code: Select all
put "Regular" into gPrefTF[gSport]["setting"]["DEFAdvantage"]
Code: Select all
put "Regular" into gPrefTF["gPrefTvBox"]["gPrefTF"][gSport]["setting"]["DEFAdvantage"]
Code: Select all
function PathToPref pValue
if 1 = 1 then --this is where the choice is made
put "gPrefTF[" & quote & "gPrefTvBox" & quote & "][" & gSport & "][" & quote & "setting" & quote & "][" & quote & pValue & quote & "]" into tPathToPref
else
put "gPrefTF[" & gSport & "][" & quote & "setting" & quote & "][" & quote & pValue & quote & "]" into tPathToPref
end if
return tPathToPref
end PathToPref
Code: Select all
put "Regular" into value(PathToPref("DEFAdvantage"))
--OR
put value(PathToPref("DEFAdvantage")) into tSOmething
Thanks
Trevix