Author |
Message |
wthef_wc3
|
Posted: Wed Mar 02, 2005 8:31 pm Post subject: Number pad to int |
|
|
This is my first post, and id like to say this is a great site and has proven very helpful for me.
To the point:
i am making a program that uses a mouse operated (mousewait function) number pad to get info from the use. the problem is that i cannot transfer the input value into an integer variable.
can anyone offer a solution. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
ssr
|
Posted: Wed Mar 02, 2005 8:44 pm Post subject: (No subject) |
|
|
tnx
can we see ur code?
8) |
|
|
|
|
|
jamonathin
|
Posted: Wed Mar 02, 2005 8:47 pm Post subject: (No subject) |
|
|
be more specific, like, how is your number pad set up (GUI buttons, etc.), and what is it exactly getting from the user, like a number, a word (string), because if you're getting a decimal number from them, then do this; code: | var real_number : real := 32.56
var int_number : int := round (real_number)
put int_number |
but if it's a string value (that's still a number, juss use strint . . .
code: | var str_number : string := "45"
var int_number : int := strint (str_number)
put int_number |
and if it's anything else, juss clarify |
|
|
|
|
|
ssr
|
Posted: Wed Mar 02, 2005 8:53 pm Post subject: (No subject) |
|
|
lol yes be more specific,
for the strint option
u can test it with strintok
but I think u already know these
eh? 8) |
|
|
|
|
|
person
|
Posted: Wed Mar 02, 2005 9:02 pm Post subject: (No subject) |
|
|
u can also div it by one to make it into an int instead of real |
|
|
|
|
|
ssr
|
Posted: Wed Mar 02, 2005 9:08 pm Post subject: (No subject) |
|
|
we r talking about for real to int now eh
all mean round
one round up and the other round down
lol
learnt this from some1 in this forum
forgot teh name |
|
|
|
|
|
Flikerator
|
Posted: Wed Mar 02, 2005 9:24 pm Post subject: (No subject) |
|
|
If its an int to a real;
intreal ()
that simple |
|
|
|
|
|
jamonathin
|
Posted: Wed Mar 02, 2005 10:04 pm Post subject: (No subject) |
|
|
I guess we can all just sit around and take random guesses at what this boy wants figured out |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Flikerator
|
Posted: Wed Mar 02, 2005 10:05 pm Post subject: (No subject) |
|
|
jamonathin wrote: I guess we can all just sit around and take random guesses at what this boy wants figured out
Well thats what we are doing |
|
|
|
|
|
wthef_wc3
|
Posted: Wed Mar 02, 2005 10:59 pm Post subject: (No subject) |
|
|
wow, fast service lol.
ok to be more specific
its a number pad so 0-9 can be pressed, in my program i need to allow the user to enter in a 7 digit int amount using the number pad.
im programs on other comp but its set up using a simple mouse.wait function. the buttons are not GUI.
to sum up i need to know how to change an input that is seperate int numbers (ie. "3" "5" "5" "6" "4" "8" "7") which is entered through the pad, into the number 3556487.
when a number is pressed i have an int variable to store each number, i need to know how to change the 7 int vars into one real var with a number like below
number as entered by numpad (ie. "3" "5" "5" "6" "4" "8" "7") to = on int var with value :=3556487 |
|
|
|
|
|
jamonathin
|
Posted: Thu Mar 03, 2005 6:50 am Post subject: (No subject) |
|
|
What you can do, is after you get ur 7 numbers, add them one by one to a string, then convert that into an int value. . .
code: |
var numbs : array 1 .. 7 of int
var hold : string := ""
var newnumb : int
put "enter a number"
for i : 1 .. 7
locate (2, 1)
get numbs (i)
hold += intstr (numbs (i))
end for
newnumb := strint (hold)
put newnumb
| |
|
|
|
|
|
ssr
|
Posted: Fri Mar 04, 2005 10:44 pm Post subject: (No subject) |
|
|
[quote="jamonathin"]What you can do, is after you get ur 7 numbers, add them one by one to a string, then convert that into an int value. . .
[quote]
just as an example of that
try this
at least thats how i did it
code: | put strint ("5"+"4") |
|
|
|
|
|
|
|