Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: +SOLVED+ Returning a number +SOLVED+  (Read 809 times)

0 Members and 1 Guest are viewing this topic.

Source

Internet Tough Guy.
+SOLVED+ Returning a number +SOLVED+
« on: November 19, 2006, 03:55:15 am »
  • Things to see and people to do.
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 2289
In GM's show_menu function, I want it to return x if nothing is selected. Here's an example:

Code: [Select]
{
 exmenu = show_menu('Item0|Item1|Item2','5')
{
switch(exmenu)
{
case 0: show_message('You picked item 0!'); break;
case 1: show_message('You picked item 1!'); break;
case 2: show_message('You picked item 2!'); break;
case 5: break;
}
}
}

Ok, so for each of the menu items, a number is returned. In this case, 0, 1, and 2 are returned. Since the default return is set to 5, I figured that making a case 5 and causing it to break would make it to where 0 would not be returned and case 0 will not initiate, thus causing the menu to close without selecting anything. Unfortunately, this isn't the case, as 0 is returned anyway. Anyone know how to make it so 5 is returned instead? Thanks!
« Last Edit: November 19, 2006, 08:12:31 am by Cronian »
Logged
The very existence of flamethrowers proves that sometime, somewhere, someone thought to themselves "You know, I really want to set those people over there on fire." - George Carlin

(!@#$%)

Hear the haunting words (They'll find you alone)
lost children with no heart are crying (Turning their hearts into stone)
and you're the lost mother they're calling
Go now, run and hide (seek more than vengeance)
I hear them crying at night (your pain is their satisfaction)
outside when the planets are falling (for the rest of time)
They want to feel and know you hear them (Go now, run and hide)

  • http://giantcock.netne.net/

Jed

Re: Returning a number
« Reply #1 on: November 19, 2006, 06:28:20 am »
I bealive if you use case default: break; it'll go to that instead of 5, but will have the effect your after.
Logged

Goodnight

Once and future Captain
Re: Returning a number
« Reply #2 on: November 19, 2006, 07:03:13 am »
  • With a Capital G
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Gender: Male
  • Posts: 706
Try taking the quotations off of '5'.

Right now, '5' is a string, which has a numerical value of 0.

If you ever do use Jed's suggestion, I believe you don't need case if you type default, but I rarely use that and would need to double-check.
Logged
Re: Returning a number
« Reply #3 on: November 19, 2006, 07:55:17 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 2245
default is used when you want to execute some code when none of the previous cases have been gone through, if your just breaking, it's useless :S
Logged

Source

Internet Tough Guy.
Re: Returning a number
« Reply #4 on: November 19, 2006, 08:11:58 am »
  • Things to see and people to do.
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 2289
Thank you, but I figured it out on my own.

UBER LOCKAGE!
Logged
The very existence of flamethrowers proves that sometime, somewhere, someone thought to themselves "You know, I really want to set those people over there on fire." - George Carlin

(!@#$%)

Hear the haunting words (They'll find you alone)
lost children with no heart are crying (Turning their hearts into stone)
and you're the lost mother they're calling
Go now, run and hide (seek more than vengeance)
I hear them crying at night (your pain is their satisfaction)
outside when the planets are falling (for the rest of time)
They want to feel and know you hear them (Go now, run and hide)

  • http://giantcock.netne.net/
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.423 seconds with 45 queries.