Page 1 of 1

array key does not exist ...

Posted: Mon Mar 13, 2017 9:42 pm
by rkriesel
The error message arises from the following LCB module and LCS script.

module:

Code: Select all

library community.livecode.rkriesel.putInto2dArray

metadata title is "putInto2dArray"
metadata version is "0.0.1"
metadata author is "Dick Kriesel"

public handler putInto2dArray ( inout xArray as Array )
   put "three" into xArray[ "one" ][ "two" ]
end handler

end library
script:

Code: Select all

on mouseUp
    local tArray
    try
        put "true" into tArray[ param(0) && "was here" ]
        putInto2dArray tArray
    catch tError
    end try
    breakpoint
end mouseUp
Is something missing above, or missing from my setup, or is it a bug?

Re: array key does not exist ...

Posted: Mon Mar 13, 2017 9:48 pm
by trevordevore
You have to define each and every key you use in LCB. LCB won't create keys that don't exist. My guess is that since you haven't created the ["one"] key you get the error.

Re: array key does not exist ...

Posted: Tue Mar 14, 2017 12:04 am
by rkriesel
Thank you, Trevor.

I'd like to read about that, but I didn't see it in the docs. Could you please tell me where to look?

-- Dick

Re: array key does not exist ...

Posted: Tue Mar 14, 2017 12:08 am
by trevordevore
I don't know where it would be in the docs. I just remember having to account for it and my code.

Re: array key does not exist ...

Posted: Tue Mar 14, 2017 5:46 am
by rkriesel
Trevor, or anyone else who knows, since I still haven't found it in the docs, please share how to "define each and every key you use in LCB."

-- Dick

Re: array key does not exist ...

Posted: Wed Mar 15, 2017 9:52 am
by rkriesel
For the record, a version of what I needed is here: http://forums.livecode.com/viewtopic.php?f=93&t=27408
--Dick