ID:267684
 
hi

can switch(alerts go bigger than three choices?

thanks
No, beyond that, we tend to use input()'s instead.
In response to Foomer
because i am making a calculater with alerts and var's and well you know calculator stuff.

and;

switch(alert("[numberA] ? [numberB]",,"+","-","%"(and then there is meant to be a "*" but it wont work,

how can i get around this?
In response to Mousie_kebabs
switch(input("[numberA]?[numberB]","Do what?") in list("+","-","/","*"))

Note: / is divide...% is percent... But it does kinda look like divide =\
In response to JackGuy
thanks for that but,

i still cant use all four math symbols.
In response to Mousie_kebabs
What do you mean? Make sure you have If statements after it...
if("+")
alert("[numberA+numberB]")
if("-")
etc etc etc
In response to JackGuy
well you cant have more than 3 if("")'s in a switch(alert

foomer suggested using input's and i was wondering how i could use inputs instead of switc(alerts.

thanks
I suggest looking at AbyssDragon's "SET (SET Evaluates Things)" library. It's awesome. It would let your user input math operators without an alert, even.
In response to Lord of Water
thanks again again lord
In response to Mousie_kebabs
ok thats a little to complicated for me.

all i need to know now is how to use inputs in the same way as switch alerts.

thansk
In response to Mousie_kebabs
I like this way best..
var/math = input("Which operation?") in list ("+","-","*","/")
switch(math)
if("+")
//do add stuff...


-Camaro-
In response to Camaro
thansk :-D
In response to Camaro
code.dm:6:error:list:undefined proc
code.dm:7:error:math:value not allowed here
code.dm:8:error:"+":duplicate definition
code.dm:11:error:"-":duplicate definition
code.dm:14:error:"*":duplicate definition
code.dm:17:error:"/":duplicate definition
code.dm:10:error:usr:duplicate definition
code.dm:10:error:numberC:value not allowed here
code.dm:10:error::empty type name (indentation error?)
code.dm:10:error:text "[]":value not allowed here
code.dm:10:error::duplicate definition
code.dm:10:error:<< :instruction not allowed here
code.dm:9:error::duplicate definition
code.dm:13:error:usr:duplicate definition
code.dm:13:error:numberC:value not allowed here
code.dm:13:error::empty type name (indentation error?)
code.dm:13:error:text "[]":value not allowed here
code.dm:13:error::duplicate definition
code.dm:13:error:<< :instruction not allowed here
code.dm:12:error::duplicate definition
code.dm:16:error:usr:duplicate definition
code.dm:16:error:numberC:value not allowed here
code.dm:16:error::empty type name (indentation error?)
code.dm:16:error:text "[]":value not allowed here
code.dm:16:error::duplicate definition
code.dm:16:error:<< :instruction not allowed here
code.dm:15:error::duplicate definition
code.dm:19:error:usr:duplicate definition
code.dm:19:error:numberC:value not allowed here
code.dm:19:error::empty type name (indentation error?)
code.dm:19:error:text "[]":value not allowed here
code.dm:19:error::duplicate definition
code.dm:19:error:<< :instruction not allowed here
code.dm:18:error::duplicate definition
code.dm:8:error::empty type name (indentation error?)
code.dm:7:error::empty type name (indentation error?)
In response to Mousie_kebabs
Sounds to me like a misplaced ( or ". Those can cause massive amounts of errors even in otherwise bugless code. Check over your new sections of code and make sure that your parenthesis and quotes match up.
In response to Lord of Water
well i got it down to know errors by moving the code around.
but it still does not work;

here is my code

mob
Login()
switch(math)
if("+")
numberC = numberA + numberB
usr << "[numberC]"
if("-")
numberC = numberA - numberB
usr << "[numberC]"
if("*")
numberC = numberA * numberB
usr << "[numberC]"
if("/")
numberC = numberA / numberB
usr << "[numberC]"

var/numberA = input("First Number?") as num
var/numberB = input("Second Number?") as num
var/numberC = 0
var/math = input("Which operation?") in list ("+","-","*","/")

when you log in;

runtime error: bad client
proc name:
usr: null
src:
call stack:
: ()
In response to Mousie_kebabs
you forgot a ..() in the Login()...which means their client and etc. don't get initialized

e-also, you can't just do var/math=input..blablabla, define var/math with nothing attached, and on Login(), usr.math=input...etc.
In response to Mousie_kebabs
You didn't do what I told you to do :P.

-Camaro-
In response to The mothball
The mothball wrote:
you forgot a ..() in the Login()...which means their client and etc. don't get initialized

Wrong. The only thing calling ..() in Login() should do is set up the basic things like a location. Unless you call Login() manually, a client is already connected; it's generally only semi-safe to assume usr is the same as src, but otherwise there shouldn't be a problem. In this case, usr was not correct, and that's why the code failed. It had nothing to do with missing ..().

Lummox JR
In response to Lummox JR
i got it to work, instead of having the switch(math)

i just had switch(input(

and it works now, still trying to work out a graphical on though.