Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: let's re-visit math oper. in a var.

From: anton:wilddsl:au at: 4-Apr-2009 17:25

Just before you go, try this: Paste it into your console or put it in a script. print "Press escape to exit the loop." forever [ num1: to-integer ask "Enter the 1st number: " num2: to-integer ask "Enter the 2nd number: " op: all [pos: find "+-*/" ask "Enter an operator [+ - * /]: " get to-word form first pos] result: op num1 num2 print ["result:" result] ] Note that TO-INTEGER needs valid input, or errors to be trapped, but we can add that later. OP is here guaranteed to be one of the four operators or NONE (thanks to ALL). Regards, Anton. wrote: