Computer Science Canada

strint help please

Author:  Bakon [ Thu May 12, 2005 5:23 pm ]
Post subject:  strint help please

Okay, so what Im doing is getting text from the GUI.CreateTextField function, but this text is a string. So what i need to do is convert the string variable, into an integer variable so that I can do for example var1 + var2, right now because of the text being a string, it cannot perform this calculation. I usefd to knwo how, can someone please refresh my memory... Very Happy

Its sometihng like:

strint myVariable(myVariableStr)... I dont know :S

Author:  Cervantes [ Thu May 12, 2005 5:34 pm ]
Post subject: 

strint (s : string [, base : int]) : int
Ex.
code:

num := strint (input)

Base 10 is assumed.

You'll also want to check if the string can be successfully turned into an integer. For this, use strintok

Ex.
code:

get input
if strintok (input) then
  num := strint (input)
end if


Please, check the help file and the turing tutorials first. The help file explains this well enough, and I recently wrote a tutorial on this. It's called String Manipulation, if you want to look.

Author:  Bakon [ Thu May 12, 2005 8:04 pm ]
Post subject: 

Sadly this did not work:

this is the input, it takes the input from the text field...

numeratorTextField := GUI.CreateTextFieldFull (26, 500, 100, "",
numerator_proc, GUI.INDENT, 0, 0)

this is the conversion code

numeratorTextField := strint (numeratorTextFieldstr)


: