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

  1.  
  2. PROGRAM Tutor6;
  3.  
  4. {$A+,B-,F+,I-,Q-,R-,S-,X+}
  5.  
  6. USES
  7.   Concerto, IO, Scripts, Types, xStrings;
  8.  
  9. CONST
  10.   Prompt  : pChar40 = 'And on this day, he spoke: ';
  11.   TooHigh : pChar80 = 'Your eyes are toward the heavens, esteemed one.~|';
  12.   TooLow  : pChar80 = 'Your feet forever touch the earth, O Great One!~|';
  13.   Winner  : pChar80 = 'He has left us, after a mere {guesses} verses.~p';
  14.  
  15.                                                     {^^^^^^^}
  16.                                                     {examine}
  17. VAR
  18.   Entry   : pChar3;
  19.   Guesses : Byte;
  20.   Number  : Byte;
  21.  
  22.  
  23. PROCEDURE RegisterGame;
  24.   BEGIN
  25.  
  26.   { This procedure registers our variables with Concerto.  This has a
  27.     great effect: The sysop can now access these variables in any text
  28.     file or script!  We'll start with the strings: }
  29.  
  30.   RegisterString('Prompt',  @Prompt,  40);
  31.   RegisterString('TooHigh', @TooHigh, 80);
  32.   RegisterString('TooLow',  @TooLow,  80);
  33.   RegisterString('Winner',  @Winner,  80);
  34.  
  35.   { Next, register the new variable: }
  36.  
  37.   RegisterByte('Guesses', @Guesses);
  38.  
  39.   { These variables can now be accessed in a few different ways:
  40.  
  41.     a. Script: LET <variable> = <value>
  42.     b. String: Hello {username}
  43.  
  44.   { Refer to SYSOP.DOC for more information. }
  45.  
  46.   END;
  47.  
  48.  
  49. BEGIN
  50.  
  51. RegisterConcerto;
  52.  
  53. { Before we run the initialization script, let's *EXTEND* the language! }
  54.  
  55. RegisterGame;
  56.  
  57. { Now call the script... }
  58.  
  59. Script('Init');
  60.  
  61.  
  62. SO_ClrScr;
  63. Guesses := 0;
  64. Number  := Random(100)+1;
  65.  
  66. REPEAT
  67.  
  68.   { Get an entry }
  69.  
  70.   SO_pChar(Prompt);
  71.   Entry[0]:=#0;
  72.   SI_pChar(Entry,3);
  73.   SO_CRLF;
  74.   Inc(Guesses);
  75.  
  76.  
  77.   { The rest of this is exactly the same }
  78.  
  79.   IF p_Int(Entry)=Number THEN
  80.     BEGIN
  81.     SO_pCharLn(Winner);
  82.     ExitDoor(0);
  83.     END
  84.   ELSE
  85.     IF p_Int(Entry)>Number THEN
  86.       SO_pCharLn(TooHigh)
  87.     ELSE
  88.       SO_pCharLn(TooLow);
  89.  
  90. UNTIL False;
  91. END.
  92.