Files
harbour-core/harbour/contrib/examples/misc/guess.prg
Viktor Szakats 6e47dd35f5 2007-11-10 18:03 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* Makefile
   - samples
   + contrib/examples
   * contrib/Makefile
   * contrib/examples/Makefile
   * contrib/examples/guestbk/inifiles.prg
   * contrib/examples/guestbk/testcgi.prg
   * contrib/examples/guestbk/bld_b32.bat
   * contrib/examples/guestbk/Makefile
   * contrib/examples/pe/pe.prg
   * contrib/examples/pe/Makefile
   * contrib/examples/misc/Makefile
   * contrib/examples/hscript/bld_b32.bat
   * contrib/examples/hscript/Makefile
   * contrib/examples/Makefile
     * Moved /samples to /contrib/examples
2007-11-10 17:04:20 +00:00

61 lines
1.1 KiB
Plaintext

/*
* $Id$
*/
//
// Guess a number
//
// Date : 1999/04/22
//
// My first application (big word) written in Harbour
//
// Written by Eddie Runia <eddie@runia.com>
// www - http://www.harbour-project.org
//
// Placed in the public domain
//
extern OutStd
function Main()
local flGuessed
local CRLF := chr(13)+chr(10)
local nSeed := 241
local nPick
QQOut( "Welcome to guess a number....", CRLF )
QQOut( "You have to guess a number between ",0," and 255", CRLF )
do while Upper( Read( "Continue Y/N : " ) ) == "Y"
nSeed := (( nSeed * 11) + 5) % 256
flGuessed := 0
do while flGuessed == 0
nPick := Val( Read( "Value : " ) )
if nPick > 255
QQOut( "More than 255", CRLF )
elseif nPick < 0
QQOut( "Less than 0", CRLF )
elseif nPick > nSeed
QQOut( "Try lower", CRLF )
elseif nPick < nSeed
QQOut( "Try higher", CRLF )
else
QQOut( "Congratulations, you've guessed the number", CRLF, CRLF )
flGuessed := 1
endif
enddo
enddo
return nil
function Read( cPrompt ) // Simple read function.
return __Accept( cPrompt )