
-----------------------------------
chrisc5553
Fri Oct 10, 2008 8:26 am

Can anyone help me with this real# problem??
-----------------------------------
Here is the program that i got for getting integer, but im hving trouble with changing it to get Real number.

function getInteger : int
   const ENTER  : char := chr (10) % Constant ASCII code for the Enter Key 
   var   ch     : string (1) := 'x'
   var   number : int := 0
   var   digits : int := 0
   var   negative : boolean := false
   
   put "Please enter a Integer : " ..
    
   loop
      if hasch then
         getch (ch)
         
         if negative = true then
            number := -1 * strint(ch) + number * 10  
            digits := digits + 1
            
         elsif negative = false then
            if ch >= '0' and ch = 9         
   end loop     result number

end getInteger

% Test Main
var num : int
num := getInteger
put ""
put "You entered ", num," as your number"

Mod Edit: Code Tags! Last warning.

-----------------------------------
CodeMonkey2000
Fri Oct 10, 2008 9:57 am

RE:Can anyone help me with this real# problem??
-----------------------------------
Your program still crashes for negative integers. For real numbers you just ignore the decimal. and use strreal.
