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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Zafrusteria
Wanderer


Joined: 11 Oct 2000
Posts: 94
Location: United Kingdom

PostPosted: Mon Sep 01, 2003 6:42 pm   

#IF then else maybe?
 
#SHOW test is running
#VARIABLE temp "Green"
#IF (@temp=~"Green") {#SHOW "true Green=Green"} {#SHOW "False Green<>Green"}

Can you guess what this will print on your screen after the line "test is running"?


The answer is it prints nothing! We do not go through the true or false part.

This was done on a new char so there were no other alias' to get it messed up.

Anyone any ideas why this fails to display anything?

Zaf
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Mon Sep 01, 2003 7:01 pm   
 
Yes. Since you have ~", zMUD treats the " as a normal character. It then encounters "), which tells it to treat the ) as part of the string being tested. It never encounters another " to terminate the string and it never encounters another ) to terminate the condition.

Learn to use spaces. Very Happy
Any of these will work:
#SHOW test is running
#VARIABLE temp "Green"
#IF (@temp =~ "Green") {#SHOW "1. true Green=Green"} {#SHOW "1. False Green<>Green"}
#IF (@temp=~ "Green") {#SHOW "2. true Green=Green"} {#SHOW "2. False Green<>Green"}
#IF (@temp = "Green") {#SHOW "3. true Green=Green"} {#SHOW "3. False Green<>Green"}
#IF (@temp="Green") {#SHOW "4. true Green=Green"} {#SHOW "4. False Green<>Green"}
#IF (@temp=~"Green"") {#SHOW "5. true Green=Green"} {#SHOW "5. False Green<>Green"}
Reply with quote
Zafrusteria
Wanderer


Joined: 11 Oct 2000
Posts: 94
Location: United Kingdom

PostPosted: Mon Sep 01, 2003 8:51 pm   
 
Ok thanks for the tip on spaces. Zmud has weird syntax with spaces though, not like most other scripting languages. Very Happy Sometime you get unxepected results when you have spaces.

So why does @obj not get set, when I use: test Green

#SHOW test is running
#VARIABLE temp "Green"
#IF (@temp =~ "Green") {
#SHOW "1. true Green=Green"
#VARIABLE @obj something
} {#SHOW "1. False Green<>Green"}
#SHOW @obj

If prints "1. true Green=Green" so why not execute the rest of the commands?
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Mon Sep 01, 2003 10:57 pm   
 
#VARIABLE accepts indirect addressing.

#VAR obj test1
#SHOW test is running
#VARIABLE temp "Green"
#IF (@temp =~ "Green") {
#SHOW "1. true Green=Green"
#VARIABLE @obj something
} {#SHOW "1. False Green<>Green"}
#SHOW {~@temp is @temp, ~@obj is @obj, ~@@obj is @{@obj}}
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Tue Sep 02, 2003 2:10 am   
 
In other word you probably want to use:
#VAR obj something
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion 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