Hi All,
After years of missing THINKS Pascal on the Mac, I thought I would give gpc a quick try! It seems pretty cool too!
The first question I wanted to ask is about this list - can I ask coding questions here, or is it purley for actual gpc development?
Andrew McCall wrote:
After years of missing THINKS Pascal on the Mac, I thought I would give gpc a quick try! It seems pretty cool too!
Thanks. :-)
The first question I wanted to ask is about this list - can I ask coding questions here, or is it purley for actual gpc development?
Yes, the it's for both.
Frank
On Tuesday 05 November 2002 4:17 pm, Frank Heckenbach wrote:
Andrew McCall wrote:
The first question I wanted to ask is about this list - can I ask coding questions here, or is it purley for actual gpc development?
Yes, the it's for both.
Frank
Cool!
Well, I have just been getting used to programming in Pascal again, and I thought I would write the age-old number guessing game. It all works, well it *should* but I seem to be having problems with some logic in an if statement:
if (iGuess > 0) or (iGuess < 101) then { do my code }
I thought this bit of code should detect if iGuess is inbetween 0 and 100, but it doesn't seem to work! Can anyone tell me why?
Also is there a random number generator in gpc? I have hardcoded the value for this program, I want to play with it being random too :)
Thanks!
On Wed, Nov 06, 2002 at 09:53:34AM +0000, Andrew McCall wrote:
On Tuesday 05 November 2002 4:17 pm, Frank Heckenbach wrote: if (iGuess > 0) or (iGuess < 101) then { do my code }
Your condition is always true:
a) 0 is same as 0 (false) b) 0 is lower than 101 (true) a) or b) is true
Similar with 10000.
Try writing if (iGuess > 0) and (iGuess < 101) then { do your code }
Also is there a random number generator in gpc? I have hardcoded the value for this program, I want to play with it being random too :)
Just call Random from the GPC unit.
Eike
On Wednesday 06 November 2002 10:10 am, Eike Lange wrote:
On Wed, Nov 06, 2002 at 09:53:34AM +0000, Andrew McCall wrote:
On Tuesday 05 November 2002 4:17 pm, Frank Heckenbach wrote: if (iGuess > 0) or (iGuess < 101) then { do my code }
Try writing if (iGuess > 0) and (iGuess < 101) then { do your code }
Oh man! I can't believe I spent about 40 minutes yesterday looking at that before starting to think that it was actually some weirdo thing with Pascal I didn't remember! I can't believe I didn't realise I was doing it totally wrong :)
Thanks, thats working now.
Also is there a random number generator in gpc? I have hardcoded the value for this program, I want to play with it being random too :)
Just call Random from the GPC unit.
I have looked for a random like function or procedure, but can't find one. How do I do what you suggest? Any docs?
On Wed, Nov 06, 2002 at 10:45:06AM +0000, Andrew McCall wrote:
On Wednesday 06 November 2002 10:10 am, Eike Lange wrote:
Just call Random from the GPC unit.
I have looked for a random like function or procedure, but can't find one. How do I do what you suggest? Any docs?
program foo; var i: Cardinal; begin for i := 1 to 10 do WriteLn (Random (4)) { random number between 0 and 3 (is 4 - 1) } end.
Eike
Andrew McCall wrote:
Well, I have just been getting used to programming in Pascal again, and I thought I would write the age-old number guessing game. It all works, well it *should* but I seem to be having problems with some logic in an if statement:
if (iGuess > 0) or (iGuess < 101) then { do my code }
I thought this bit of code should detect if iGuess is inbetween 0 and 100, but it doesn't seem to work! Can anyone tell me why?
Try 'and'. The above is synonymous with 'true'.
Set your outgoing line length wrap to something well under 80. I use 65.