mIRC Home    About    Download    Register    News    Help

Print Thread
#149731 23/05/06 01:05 PM
Joined: Aug 2003
Posts: 50
D
Babel fish
OP Offline
Babel fish
D
Joined: Aug 2003
Posts: 50
It's a stupid question I know, probably my problem needs a simple solution but I can't find it...

IF first variable OR sencond variable IS EQUAL TO null then go to label called end

I tryed:
  • if %avar || %bvar == $null goto end
  • if (%avar || %bvar) == $null goto end
  • if (%avar || %bvar == $null) goto end
  • if (%avar == $null) || ( %bvar == $null) { goto end }
  • if ((%avar == $null) || ( %bvar == $null)) { goto end }


What's wrong?

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
The last one is how you should do it. As for the problem, you probably have those not equalling $null. Throw in an echo just before the IF...

echo -a avar = %avar -- %bvar = %bvar

Then test and see if you have anything there.

Note that you can also use:

if (!%avar || !%bvar) { goto end }

However, that will also be true of one of them is 0 or $false instead of just $null.


Invision Support
#Invision on irc.irchighway.net
Joined: Apr 2006
Posts: 464
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Apr 2006
Posts: 464
Or:

if (%avar == $null) OR (%bvar == $null) { goto end }

Joined: Aug 2003
Posts: 50
D
Babel fish
OP Offline
Babel fish
D
Joined: Aug 2003
Posts: 50
Last questione: I have a dialog with a text form
I have two situations:

FIRST: if the variable %xvar is empty the dialog asks the user to fill the form

SECOND: if the variable %xvar is not NULL the dialog should appear filled with the text recived by the variable.

Code:
 if (%xvar == $null) { set %xfrm $did(1).text } ; this s the first situation
else { ...? } 


Shoud I use /dyd command? How?
Threre is also a way to transform that form in a "not writabe" form if the variable is not NULL (always showing the %xvar value of course)?

I tryed this ma the value appears only if a select the form and press a button:

Code:
   else { /did -ram DialogName 1 %xvar } 



Last edited by Dylan666; 23/05/06 05:48 PM.
Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
usage inside an on dialog event, it might go like this

if (!%xvar) { var %xvar = $input(What should it have,eo) }
elseif (%xvar) { did -a $dname ID %xvar }

Joined: Aug 2003
Posts: 50
D
Babel fish
OP Offline
Babel fish
D
Joined: Aug 2003
Posts: 50
Howerver I have the same problem: the edit box appears empty (I mean that is not showing varaible value) untill i click and try to write in it

Last edited by Dylan666; 23/05/06 06:00 PM.
Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
post a sample dialog of the section you are doing with the relevent
"on dialog" for the edit box

where does the var normally get its value from?
ie: its set in another part of the script, or in another script / alias / event

Joined: Aug 2003
Posts: 50
D
Babel fish
OP Offline
Babel fish
D
Joined: Aug 2003
Posts: 50
ok this is the code:

Code:
 
 menu nicklist {
 - My Script -
 .- Command - :  set %cvar $1 | /mydialog 
 }

 alias mydialog { dialog -m mydialog mydialog}
  dialog mydialog {
    title "This is my dialog"
  size -1 -1 245 192
  option pixels
  text "bla bla bla", 30, 16 22 150 16
  edit "", 3, 29 45 120 20
  check "dog", 33, 176 51 60 15
  text "something something something", 10, 16 87 150 16
  check "cat", 11, 178 116 60 15
  edit "", 1, 31 110 120 20
  button "OK", 100, 96 147 75 25, ok
 }

 on 1:dialog:mydialog:edit:*:{

  if (%cvar == $null) { set %bvar $did(3).text }
  else { /did -ram mydialog 3 %cvar | %bvar = %cvar } 
  set %avar $did(1).text
  }
 on 1:dialog:mydialog:sclick:100:{ if (%avar == $null) || (%bvar == $null) { goto done } 
 if ($did(mydialog,11).state == 1)  { %avar2 = cat } 
 else { %avar2 = mouse }

 if ($did(xwin,33).state == 1)  { %bvar2 = dog } 
 else { %bvar2 = elephant }
     /editbox -n $active / $+ %bvar2 %bvar %avar2 %avar | /unset %avar2 %bvar %bvar2 
    :done
 /unset %cvar %avar 
 }



I replaced the text parts with name of animals but the scripts is just as the original one.

If I use the script on a nickname using the right-click menu the dialog should appear showing the nick in the upper grayed edit box.
But it doesn't appens, the nick appears only when I try to write in that box.
I also tryed to move the focus on the second box using /did -f mydialog 1 but nothing has changed

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Look where you're filling the information in at... you're in the EDIT section. That means that it will happen when you try typing something. Not what you wanted. Instead, it should be in the INIT section..
Code:
on *:dialog:mydialog:init:*: {

}


The init section is where everything goes that should happen when a dialog is first opened (initialised).


Invision Support
#Invision on irc.irchighway.net
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Quote:
Or:

if (%avar == $null) OR (%bvar == $null) { goto end }


You can't use OR in mIRC scripting. || means OR.

Also, although mIRC allows you to not use every parentheses that you should be using, it's not really good coding style to skip them.

Rather than:
Code:
if %a == 1 { echo -a hi }


It's better to use the parentheses:
Code:
if (%a == 1) { echo -a hi }


The same is true for multiple checks as in the example... you should use:
Code:
if ((%avar == $null) || (%bvar == $null)) { goto end }


Instead of:
Code:
if (%avar == $null) || (%bvar == $null) { goto end }


It will work both ways, but it's better coding style to use all appropriate parentheses. It can also make it easier to understand.


