
-----------------------------------
someguy123
Thu Feb 01, 2007 8:05 pm

need help with procdures
-----------------------------------
var card : array 1 .. 52 of int
var cardcheck : array 1 .. 52 of boolean
var cardnum : array 1 .. 52 of int
var num : int
var counter : int := 1
var guess : string

for i : 1 .. 52
    card (i):= Pic.FileNew ("cards/" + intstr (i) + ".jpg")
    cardcheck (i) := true
end for

procedure Dealing
    loop
        randint (num, 1, 52)
        Pic.Draw (card (num), 0, 0, picCopy)
        exit when cardcheck (num) = true
    end loop
    cardcheck (num) := false
    cardnum (counter) := (num)
    counter := counter + 1    
end Dealing

procedure Guess
        locate (1,1) put "Higher or lower?"
        get guess
end Guess

procedure Compare
    if cardnum (counter) > cardnum (counter-1) and guess = "lower" then
            put "You are right."
        elsif cardnum (counter) < cardnum (counter-1) and guess = "higher" then
            put "You are right."
        else
            put "Your are wrong."
    end if
end Compare

Dealing
Guess
Dealing
Compare


during my compare procedure i dont get any value on any variable so it doesnt run correctly, andyone can give me any advice on how to fix it?

-----------------------------------
CodeMonkey2000
Thu Feb 01, 2007 8:39 pm

Re: need help with procdures
-----------------------------------
My guess is that cardnum (counter) never gets assigned a value.

-----------------------------------
someguy123
Thu Feb 01, 2007 8:42 pm

Re: need help with procdures
-----------------------------------
any idea how to fix that?

-----------------------------------
CodeMonkey2000
Thu Feb 01, 2007 9:20 pm

RE:need help with procdures
-----------------------------------
try cardnum (counter-1) > cardnum (counter-2)

-----------------------------------
someguy123
Thu Feb 01, 2007 9:49 pm

Re: RE:need help with procdures
-----------------------------------
try cardnum (counter-1) > cardnum (counter-2)

how would that make a difference..

-----------------------------------
runhardndie
Tue Feb 06, 2007 4:42 pm

Re: need help with procdures
-----------------------------------
Just choose 2 different numbers in your deal procedure. I reordered your program for you to look at..(see attached)

-----------------------------------
CodeMonkey2000
Tue Feb 06, 2007 10:42 pm

Re: RE:need help with procdures
-----------------------------------
try cardnum (counter-1) > cardnum (counter-2)

how would that make a difference..
because look at where this statement is: counter := counter + 1 this is a off-by-one error. 
If you want your way to work do:var num : int
var counter : int := 0
var guess : string

for i : 1 .. 52
    card (i) := Pic.FileNew ("cards/" + intstr (i) + ".jpg")
    cardcheck (i) := true
end for

procedure Dealing
    loop
        randint (num, 1, 52)
        Pic.Draw (card (num), 0, 0, picCopy)
        exit when cardcheck (num) = true
    end loop
    counter := counter + 1
    cardcheck (num) := false
    cardnum (counter) := (num)
end Dealing

procedure Guess
    locate (1, 1)
    put "Higher or lower?"
    get guess
end Guess

procedure Compare
    if cardnum (counter) > cardnum (counter - 1) and guess = "lower" then
        put "You are right."
    elsif cardnum (counter) < cardnum (counter - 1) and guess = "higher" then
        put "You are right."
    else
        put "Your are wrong."
    end if
end Compare

Dealing
Guess
Dealing
Compare

