mIRC Home    About    Download    Register    News    Help

Print Thread
Failing IF statement #246143 25/05/14 01:56 AM
Joined: May 2014
Posts: 10
startgame Offline OP
Pikka bird
OP Offline
Pikka bird
Joined: May 2014
Posts: 10
I suppose that I am attempting to read the name of this variable wrong, so perhaps that is why this if statement is not working properly.

Using:
set %new. $+ [ # [ $+ [ $nick ] ] ] 1

I am able to set the variable perfectly fine: %new.#user 1


But when I check whether or not that variable exists using this, I run into problems.
Code:
if (%new. $+ [ # [ $+ [ $nick ] ] ] != $null) {
  msg $chan Exists
} 
else {
  msg $chan Does not exist
}


That if statement wont go to else if %new.#user does not exist. It will only execute the line that states that it exists although it does not. I figure it may be something that I'm just overlooking, or even the syntax of attempting to retrieve the variable may be wrong. Hopefully someone can assist me on this, so I can put it behind me.

Thank you

Last edited by startgame; 25/05/14 02:07 AM. Reason: More information
Re: Failing IF statement [Re: startgame] #246144 25/05/14 02:08 AM
Joined: Dec 2013
Posts: 779
N
Nillen Offline
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
A wise man once told me he'd recommend using ini files over globally named variables 99% of the time, he was correct.
Use that to set your values instead, they're very easy to deal with once you've gotten started.

Here's the syntax:
Writeini Example.ini Section Item Value
Turns out like this:
Example.ini
[Section]
Item=Value
-
To get the value you use $readini. Syntax:
$readini(Example.Ini,Section,Item) which will return: Value
Use the helpfiles for further reference. You won't regret it.


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Re: Failing IF statement [Re: Nillen] #246145 25/05/14 02:27 AM
Joined: May 2014
Posts: 10
startgame Offline OP
Pikka bird
OP Offline
Pikka bird
Joined: May 2014
Posts: 10
Originally Posted By: Nillen
A wise man once told me he'd recommend using ini files over globally named variables 99% of the time, he was correct.
Use that to set your values instead, they're very easy to deal with once you've gotten started.

Here's the syntax:
Writeini Example.ini Section Item Value
Turns out like this:
Example.ini
[Section]
Item=Value
-
To get the value you use $readini. Syntax:
$readini(Example.Ini,Section,Item) which will return: Value
Use the helpfiles for further reference. You won't regret it.


I already do you use ini files for other storage of user and channel data, but at this current time I feel this does not require it as I am not storing many values; I am only storing 3 values, so I figure that just using a few dynamic variables would save the time and keep them parted for me to retrieve later on while I test a few things for now.

Although in the future I will transfer this data to an ini to be read from, I would rather stick with just a couple of dynamic variables to test and ensure each of the executed commands are properly working on my end.

Re: Failing IF statement [Re: startgame] #246146 25/05/14 06:18 AM
Joined: Apr 2014
Posts: 191
B
blessing Offline
Vogon poet
Offline
Vogon poet
B
Joined: Apr 2014
Posts: 191
The variable not evaluated correctly.
It should be like this:
Code:
set %new. [ $+ # [ $+ [ $nick ] ] ] 1

if (%new. [ $+ # [ $+ [ $nick ] ] ] != $null) {
  msg $chan Exists
} 
else {
  msg $chan Does not exist
}