mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2021
Posts: 36
T
Ameglian cow
OP Offline
Ameglian cow
T
Joined: Dec 2021
Posts: 36
I was hoping you could implement the following code to work:

Code
if (%does_not_exist isin $null $+ $false) { set %does_not_exist $false }

Even if you just use the following it does NOT work:

Code
if (%does_not_exist isin $null) { set %does_not_exist $true }

So my request is if you could make mIRC allow a non existant variable to be used like
Code
isin $null $+ $false

Thank you, good luck.


. : Machine-Gun script named Bauderr with Trio-ircproxy.py :: .
Joined: Jan 2012
Posts: 317
Pan-dimensional mouse
Offline
Pan-dimensional mouse
Joined: Jan 2012
Posts: 317
I don't quite understand why you need this, what you want to do, what is the end goal and what should be the result. But it looks like you are doing something wrong.

You can learn how such conditions work in the example below:
Code
alias testVarValue {
  if (!%does_not_exist) { set %does_not_exist $null | echo test1: %does_not_exist (Null) }
  if (%does_not_exist == $null) { set %does_not_exist $false | echo test2: %does_not_exist (False) }
  if (%does_not_exist == $false) { set %does_not_exist $true | echo test3: %does_not_exist (True) }
  if (%does_not_exist == $true) { unset %does_not_exist | echo test4: %does_not_exist (Variable deleted) }
}

To test, enter the command: /testVarValue


What checks each condition:

  • if (!%does_not_exist) - if a variable with that name does not exist, it will be created with an empty value = "$null" — (More here).
  • if (%does_not_exist == $null) - if the variable exists and it is empty = "$null", then it is assigned the value "$false" — (More here).
  • if (%does_not_exist == $false) - if the variable has the value "$false", then it is assigned the value "$true" — (More here).
  • if (%does_not_exist == $true) - if the variable has the value "$true", then it is deleted — (More here).


Or so:

  • if (!%does_not_exist) - used when you want to check that this variable does NOT exist.
  • if (%does_not_exist) - used when you want to check that this variable does exist.



Perhaps this is how you want to check your variables, but in fact, it can be done in many ways — (More here).


🌐 http://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples
Joined: Dec 2021
Posts: 36
T
Ameglian cow
OP Offline
Ameglian cow
T
Joined: Dec 2021
Posts: 36
The purpose is to have toggle switch
Code
if (%not_existing isin $null $+ $true) { set %not_existing $false | ; $null and $true is enabled }
if (%not_existing == $false) { unset %not_existing | ; $null and $true is enabled }
You see how it saves variable space to have an unset variable to turn the script ON


. : Machine-Gun script named Bauderr with Trio-ircproxy.py :: .
Joined: Jul 2006
Posts: 4,172
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,172
Not sure I understand what you're saying, can you clarify?

A toggling variable/switch is made using two values, two boolean values of some sort.
Note that there's no difference between an existing variable set to nothing ($null) and non existing variable
Note also that "if (%switch) {" is equivalent to "if (%switch != $null) && (%switch != $false) && (%switch != 0) {"

if (%switch) { echo -ag the switch is on | unset %switch }
else { echo -ag the switch if off | set %switch $true }



if %switch is $null or if the variable don't exist (or $false or 0, but when you control the value you know you're not setting it to nothing but $true or $null) when entering the if, it would trigger the else and toggle the switch to enable it (%switch is set to $true)
if %switch is $true (or non $false and non 0 but again irrelevant here) it will disable the switch (%switch is unset, same as setting it to $null)


#mircscripting @ irc.swiftirc.net == the best mIRC help channel

Link Copied to Clipboard