Lists as in []
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Posts: 10
- Joined: Fri Nov 16, 2018 2:01 am
Lists as in []
In Director 12, where I’m coming from, there is a construct called “lists,” and used to store data like so: [“A”, “B”, “C”] etc. To get at the data, one uses syntax like listName.getAt[1], etc. Is there such a thing in LC 9? If so, what is it called?
TIA
TIA
-
- VIP Livecode Opensource Backer
- Posts: 9663
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Lists as in []
Hi.
It sounds like you are describing an array variable. Arrays in LC are associative, and my attain any depth.
So you might, for a single level array:
Arrays are special variables, as opposed to "ordinary" variables.
Write back if you need more. You might read page 125 in the user guide.
Craig Newman
It sounds like you are describing an array variable. Arrays in LC are associative, and my attain any depth.
So you might, for a single level array:
Code: Select all
on mouseUp
put "A" into listName["1"]
put "B" into listName["2"]
put "C" into listName["3"]
answer listName["2"]
end mouseUp
Write back if you need more. You might read page 125 in the user guide.
Craig Newman
Re: Lists as in []
Yep, ARRAYS are one way to do it, but QUOTES are not neccessary for keys that are numbers.
Another way is to use ITEMS or LINES:
Or lines:
Or if your strings already contain commas, we can SET itemdelimiter, which defaults to COMMA, to whatever we need, even to more than 1 character!
Does not really make sense, but you get the picture
Best
Klaus
Another way is to use ITEMS or LINES:
Code: Select all
...
put "A,B,C" into tItemList
put item 3 of tItemList
## -> C
...
Code: Select all
...
put "A" & CR & "B" & CR & "C" into tLineList
put line 2 of tLineList
## -> B
...
Code: Select all
...
put "AyaddaByaddaC" into tYaddaList
set itemdel to "yadda"
put item 1 of tYaddaList
## -> A
...
Best
Klaus
-
- VIP Livecode Opensource Backer
- Posts: 9663
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Lists as in []
What Klaus is referring to are known as "chunk" expressions, These should become second nature to you, since they provide intrinsic parsing of text down to the character level.
A chunk can take several forms, and just as importantly, there are several functions that access them directly.
Back to the user guide, page 416, at least in v.8x.
Craig
A chunk can take several forms, and just as importantly, there are several functions that access them directly.
Back to the user guide, page 416, at least in v.8x.
Craig
Re: Lists as in []
Where can you get a PDF user guide? I have revision 19 (2010.11.09).
Regards,
Carles
Regards,
Carles
Re: Lists as in []
Hi Carles,
the "User Guide" is part of every LC installation and you can access it in LC via menu -> Help -> User Guide
Best
Klaus
the "User Guide" is part of every LC installation and you can access it in LC via menu -> Help -> User Guide
Best
Klaus
Re: Lists as in []
Hi Klaus,
Thanks for the information, every day you learn new things
Regards,
Carles
Thanks for the information, every day you learn new things
Regards,
Carles
Re: Lists as in []
This is one of the few times I actually recommend using either the dictionary to access the guides, or James Hale's excellent docset reader (on usershare/samples).
When using the actual pdf guide, though, I tend to prefer to open that in Firefox, just for ease of use (like allowing autoscrolling, good search, etc.). Best of all, if you have FF open with the 'windows and tabs from last session' set, it will open the pdf to where you left off.
I've actually chunked through the pdf (a few times) as I'm sure almost everyone else has. The dictionary has given a series of guides as a much more navigable document than the pdf itself. When using the actual pdf guide, though, I tend to prefer to open that in Firefox, just for ease of use (like allowing autoscrolling, good search, etc.). Best of all, if you have FF open with the 'windows and tabs from last session' set, it will open the pdf to where you left off.