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
khaos
Beginner


Joined: 07 Dec 2000
Posts: 18

PostPosted: Fri Jan 25, 2002 1:41 pm   

IF statement
 
I want to make an alias. And I need to check if there are any arguments. Im pretty sure I once did this buy typing this:
#alias test {#IF (%1 == {} ) {do this} {do %1}}

But it doesnt seem to be working, was any thing changed in the newer ver?

- Khaos
Reply with quote
bgunther
Novice


Joined: 20 Dec 2001
Posts: 39
Location: USA

PostPosted: Fri Jan 25, 2002 3:07 pm   
 
Well, this works, at least on a test alias I made.

#alias test {#if (%1) {do %1} {do this}}

Bob, aka Kayd on SWMud and a few others.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri Jan 25, 2002 7:28 pm   
 
You can also use the %testparam() function if you need to know how many arguments there are.

LightBulb
All scripts untested unless otherwise noted
Reply with quote
Troubadour
GURU


Joined: 14 Oct 2000
Posts: 556
Location: USA

PostPosted: Mon Jan 28, 2002 8:46 am   
 
The function is named %numparam. (testparam is an alias used in the example in the help file for %numparam.)

#IF %numparam {do %1} {do default}

I've also used the %null function to perform this test.

#IF %null(%1) {do default} {do %1}

Troubadour
Reply with quote
fulgurate
Beginner


Joined: 24 Jan 2002
Posts: 20
Location: USA

PostPosted: Tue Jan 29, 2002 5:13 am   
 
This will work, as well.
#alias #if (%len(%-1) > 0) {do true stuff} {do false stuff}
However, I like the %numparam better.

fulgurate (W2KPro SP2, 6.25a)
Any code is provided for entertainment purposes only.
"Of making many books there is no end,
and much study is a weariness of the flesh." - Eccl. 12:12b
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