
-----------------------------------
yawam
Mon Oct 11, 2010 8:08 pm

questions about string(1) converting
-----------------------------------
hi guys 
im new to turing, so today im just trying to play around with  the codes

and i found a problem (which i dont know what's goin on and how to solve it :f)


here's the codes

var number : string(1)
get mumber
put number 

it does work when you run it
[b]but once you enter a negative number, it wont  run properly anymore, it wont return the input[/b]
it turns out to be "input string is too large for the string varibale"
so, how can i get a negative number work in string? or how can i convert a string type negative number to interger type?

btw..this is what i got when i try to convert a string type negative to interger...\\\
"string passed to strrint is not correct format" 

please help out here :\

-----------------------------------
copthesaint
Mon Oct 11, 2010 8:59 pm

RE:questions about string(1) converting
-----------------------------------
Gee MUMBERS are pretty hard arnt they?

-----------------------------------
Zren
Mon Oct 11, 2010 9:12 pm

RE:questions about string(1) converting
-----------------------------------
xD Mumbers.

Anyways
get will put the entire input string into the variable you give. The string number has room for only one character. Since negative numbers will essentially need two chracteracters "-" and "7". This breaks numbers.

You don't need to place an upper limit on numbers. You only need to do this when you use getch().

-----------------------------------
yawam
Mon Oct 11, 2010 9:16 pm

Re: RE:questions about string(1) converting
-----------------------------------
Gee MUMBERS are pretty hard arnt they?

lol..my bad..

-----------------------------------
Zren
Mon Oct 11, 2010 9:20 pm

Re: questions about string(1) converting
-----------------------------------
Uhg >.< I like to post-edit too much. Doesn't work when people answer like the lightning king.

Removing the upper limit should work for numbers with  Integer.

-----------------------------------
yawam
Mon Oct 11, 2010 9:48 pm

RE:questions about string(1) converting
-----------------------------------
i tried it befor didnt work out so well
i guees it's some other parts of the program that doesnt work or something 

thank you anyway.XD

-----------------------------------
copthesaint
Mon Oct 11, 2010 10:36 pm

Re: questions about string(1) converting
-----------------------------------
Simplest programing on the face of the planet, GOD! I wish java was this easy.
View.Set ("Graphics,offscreenonly,nobuttonbar")
var s : string := ""
loop
    if hasch then
        s := s + getchar
        Input.Flush
        delay (100)
    end if
    put s
    View.Update
    cls
end loop

The only difference between getch () and getchar. getch in turing is a "procedure" and getchar is "function", because in turing, procedures only take values, while functions take and give values.
