mIRC Home    About    Download    Register    News    Help

Print Thread
#48665 11/09/03 09:14 AM
N
NewScripter
NewScripter
N
I've still been going through tutorials and I noticed some of them say the scripting is diff. depending on the v. of IRC so how am I supposed to know? Here's an e.g. that returns, when put in my Aliases, it gives me (ELSE) is an invalid command and (ELSEIF) is an invalid command.

/testing {
if ($me == $1) { /say $1 is $me }
elseif ($1 == $null) { /echo oopsie, forgot a variable }
else { /say $1 is not $me }
}

The first part works, so that if I type in: /testing <nick> it returns the proper "<nick> is <nick>

Tx again...

#48666 11/09/03 09:20 AM
Joined: Jan 2003
Posts: 149
J
Vogon poet
Offline
Vogon poet
J
Joined: Jan 2003
Posts: 149
it works in mIRC v6.1
however this is bad coding...

Code:
testing {
  if (!$1) { echo oopsie, forgot a variable }
  elseif ($me == $1) { say $1 is $me }
  else { say $1 is not $me }
}

#48667 11/09/03 09:25 AM
N
NewScripter
NewScripter
N
I get the if (!$1) part, and rearranging them is fine...but if it's scripting for v. 6.1 what am I supposed to use for 6.3? I don't want to read a bunch of tutorials to learn stuff that doesn't even work anymore...

#48668 11/09/03 09:55 AM
Joined: Mar 2003
Posts: 1,256
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Mar 2003
Posts: 1,256
The only way to be sure is to check the commands in the helpfile. Other than that -- most things stay the same, sometimes stuff gets added, occasionally things get removed or changed. Read the versions.txt to find out which things changed. Forget about writing a script that works on all versions, it can't be done without extensive errortesting, versionchecking, and building in fixes for things that didn't work in older versions. And when the next version comes, you're screwed.

#48669 11/09/03 10:23 AM
Joined: Jan 2003
Posts: 149
J
Vogon poet
Offline
Vogon poet
J
Joined: Jan 2003
Posts: 149
Since mIRC v5.9 grin
59.Added support for ! not prefix in if statements for use with
$identifiers and %variables, eg. if (!%moo) echo no cows

#48670 11/09/03 05:05 PM
Joined: May 2003
Posts: 161
A
Vogon poet
Offline
Vogon poet
A
Joined: May 2003
Posts: 161
!%blah is not the same as %blah == $null . !%blah is true on any false value, like 0, $false, $no, etc...

#48671 11/09/03 05:10 PM
R
r0ck0
r0ck0
R
actually !%bleh would == $false, 0, no & $null

#48672 11/09/03 05:15 PM
Joined: May 2003
Posts: 161
A
Vogon poet
Offline
Vogon poet
A
Joined: May 2003
Posts: 161
that's what I just said...

#48673 11/09/03 05:16 PM
R
r0ck0
r0ck0
R
Quote:
!%blah is not the same as %blah == $null


so !%blah can be the same as %blah == $null

#48674 11/09/03 05:21 PM
Joined: May 2003
Posts: 161
A
Vogon poet
Offline
Vogon poet
A
Joined: May 2003
Posts: 161
no it's not

Code:
set %i 0
if (!%i) echo a
if (%i == $null) echo b


it will say a but not b

#48675 11/09/03 05:26 PM
R
r0ck0
r0ck0
R
lol ... ok if there were no value set for %blah, or
%blah wasn't set at all for that matter, would that not mean that %blah is NULL of any value ?
If so then both !%blah & %blah == $null would both be true.

#48676 11/09/03 05:27 PM
R
r0ck0
r0ck0
R
ya that's because when you set %i to 0 .. it's not $null

try this
Code:
alias nulltest {
  unset %i
  if (!%i) echo a
  if (%i == $null) echo b
}

it will echo both

Last edited by r0ck0; 11/09/03 05:31 PM.
#48677 11/09/03 05:32 PM
P
pheonix
pheonix
P
its not the same in all circumstances:
alias test {
set %i 0
echo -a $iif(!%i,yes,no)
echo -a $iif(%i == $null,yes,no)
}
!%i reads '0' as $null
%i == $null doesn't

#48678 11/09/03 05:34 PM
R
r0ck0
r0ck0
R
thats why I said so !%blah can be the same as %blah == $null

depending on the circumstances, so !%blah would be true for any false statement including $null

so why use
if ((%blah == 0) || (%blah == $false) || (%blah == no) || (%blah == $null)) when you could just use if (!%blah) ?

Last edited by r0ck0; 11/09/03 05:38 PM.
#48679 12/09/03 10:44 AM
O
Om3n
Om3n
O
%/$ == $null CAN be the same as !%/$
This all depends on the circumstances, What it seems people are failing to mention is that $null indicates an absense of any state or value for %/$ and will only trigger in that case, where as !%/$ will trigger on any case of %/$ being false/no/0 ect.

At least this is my understanding of the difference.

However to reply more closely to NewScripter's post, just script by the latest version of mIRC, this way your script will be compatible with future versions as scripting formats ect are not changed very often. If/when anything in the scripting language is changed, it is mentioned in the versions.txt that is included in the mIRC package. So i just suggest reading the versions.txt any time you upgrade mIRC, this way you will be up to date on any changes that may occur or additions that may improve the scripting language, and you can update yours cripts if/when at all neccersary.

ps. i think you meant to type 6.03 not 6.3 smile

Last edited by Om3n; 12/09/03 10:50 AM.
#48680 12/09/03 11:33 AM
R
r0ck0
r0ck0
R
Quote:
failing to mention is that $null indicates an absense ...


nope .. I said that too ...
"would that not mean that %blah is NULL of any value"

#48681 12/09/03 12:04 PM
O
Om3n
Om3n
O
Wasn't directly replying to your post(s), thats just how this forum works, you have to click reply on somebody lolz.

#48682 12/09/03 12:51 PM
R
r0ck0
r0ck0
R
wink


Link Copied to Clipboard