Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
Articval
Novice


Joined: 01 Jun 2005
Posts: 47

PostPosted: Sat Nov 01, 2008 10:40 pm   

[2.37] #if command inside #forall, failing
 
Hi!

I explain myself badly when talking about programming, so I will put examples of what I think it should do and what it does.

#forall @list {#if %i=cheese {#echo yeah}}

This forall was not working for me, the exact error was that I had an extra bracet, then I remove the bracet, and it wont work correcly either.

What I had to do to 'solve' it was to get an alias this way:

#forall @list {aliasname %i}

#alias aliasname {#if %1=cheese {#echo yeah}}


Hope this was not already posted, and I would like to know if this is a bug or if its supoused to work that way, thankyou!
Reply with quote
Dumas
Enchanter


Joined: 11 Feb 2003
Posts: 511
Location: USA

PostPosted: Sat Nov 01, 2008 10:52 pm   
 
hmm, original worked for me. Which means it makes no sense that the first didn't work and the second didn't. Might you have made a typo on the original one?

Just to be sure, you are expecting that whenever cheese is found on the list, that yeah will be printed. You aren't expecting any thing else to happen right?
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Sat Nov 01, 2008 11:11 pm   
 
It's generally because CMUD is more strict with commands. It should work either way, but try:

#FORALL @list {#IF (%i="cheese") {#echo yeah}}

will work. Quote the strings, parenthesize the arguments.

Charneus
Reply with quote
Dumas
Enchanter


Joined: 11 Feb 2003
Posts: 511
Location: USA

PostPosted: Sun Nov 02, 2008 1:56 am   
 
Both work charneus, at least for me. But it still doesn't explain why the first one did not work for Articval and his workaround did. Maybe it is the context of how he was using it?
Reply with quote
Articval
Novice


Joined: 01 Jun 2005
Posts: 47

PostPosted: Sun Nov 02, 2008 2:17 pm   
 
Ok, got the difference:

If you guys do:

#FORALL @listacolores {%i;#IF (%i="yellowgreen") {#echo yeah}}

THAT is what is not going to work :)

If u remove the %i, then works like it should
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Sun Nov 02, 2008 2:30 pm   
 
That's because you can't start a line with a function.

#FORALL @listacolores {#EXEC {%i};#IF (%i="yellowgreen") {#echo yeah}}

WILL work.

Charneus
Reply with quote
Articval
Novice


Joined: 01 Jun 2005
Posts: 47

PostPosted: Sun Nov 02, 2008 2:40 pm   
 
The more I think I know, the more I know I dont.

Thankyou.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum All times are GMT
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

© 2009 Zugg Software. Hosted by Wolfpaw.net