mIRC Home    About    Download    Register    News    Help

Print Thread
Page 2 of 2 1 2
Re: PHP/C# Style 'SWITCH' statements #162182 16/10/06 04:16 PM
Joined: Nov 2004
Posts: 802
Jigsy Offline
Hoopy frood
Offline
Hoopy frood
Joined: Nov 2004
Posts: 802
He ment goto break.


What do you do at the end of the world? Are you busy? Will you save us?
Re: PHP/C# Style 'SWITCH' statements #162183 16/10/06 05:06 PM
Joined: Oct 2006
Posts: 48
G
Ghozer Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Oct 2006
Posts: 48
Quote:
What are you talking about? There is no /break or /halt command in the code.


yeah, i was meaning the goto break, i was speaking literal re: yours and previous 'hack' versions and ways round it..

Re: PHP/C# Style 'SWITCH' statements #162184 16/10/06 11:10 PM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Better would be this

Code:
alias moo { 
  var %moo = $1
  var %in = $true | while (%in) { var %in = $false
    goto %moo {
      :cow 
      echo -a moo cow 
      break 
 
      :dog 
      echo -a moo dog 
      break
 
      :d&c
      echo -a moo duck
 
       :cat 
      echo -a moo cat 
      break
 
      :%moo 
      echo -a moo mouse 
      break
    }
  }
  echo -a code beyond the case
}


thats pretty read able as well, and we even get to use the real /BREAK command

[edit]
I just thought as well it leads to another interesting option, the ability to alter %moo and recall the case select if you so desired, by use of the /CONTINUE comand, forcing it to return to the top of the while loop.

Last edited by DaveC; 16/10/06 11:13 PM.
Re: PHP/C# Style 'SWITCH' statements #162185 16/10/06 11:41 PM
Joined: Apr 2004
Posts: 759
M
Mpdreamz Offline
Hoopy frood
Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 759
Hey cool nicely "abused" mate never thought of that before. Its still not indented correctly but still the half of something is better then a whole lot of nothing smile

if implemented i would also like to see the case statement using () as well as suppose to JS/PHP since we dont use quoted strings
Code:
switch (%var) { 
  case (dog) { 
    echo -a what you know! its a dog!
    break
  }
  default { 
    echo -a what you know! its not a dog :(
  }
}

Though default doesn't really need bracketing there :tongue:


$maybe
Re: PHP/C# Style 'SWITCH' statements #162186 16/10/06 11:55 PM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
It would be much more readable without the extra pair of braces and the additional indentation of the while block, but it's an interesting idea nonetheless.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Page 2 of 2 1 2