mIRC Homepage
Posted By: Dr_Brom_sung_ /goto: duplicate 'error' found - 30/03/06 12:49 PM
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
Posted By: milosh Re: /goto: duplicate 'error' found - 30/03/06 01:11 PM
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.
Posted By: milosh Re: /goto: duplicate 'error' found - 30/03/06 01:24 PM
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.
Posted By: Dr_Brom_sung_ Re: /goto: duplicate 'error' found - 30/03/06 01:54 PM
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
Posted By: Bob57 Re: /goto: duplicate 'error' found - 30/03/06 02:05 PM
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
}
Posted By: symphony Re: /goto: duplicate 'error' found - 30/03/06 02:14 PM
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.
Posted By: Bob57 Re: /goto: duplicate 'error' found - 30/03/06 02:28 PM
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.
Posted By: Dr_Brom_sung_ Re: /goto: duplicate 'error' found - 30/03/06 04:00 PM
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
Posted By: mIRCManiac Re: /goto: duplicate 'error' found - 30/03/06 04:04 PM
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"
Posted By: Dr_Brom_sung_ Re: /goto: duplicate 'error' found - 30/03/06 05:04 PM
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
© mIRC Discussion Forums