home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 31 / CDASC_31_1996_juillet_aout.iso / vrac / cddk9605.zip / TUTOR.ARJ / TUTOR7.PAS < prev    next >
Pascal/Delphi Source File  |  1996-05-16  |  1KB  |  77 lines

  1.  
  2. PROGRAM Tutor7;
  3.  
  4. {$A+,B-,F+,I-,Q-,R-,S-,X+}
  5.  
  6. USES
  7.   Concerto, IO, Scripts, Types, xStrings;
  8.  
  9. CONST
  10.   Prompt  : pChar = NIL;
  11.   TooHigh : pChar = NIL;
  12.   TooLow  : pChar = NIL;
  13.   Winner  : pChar = NIL;
  14.  
  15. VAR
  16.   Entry   : pChar3;
  17.   Guesses : Byte;
  18.   Number  : Byte;
  19.  
  20.  
  21. PROCEDURE RegisterGame;
  22.   BEGIN
  23.   RegisterByte    ('Guesses', @Guesses);
  24.   RegisterDynamic ('Prompt',  @Prompt);
  25.   RegisterDynamic ('TooHigh', @TooHigh);
  26.   RegisterDynamic ('TooLow',  @TooLow);
  27.   RegisterDynamic ('Winner',  @Winner);
  28.  
  29.   { The RegisterDynamic procedure registers a special type of
  30.     variable with Concerto: a null-terminated string that is
  31.     reallocated and deallocated as needed.  Look at TYPES.INT
  32.     for more information. }
  33.  
  34.   END;
  35.  
  36.  
  37. BEGIN
  38.  
  39. { Setup the door }
  40.  
  41. RegisterConcerto;
  42. RegisterGame;
  43. Script('Init');
  44.  
  45. {***}
  46. Script('Init7');     { Examine INIT7.SCR now! }
  47. {***}
  48.  
  49. SO_ClrScr;
  50. Guesses:=0;
  51. Number:=Random(100)+1;
  52.  
  53. REPEAT
  54.  
  55.   { Get an entry }
  56.  
  57.   SO_pChar(Prompt);
  58.   Entry[0]:=#0;
  59.   SI_pChar(Entry,3);
  60.   SO_CRLF;
  61.   Inc(Guesses);
  62.  
  63.  
  64.   IF p_Int(Entry)=Number THEN
  65.     BEGIN
  66.     SO_pCharLn(Winner);
  67.     ExitDoor(0);
  68.     END
  69.   ELSE
  70.     IF p_Int(Entry)>Number THEN
  71.       SO_pCharLn(TooHigh)
  72.     ELSE
  73.       SO_pCharLn(TooLow);
  74.  
  75. UNTIL False;
  76. END.
  77.