mIRC Home    About    Download    Register    News    Help

Print Thread
If/Then question #253647 25/06/15 06:56 AM
Joined: Oct 2014
Posts: 42
K
Kooky Offline OP
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Oct 2014
Posts: 42
So I'm having an issue with a script snip.
This line

if ($2 = null) {$2 = 6}

I'm using a wrong variable. The idea is if no other number is set for $2 I want $2 to equal 6. Otherwise, it's the number set in the script command.

Re: If/Then question [Re: Kooky] #253649 25/06/15 08:30 AM
Joined: Sep 2014
Posts: 259
S
Sakana Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
Use this:

if ($2 == $null) { var %2 = 6 }

Re: If/Then question [Re: Sakana] #253650 25/06/15 08:41 AM
Joined: May 2015
Posts: 249
splinny Offline
Fjord artisan
Offline
Fjord artisan
Joined: May 2015
Posts: 249
$iif($2,$2,6)


Dont give a fish - teach to fish!
Re: If/Then question [Re: splinny] #253652 25/06/15 12:21 PM
Joined: Jul 2006
Posts: 3,880
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,880
And you get 6 when $2 is 0

Never use $iif unless speed execution doesn't matter and it really avoids repetition

I like Sakana's idea
Code:
var %2 = $2
if (%2 == $null) %2 = 6

Last edited by Wims; 25/06/15 12:23 PM.
Re: If/Then question [Re: Wims] #253653 25/06/15 01:16 PM
Joined: May 2015
Posts: 249
splinny Offline
Fjord artisan
Offline
Fjord artisan
Joined: May 2015
Posts: 249
Ok,
Code:
$iif($2 != $null,$2,6)


Dont give a fish - teach to fish!
Re: If/Then question [Re: splinny] #253654 25/06/15 02:31 PM
Joined: Jul 2006
Posts: 3,880
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,880
Yeah but you are still using $iif, the suggestion was to never suggest to someone to use $iif unless speed execution doesn't matter AND it makes the code clearer/avoids repetition, because $iif is much much slower than /if

Re: If/Then question [Re: Wims] #253778 06/07/15 02:07 AM
Joined: Oct 2014
Posts: 42
K
Kooky Offline OP
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Oct 2014
Posts: 42
On the same lines as this, if I want a different variable set if letters and not numbers are used, how would I do that?

I'm looking for the variable segment that states that, but I cannot find it.

As in..

if $2 is a word or series of words and not a number then.. the script does another thing...

Looking for the variable that means "no numbers included, only the alphabet"

Re: If/Then question [Re: Kooky] #253779 06/07/15 07:24 AM
Joined: Sep 2014
Posts: 259
S
Sakana Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
You need a regular expression. This one does what you want (only triggers if all characters in $2- are either letters or spaces)


Code:
if $regex($2-,/^([A-Za-z\s]*)$/g) { echo -a $regml(1) }