
-----------------------------------
chrisc5553
Wed Oct 08, 2008 3:16 pm

Can any1 help me with this Integer problem please??
-----------------------------------
Hers the the problem that i got for get postive integers, and i want to change it to get intger, so it can hv negative number


function getPositiveInteger : 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

    put "Please enter a positive Integer : " ..
    
    loop
        if hasch then
            getch (ch)

            if ch >= '0' and ch = 9
    end loop

    result number
end getPositiveInteger

% Test Main
var num : int
num := getPositiveInteger
put ""
put "You entered ", num," as your number"


-----------------------------------
Clayton
Wed Oct 08, 2008 3:51 pm

RE:Can any1 help me with this Integer problem please??
-----------------------------------
Look into String manipulation and strintok(). The Turing Walkthrough is an excellent resource for something like this.

-----------------------------------
Tony
Wed Oct 08, 2008 3:53 pm

RE:Can any1 help me with this Integer problem please??
-----------------------------------
So what's the problem?

Besides checking for digits ch >= '0' and ch 