Computer Science Canada

strint help

Author:  beamer [ Fri Nov 11, 2005 12:45 pm ]
Post subject:  strint help

does anyone know how to get strint to work? I can't seem to get my inputed number to convert into a number to compare with a sum of 2 random numbers Sad . any help would be greatly appreciated.

Author:  Tony [ Fri Nov 11, 2005 1:03 pm ]
Post subject: 

Turing:

put strint ("1") + 1

or just have user input the number directly
Turing:

var num : int
get num
put num + 1

then there's no need for strint()

Author:  codemage [ Fri Nov 11, 2005 1:05 pm ]
Post subject: 

Like so:

code:
var s : string
var i : int

get s % ie s = "12345"
i := strint(s)

Author:  MysticVegeta [ Fri Nov 11, 2005 6:58 pm ]
Post subject: 

I suggest that you also pay a little attention to the "strintok" command. Useful for errortraping later.

Author:  do_pete [ Mon Nov 14, 2005 11:37 am ]
Post subject: 

yeah you could go:
code:
var input : string
var interger : int
loop
    put "Enter a number: " ..
    get input
    exit when strintok (input)
end loop
interger := strint (input)

Author:  codemage [ Mon Nov 14, 2005 1:00 pm ]
Post subject: 

Even better if you give the user some feedback on incorrect input.

code:
loop
    put "Enter a number: " ..
    get input
    exit when strintok (input)
    put "How about an actual number this time, wiseguy."
end loop

Author:  wtd [ Mon Nov 14, 2005 1:24 pm ]
Post subject: 

codemage wrote:
Even better if you give the user some feedback on incorrect input.

code:
loop
    put "Enter a number: " ..
    get input
    exit when strintok (input)
    put "How about an actual number this time, wiseguy."
end loop


If it helps so see the control flow a bit more clearly.

code:
loop
    put "Enter a number: " ..
    get input
 
    if strintok (input) then
        exit
    else
        put "How about an actual number this time, wiseguy."
    end if
end loop


: