PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Accessing lists like arrays

PointOfLight · 16 Sep 2004, 19:45 UTC
Is it possible to access a list like:

val$ = list$[1]

Or is this something you were at least thinking about putting in? I seem to remember seeing this in the forum at some point.
Yep, it is possible. Something to think about though.

list(l$);
Add(l$, "STRING");

If you want to access a string character in a list, you can't. The index array will move to the list pointer instead. You have to copy the list value to a temp variable in order to do this:

s$ = l$;
if (s$[1] == 'T')
...
end;
PointOfLight · 16 Sep 2004, 20:54 UTC
Well, if you wouldn't be able to do:

val$ = list$[1]

where list$ is a list of strings, then I suppose that wouldn't be helpful, at least not for me. Most of what I do with lists right now involves strings.
No, I am just saying that you can't access a character in a string in a list. But a list of strings can be indexed no problem.

Ex:

List(l$);
Add(l$, "STRING1", "STRING2");
a$ = l$[0];
b$ = l$[1];
PointOfLight · 16 Sep 2004, 21:21 UTC
Oh, well in that case I take back what I said :) That actually would be cool.