TinTin++ Mud Client The TinTin++ message board

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
TinTin++ Mud Client

tintin 2.00.1: Unexpected behaviour using lists to set vars

 
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Bug Reports
View previous topic :: View next topic  
Author Message
louipc



Joined: 16 Jul 2006
Posts: 65

PostPosted: Thu May 06, 2010 7:38 pm    Post subject: tintin 2.00.1: Unexpected behaviour using lists to set vars Reply with quote

Unexpected behaviour using lists to set vars.

Code:
#list test create foo
#show ${test[%*]}
{foo}
#var noindexlist ${indexlist[%*]}
#show $noindexlist
{foo}{}


Also, if indexlist is {}, noindexlist would be set to 0.

I wanted to use this strategy to convert a simple list:
"one two three four"
into a list that I can iterate through via #forall:
"{one}{two}{three}{four}"

Unfortunately it fails when there's only one item in the list.
Back to top
View user's profile Send private message
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3796

PostPosted: Thu May 06, 2010 9:23 pm    Post subject: Reply with quote

Can't do that as it'll try to create an associative array.

I don't think it should return 0 if the variable is {} so I'll add that to my todo list.

You can use:

#var simple {one;two;three;four}

Or alternatively use $variable[%*] in the #forall call, though obviously that's not gonna work too well with an empty variable returning 0.
Back to top
View user's profile Send private message Send e-mail
louipc



Joined: 16 Jul 2006
Posts: 65

PostPosted: Fri May 07, 2010 5:58 am    Post subject: Reply with quote

Is there a simple way to save a space separated list to a variable that can be fed to #forall?
Back to top
View user's profile Send private message
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3796

PostPosted: Fri May 07, 2010 7:09 am    Post subject: Reply with quote

You could use:

#var mylist tmplist
#replace tmplist { } {;}
#forall {$tmplist} {do stuff}

Or a little more elegant:

Code:

#function {createlist}
{
    #var result {%0};
    #replace result { } {;}
}

#forall {@createlist{$mylist}} {do stuff}
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Bug Reports All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum
Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads
TinTin++ Homepage

Powered by phpBB © 2001, 2002 phpBB Group