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

  1.  
  2. PROGRAM Tutor4;
  3.  
  4. {$A+,B-,F+,I-,Q-,R-,S-,X+}
  5.  
  6. USES
  7.   Concerto, IO, Scripts, xStrings;
  8.  
  9. VAR
  10.   Entry  : pChar3;
  11.   Number : Byte;
  12.  
  13. BEGIN
  14.  
  15. { Our brief introduction to Concerto is finished.  Now we're going to
  16.   start working on an actual door game!  We trust, at this point, that
  17.   you will refer to the INT (interface) files if you are looking for
  18.   details not described in this and subsequent tutorials. }
  19.  
  20.  
  21. { As always, the first step is to initialize the door. }
  22.  
  23. RegisterConcerto;
  24. Script('Init');
  25.  
  26.  
  27. { Our door game is going to be simple -- after you, you probably want
  28.   to get started on your *own* game as soon as possible.  We are going
  29.   to make a number guessing name (no groans!). :}
  30.  
  31.  
  32. { Select a random number }
  33.  
  34. Number:=Random(100)+1;
  35.  
  36. REPEAT
  37.  
  38.   { Display the prompt }
  39.  
  40.   SO_pChar('Enter your guess: ');
  41.  
  42.  
  43.   { Get a number from the user.  We are going to use the SI_pChar
  44.     procedure, which is a low-level pChar input routine.  It
  45.     accepts two parameters:
  46.  
  47.        1) a pChar to hold the result, and
  48.        2) the maximum length of the string.
  49.  
  50.     SI_pChar has a unique feature.  If the first parameter is not
  51.     empty, then the user will be allow to edit the existing characters!
  52.     This can be good at times, but you will have to erase the string
  53.     if you need the user to enter something from scratch.  See below. }
  54.  
  55.   Entry[0]:=#0;
  56.   SI_pChar(Entry,3);
  57.  
  58.  
  59.   { Check the answer... }
  60.  
  61.   IF p_Int(Entry)=Number THEN
  62.     BEGIN
  63.     SO_pCharLn('|FFThe geezer actually won!|07~p');
  64.     ExitDoor(0);
  65.     END
  66.   ELSE
  67.     IF p_Int(Entry)>Number THEN
  68.       SO_pCharLn('Too big, dummy.')
  69.     ELSE
  70.       SO_pCharLn('Think bigger, peabrain.');
  71.  
  72. UNTIL False;
  73.  
  74. { This line will never be reached -- look closely at the UNTIL statement! }
  75.  
  76. END.
  77.