This site is no longer active and is available for archival purposes only. Registration and login is disabled.

Accessing lists like arrays


Accessing lists like arrays

Postby PointOfLight » Sep 16, 2004 @ 8:45pm

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.
Eric Pankoke
Programmer
Point Of Light Software
http://www.polsoftware.com/
PointOfLight
pm Member
 
Posts: 525
Joined: Nov 2, 2003 @ 8:39pm


Postby kornalius » Sep 16, 2004 @ 9:14pm

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;
Regards,
Kornalius
President
ArianeSoft Inc.
http://www.arianesoft.ca
User avatar
kornalius
pm Member
 
Posts: 1704
Joined: Dec 9, 2003 @ 6:04pm
Location: Montreal, Québec, Canada


Postby PointOfLight » Sep 16, 2004 @ 9:54pm

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.
Eric Pankoke
Programmer
Point Of Light Software
http://www.polsoftware.com/
PointOfLight
pm Member
 
Posts: 525
Joined: Nov 2, 2003 @ 8:39pm


Postby kornalius » Sep 16, 2004 @ 10:07pm

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];
Regards,
Kornalius
President
ArianeSoft Inc.
http://www.arianesoft.ca
User avatar
kornalius
pm Member
 
Posts: 1704
Joined: Dec 9, 2003 @ 6:04pm
Location: Montreal, Québec, Canada


Postby PointOfLight » Sep 16, 2004 @ 10:21pm

Oh, well in that case I take back what I said :) That actually would be cool.
Eric Pankoke
Programmer
Point Of Light Software
http://www.polsoftware.com/
PointOfLight
pm Member
 
Posts: 525
Joined: Nov 2, 2003 @ 8:39pm


Return to Pocket Programming Language (PPL)


Sort


Forum Description

Discuss this new development tool.

Moderator:

kornalius

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron