Page 1 of 1

Question about array modification [Solved]

Posted: Thu May 08, 2014 5:06 pm
by atout66
Hi to all,

This code returns no error, however, the green button of the code editor turns red when I save it.

Code: Select all

put "3" into laKey
put the myTest of field myTest into myArray -- load the original array from the custom propertie of the field var <myTest> to a local array <myArray >
put the text of me into myArray[laKey][2] -- make the modification
put the keys of myArray into the myTest of field myTest -- it is supposed to record the changes to the original array, but turns red ?!?
-- put myArray into the myTest of field myTest dosen't work either
Any idea why this code doesn't work ?

Kind regards, Jean-Paul.

Re: Question about array modification

Posted: Thu May 08, 2014 5:12 pm
by dunbarx
Hi.
put the keys of myArray into the myTest of field myTest
Does this work? It should not, because you cannot put a value "into the" of a variable, and if you are setting a custom property, well, then you cannot use "put".

As for the red problem, I would call Ghostbusters.

Craig Newman

Re: Question about array modification

Posted: Thu May 08, 2014 5:17 pm
by atout66
No Craig, this is the line of code which turns with the red cross in the code editor.
Also:

Code: Select all

set the keys of myArray to the myTest of field myTest
turns red aswell...

I made some search in the tutorials and lessons section without succes until here.

Kind regards, Jean-Paul.

Re: Question about array modification

Posted: Thu May 08, 2014 5:21 pm
by Klaus
Maybe some QUOTES will help? 8)
...
set the keys of myArray to the myTest of field "myTest"
...
However I do not think that you can SET the keys of an array at all!

Re: Question about array modification

Posted: Thu May 08, 2014 5:38 pm
by atout66
Klaus wrote:However I do not think that you can SET the keys of an array at all!
I can do many things by myself, but LC doesn't agree :lol:

I do not need quotes because <myTest> is a var :wink:

Re: Question about array modification

Posted: Thu May 08, 2014 5:46 pm
by Klaus
atout66 wrote:
Klaus wrote:I do not need quotes because <myTest> is a var :wink:
Well, using a variable and a custom property with the same name in the same handler IS asking for trouble, if you ask me! 8)
This will actually give unexspectected results like this:
...
put "any_name" into myTest
set the myTest of fld myTest to "abc"
...
This will put "abc" into a custom property named "any_name"!!!, because myField is a valid variable
and in that case the engine will take its CONTENT as the cp name!
Surely not what you will like :D

I usually add a c to my cp names: the cWhatever of ...

Re: Question about array modification

Posted: Thu May 08, 2014 5:51 pm
by atout66
Ah, you're right, this is a bad habit that I need to lose (and others !) :wink:
I made the modification without success.

Re: Question about array modification

Posted: Thu May 08, 2014 6:04 pm
by atout66
I've got it 8)

Code: Select all

set the cTest of field myTest to the keys of myArray
That was the right syntax, the custom propertie first :mrgreen:

Kind regards, Jean-Paul.