mIRC Home    About    Download    Register    News    Help

Print Thread
/goto: duplicate 'error' found #146008 30/03/06 12:49 PM
Joined: Nov 2004
Posts: 148
D
Dr_Brom_sung_ Offline OP
Vogon poet
OP Offline
Vogon poet
D
Joined: Nov 2004
Posts: 148
I'm having problems understanding why it fails (Logically).

Lets assume that sound.mp3 exists.


Code:
alias err {
  if ($1 == 1) {
    if ($exists("sound.mp3") == $true) {
      splay -q "sound.mp3"
      :error
    }
     goto end
  }
  if ($2 == 1) {
    if ($exists("sound.mp3") == $true) {
      splay -q "sound.mp3"
      :error
    }
  }
  :end
}

  



If I write: /err 1 then I get /goto: duplicate 'error' found


If I remove the " goto end" then it doesn't fail. My question is WHY??? I see no logic in this. confused confused

Re: /goto: duplicate 'error' found #146009 30/03/06 01:11 PM
Joined: Dec 2003
Posts: 261
M
milosh Offline
Fjord artisan
Offline
Fjord artisan
M
Joined: Dec 2003
Posts: 261
The problem is that you used :error twise. I don't see why do you need that goto point, you are not even using it.


velicha dusha moja Gospoda
Re: /goto: duplicate 'error' found #146010 30/03/06 01:24 PM
Joined: Dec 2003
Posts: 261
M
milosh Offline
Fjord artisan
Offline
Fjord artisan
M
Joined: Dec 2003
Posts: 261
And it fails becouse, when you use goto then the script is looking for goto points (:error and :end in your case) in every if statement and you have two of :error. If you don't use goto, then only one :error point is seen, becouse the second if statement is not looked, becouse it is not true.


velicha dusha moja Gospoda
Re: /goto: duplicate 'error' found #146011 30/03/06 01:54 PM
Joined: Nov 2004
Posts: 148
D
Dr_Brom_sung_ Offline OP
Vogon poet
OP Offline
Vogon poet
D
Joined: Nov 2004
Posts: 148
I can also use /err 0 1 and then the second if happens!

Quote:
The problem is that you used :error twise


Well, what do you suggest? confused Sometimes when playing sounds, windows has problems playing it and then it causes error in mIRC.
This causes the script to halt!!! And since I don't want the script to halt then I use :error
Since I want it to continue just after the play command then I need to put :error after each "/splay" command.




If I remove the "goto end" and write: /err 1 1 then it should play the sound.mp3 twice... and since both statements are true and it fails.
How can I prevent the script from halting on error with this case (When it can't play the mp3 file and it has to play it twince in 2 different places in the alias) ??
How do I prevent it from

Re: /goto: duplicate 'error' found #146012 30/03/06 02:05 PM
Joined: Dec 2004
Posts: 66
B
Bob57 Offline
Babel fish
Offline
Babel fish
B
Joined: Dec 2004
Posts: 66
I use goto sometimes but itís usually cleaner to script without them.
Code:
 
alias err {
  if ($1 == 1) {
    if ($exists("sound.mp3") == $true) splay -q "sound.mp3"
  }
  elseif ($2 == 1) {
    if ($exists("sound.mp3") == $true) splay -q "sound.mp3"
  }
}


Hmm, you are already testing for if the sound file exists, I havenít had mirc error on a sound file if itís found, try this:
Code:
 
alias err {
  if ($1 == 1) {
    if ($exists("sound.mp3") == $true) splay -q "sound.mp3"
  }
  elseif ($2 == 1) {
    if ($exists("sound.mp3") == $true) splay -q "sound.mp3"
  }
  :error
}


Since both use the same found file you can write it this way:
Code:
 
alias err {
  if (($1 == 1) || ($2 == 1)) {
    if ($exists("sound.mp3") == $true) splay -q "sound.mp3"
    else echo -s "sound.mp3" not found in alias err
  }
  :error
}

Re: /goto: duplicate 'error' found #146013 30/03/06 02:14 PM
Joined: Jan 2006
Posts: 468
symphony Offline
Fjord artisan
Offline
Fjord artisan
Joined: Jan 2006
Posts: 468
Hi there,
Use this code.
Code:
alias err {
  if ($1 == 1) {
    if $exists($qt(sound.mp3)) {
      splay -q $qt(sound.mp3)
    }
    else { echo -a Error }
  }
  elseif ($1 == 2) {
    if $exists($qt(sound.mp3)) {
      splay -q $qt(sound.mp3)
    }
    else { echo -a Error }
  }
}


PS: if $2 == 1 will not be supported like this, you need to use if ($1) && ($2) then if ($2 == <value>) etc.. but this code I posted for you shall work.

Re: /goto: duplicate 'error' found #146014 30/03/06 02:28 PM
Joined: Dec 2004
Posts: 66
B
Bob57 Offline
Babel fish
Offline
Babel fish
B
Joined: Dec 2004
Posts: 66
My understanding is that an alias should have at most one :error, it doesnít have to be right after the command that might cause the error, an error that happens anywhere in the alias will jump to the :error.
Code:
alias err {
  if ($1 == 1) {
    splay -q "sound.mp3"
  }
  elseif ($2 == 1) {
    splay -q "sound.mp3"
  }
  goto end
  :error
  echo -s Error in alias err: $error
  reseterror
  :end
}


The reseterror might not be needed, simply having the :error in the alias might take care of it.

Re: /goto: duplicate 'error' found #146015 30/03/06 04:00 PM
Joined: Nov 2004
Posts: 148
D
Dr_Brom_sung_ Offline OP
Vogon poet
OP Offline
Vogon poet
D
Joined: Nov 2004
Posts: 148
Well, for your information playing the sound may also fail because of codecs problems.

Bad codecs or something that prevents the sound from being played can cause an error even if it exists. I had this problem more than once, and I had to reinstall the codecs or restart the computer to solve it.

The point is that I don't want to make the alias jump to the end if it has an error. I just want it to continue.

Well, nevermind.

Thanks

Re: /goto: duplicate 'error' found #146016 30/03/06 04:04 PM
Joined: Feb 2005
Posts: 681
M
mIRCManiac Offline
Fjord artisan
Offline
Fjord artisan
M
Joined: Feb 2005
Posts: 681
If you don't want the script to halt if there is an
error playing the sound file, use a timer..

.timer 1 0 splay -q "sound.mp3"

Re: /goto: duplicate 'error' found #146017 30/03/06 05:04 PM
Joined: Nov 2004
Posts: 148
D
Dr_Brom_sung_ Offline OP
Vogon poet
OP Offline
Vogon poet
D
Joined: Nov 2004
Posts: 148
Yeah I though of that. Either having a timer or calling another alias that will play the sound and will have a :error

Thanks for the idea, I didn't think of using a timer smirk