array key does not exist ...

Moderators: LCMark, LCfraser

Post Reply
rkriesel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 60
Joined: Thu Apr 13, 2006 6:25 pm

array key does not exist ...

Post by rkriesel » Mon Mar 13, 2017 9:42 pm

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?

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 873
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Re: array key does not exist ...

Post by trevordevore » Mon Mar 13, 2017 9:48 pm

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.
Trevor DeVore
ScreenSteps - http://www.screensteps.com

Levure Application Framework: https://github.com/trevordevore/levure
LiveCode Resources for Developers: http://livecode.bluemangolearning.com

rkriesel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 60
Joined: Thu Apr 13, 2006 6:25 pm

Re: array key does not exist ...

Post by rkriesel » Tue Mar 14, 2017 12:04 am

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

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 873
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Re: array key does not exist ...

Post by trevordevore » Tue Mar 14, 2017 12:08 am

I don't know where it would be in the docs. I just remember having to account for it and my code.
Trevor DeVore
ScreenSteps - http://www.screensteps.com

Levure Application Framework: https://github.com/trevordevore/levure
LiveCode Resources for Developers: http://livecode.bluemangolearning.com

rkriesel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 60
Joined: Thu Apr 13, 2006 6:25 pm

Re: array key does not exist ...

Post by rkriesel » Tue Mar 14, 2017 5:46 am

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

rkriesel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 60
Joined: Thu Apr 13, 2006 6:25 pm

Re: array key does not exist ...

Post by rkriesel » Wed Mar 15, 2017 9:52 am

For the record, a version of what I needed is here: http://forums.livecode.com/viewtopic.php?f=93&t=27408
--Dick

Post Reply

Return to “LiveCode Builder”