Hello, can i know what the issue over here and the solution? can't seem to make this work.
I'm using easy json and the bold and underline sentence is the error.
on mouseup
create group "mainbox"
put 0 into myLoop
put 242 into myPosition1
put 1 into myID
put 0 into testname
repeat until myLoop = 5
add 1 to myLoop
add 50 to myPosition1
add 1 to myID
add 10 to testname
create field ""&testname&"" in group "mainbox"
move it to 158,myPosition1
put tArray["users"][myID]["idnumber"] into field ""&testname&""
end repeat
end mouseup
JSON ERROR
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: JSON ERROR
It's obvious : why do you put a double quotes before and after testname ?
Code: Select all
put tArray["users"][myID]["idnumber"] into field testname
Re: JSON ERROR
Well, I think he did that because of how he set the line above it up.
Code: Select all
// created field here...
create field ""&testname&"" in group "mainbox"
move it to 158,myPosition1
// repeated it here...
put tArray["users"][myID]["idnumber"] into field ""&testname&""
field "" & testname & ""
But you are certainly correct, it could be shortened to just field testname, provided 'testname' is a variable holding something else, if it is the actual name you want the field to be it should be field "testname".
*Edit - this was only an explanation to bangkok, not a solution to the problem. I see some other issues, but will take a bit to test those out before commenting.
*Edit for clarity - I think the reason the field name errors out is because you are naming them strictly with numbers. In Lc, field 10 would refer to the 10th field created, it is not a way to name the field.
Last edited by bogs on Fri Apr 27, 2018 4:43 pm, edited 1 time in total.
Re: JSON ERROR
Well, I only had time to briefly look at / test this, but I've made some corrections to the code posted, which I've commented.
Hope that is of some help to you.
Code: Select all
on mouseup
/* Previous code created this group over and over. This creates the group once,
and puts any controls created into a variable which can be checked during the loop...*/
if there is not a group "mainbox" then create group "mainbox"
put the childControlNames of group "mainbox" into tmpCtrlNames
put 0 into myLoop
put 242 into myPosition1
put 1 into myID
put 0 into testname
repeat until myLoop = 5
add 1 to myLoop
add 50 to myPosition1
add 1 to myID
add 10 to testname
if there is group "mainbox" then
/* We are testing to see if it is necessary to create a field or not...*/
if testname is among the lines of tmpCtrlNames then
// don't create it, it already exists...
else
// it isn't there, so create it...
create field testname in group "mainbox"
move group "mainbox" to 158,myPosition1
end if
end if
/* No array was created in the previous code above, so there is nothing to put into
any of the fields. If you have a handler somewhere else creating the array, you
can un-comment this next line ... */
// put tArray["users"][myID]["idnumber"] into field testname
end repeat
Re: JSON ERROR
Corrected some flaws in my above code -
Some things to note -
Code: Select all
on mouseup
if there is not a group "mainbox" then create group "mainbox"
put the childControlNames of group "mainbox" into tmpCtrlNames
put 0 into myLoop
put 242 into myPosition1
put 1 into myID
put 0 into testname
repeat until myLoop = 5
add 1 to myLoop
add 50 to myPosition1
add 1 to tArray[myID]
add 10 to testname
if there is group "mainbox" then
if testname is among the lines of tmpCtrlNames then
// don't create it, it already exists...
else
create field testname in group "mainbox"
move group "mainbox" to 158,myPosition1
end if
end if
// put tArray["users"]["myID"]["idnumber"] into field testname
put "users idnumber " & tArray[myID] into field myLoop
end repeat
end mouseup
- The above code does not fix the issue with naming the fields, only allows it to work as intended.
- Grammatical correction for the layout of the field entry at the end put in.
- Time for lunch