
-----------------------------------
foo fighter
Wed Nov 23, 2005 11:48 am

&quot;get&quot; help
-----------------------------------
how do i make a get command where the user doesn't have to press enter after typing in a word or number or somethin like that :? [/b]

-----------------------------------
Tony
Wed Nov 23, 2005 11:51 am


-----------------------------------

var c : string (1)
getch (c)
put "you pressed : ", c

works for a single character. If you put getch() in a loop, you could get whole words

-----------------------------------
foo fighter
Wed Nov 23, 2005 12:18 pm


-----------------------------------
alright well i understand how the strings work but it doesnt seem to work with int

this is what ive tried:

var number : int (1)
getch number[/b]

-----------------------------------
Tony
Wed Nov 23, 2005 12:20 pm


-----------------------------------
it works for characters only.

if you want a digit, you getch() it as a character, and then strint() convert it to a digit

-----------------------------------
foo fighter
Wed Nov 23, 2005 12:32 pm


-----------------------------------
could i get an example, cause i'm not familiar with strint commands

-----------------------------------
Tony
Wed Nov 23, 2005 12:35 pm


-----------------------------------
var c : string (1)
getch (c)
if strintok (c) then
    put strint (c), " is more than 5 :: ", strint (c) > 5
end if


-----------------------------------
Albrecd
Wed Nov 23, 2005 1:19 pm


-----------------------------------

var stuff :char
put "please press a letter key"
stuff := getchar
put "you pressed the ",stuff," key"


Try that

-----------------------------------
foo fighter
Wed Nov 23, 2005 5:34 pm


-----------------------------------
Ok im done with getch stuff.  now i have a new problem, i cant divide integers

take at look:

var bi, binary : int

put "Enter a number: "
get bi

binary := bi / 2

when i divide by 2, i get "assigned value wrong type" 2 is high-lighted

-----------------------------------
Cervantes
Wed Nov 23, 2005 6:37 pm


-----------------------------------
That's because binary is an integer.  But division using / returns a real number.  (Think: 13 / 2).  

Alternatives are to use div, as in
binary := bi div 2
Or use round, as in
binary := round (bi / 2)