Invision Support
#Invision on irc.irchighway.net
Joined: Aug 2003
Posts: 50
D
Babel fish
OP Offline
Babel fish
D
Joined: Aug 2003
Posts: 50
What a stupid I am!
You're are right, it was so simple... but without yuor help probabliy I wuold have found the error in days ;-)

Joined: Aug 2003
Posts: 50
D
Babel fish
OP Offline
Babel fish
D
Joined: Aug 2003
Posts: 50
Quote:
Quote:
Or:

if (%avar == $null) OR (%bvar == $null) { goto end }


You can't use OR in mIRC scripting. || means OR.


I know what || means but why can't I use it?
The Help document talks about it...

PS: changing EDIT with INIT the edit box is ok but the script desn't write anything

Last edited by Dylan666; 23/05/06 10:11 PM.
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Test it out and see. smile

Here's a quote from the help file:

Quote:
You can combine comparisons by using the && for AND and || for OR characters.


Notice it says to use || *for* OR. Not that you can use either || or OR.

So...

Code:
if ((%a == 1) OR (%a == 2)) { echo -a hi }


is incorrect. But...

Code:
if ((%a == 1) || (%a == 2)) { echo -a hi }


is correct.


Invision Support
#Invision on irc.irchighway.net
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Quote:
PS: changing EDIT with INIT the edit box is ok but the script desn't write anything


Um... you don't want to move EVERYTHING into INIT. If you want it to set the variables when you type something, that needs to be in EDIT.

All you need in INIT (for that) is:

if (%cvar != $null) { did -ram mydialog 3 %cvar }

Last edited by Riamus2; 23/05/06 10:17 PM.

Invision Support
#Invision on irc.irchighway.net
Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
clean up this
Code:
menu nicklist {
  - My Script -:  set %cvar $$1 | mydialog 
}

alias mydialog { dialog -m mydialog mydialog }
dialog mydialog {
  title "This is my dialog"
  size -1 -1 245 192
  option pixels
  text "bla bla bla", 30, 16 22 150 16
  edit "", 3, 29 45 120 20
  check "dog", 33, 176 51 60 15
  text "something something something", 10, 16 87 150 16
  check "cat", 11, 178 116 60 15
  edit %cvar , 1, 31 110 120 20
  button "OK", 100, 96 147 75 25, ok
}

on 1:dialog:mydialog:edit:*:{
;; What??? did -ram mydialog 3 %cvar [color:red]<-- this takes whatever is in %cvar 
and puts it in the editbox and disables the editbox so you cant type in it, 
what is the point in having an editbox if you cant type in it??[/color]
  %bvar = %cvar  
  set %avar $did(1).text
}

on 1:dialog:mydialog:sclick:100:{

  ;; pointless if (%avar == $null) || (%bvar == $null) { stuff }

  if ($did(mydialog,11).state == 1)  { %avar2 = cat } 
  else { %avar2 = mouse }

  if ($did(mydialog,33).state == 1)  { %bvar2 = dog } 
  else { var %bvar2 = elephant }

  echo -a editbox -n $active / $+ %bvar2 %bvar %avar2 %avar | /unset %avar2 %bvar %bvar2 

  unset %cva* %bva* %ava*
}


fine tune this to get it closer to what you really want to do, and post it back here

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Right...

Code:
 on 1:dialog:mydialog:edit:*:{

  if (%cvar == $null) { set %bvar $did(3).text }
  else { /did -ram mydialog 3 %cvar | %bvar = %cvar } 
  set %avar $did(1).text
  }


1) If you want it to insert the text, use what I wrote in my previous post for the INIT section.

2) The way you have it now, if %cvar is $null, then you can enter something into the edit box (which I assume you want). However, it will save it in %bvar and %cvar will remain $null. So you will never have a value in %cvar.


Btw, MikeChat, there are times when you may want to allow the edit box to be typed in only if there is no value already stored there. It is not often, but it can happen. Login information can be an example, though it would be set up differently than this (I'd hope).

Last edited by Riamus2; 23/05/06 10:25 PM.

Invision Support
#Invision on irc.irchighway.net
Joined: Aug 2003
Posts: 50
D
Babel fish
OP Offline
Babel fish
D
Joined: Aug 2003
Posts: 50
Quote:
clean up this [code]on 1:dialog:mydialog:edit:*:{
;; What??? did -ram mydialog 3 %cvar <-- this takes whatever is in %cvar
and puts it in the editbox and disables the editbox so you cant type in it,
what is the point in having an editbox if you cant type in it??



If the user doesn't use the right-click menu on a nick he has to specify a name, but if uses the mouse in the nicklist we have to suppose that the nick he is going to write is the nick the he has selected using the mouse

Joined: Aug 2003
Posts: 50
D
Babel fish
OP Offline
Babel fish
D
Joined: Aug 2003
Posts: 50
I will have a value in %cvar i someone uses the alias choosing a nick with the right click mouse menu.

That is not the problem, if I add an ECHO command...


Code:
  on 1:dialog:mydialog:init:*:{

  if (%cvar == $null) { set %bvar $did(3).text }
  else { /did -ram mydialog 3 %cvar | %bvar = %cvar | echo %cvar } 
  set %avar $did(1).text
  }
 


I can see that the %cvar has the nick as value

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
As I said above... you only need the one line I gave you in INIT. You should leave the stuff in EDIT there (though you can remove the ELSE line from the EDIT section).

Last edited by Riamus2; 23/05/06 10:33 PM.

Invision Support
#Invision on irc.irchighway.net
Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
Quote:

Btw, MikeChat, there are times when you may want to allow the edit box to be typed in only if there is no value already stored there. It is not often, but it can happen. Login information can be an example, though it would be set up differently than this (I'd hope).


rather than confuse this issue, you go ahead and help the OP


Link Copied to Clipboard