home *** CD-ROM | disk | FTP | other *** search
/ ftp.wwiv.com / ftp.wwiv.com.zip / ftp.wwiv.com / pub / DOOR / CONC_003.ZIP / TUTOR.ARJ / TUTOR5.PAS < prev    next >
Pascal/Delphi Source File  |  1996-07-15  |  3KB  |  112 lines

  1.  
  2. {$A+,B-,I-,Q-,R-,S-}
  3.  
  4. {$F+} { Force Far calls }
  5. {$X+} { Extended Syntax }
  6.  
  7. USES
  8.  
  9.   DoorKit, IO, IO_FX, Scripts, Types, xStrings,
  10.  
  11.   { Color systems }
  12.  
  13.   _ANSI,               { . . . . . . . . . . . . . . . . . . . ANSI support }
  14.   _ATCodes,            { . . . . . . . . . .  PCBoard and WildCat at-colors }
  15.   _AVATAR,             { . . . . . . . . . . . . . . . . . . AVATAR support }
  16.   _HexPipe,            { . . . . . . . . . . . . . . . . . . HexPipe system }
  17.   _LORDCLR,            { . . . . . . LORD [Legend of the Red Dragon] colors }
  18.   _RACOLOR,            { . . . . . . . . . . . . . . RemoteAccess ^K colors }
  19.  
  20.  
  21.   { Extra features }
  22.  
  23.   _Chat,               { . . . . . . . . . . . . . . . . . . Cool chat-mode }
  24.   _Control,            { . . . . . . . . . . . . . . . . . .  Control codes }
  25.   _Errata,             { . . . . . . . . . . . . .  Run-time error handling }
  26.   _IO,                 { . . . . . . Various I/O script commands (i.e. CLS) }
  27.   _Macros,             { . . . . . . . . . . . . . . . . . . .  Text Macros }
  28.   _Params,             { . . . . .  Sysop-definable command-line parameters }
  29.   _Release,            { . . . . . . . . . . . . . . .  Time-slice releaser }
  30.   _SO,                 { . . . .  Allows use of WriteLn via SO virtual file }
  31.   _Status,             { . . . . . . . . . . . Sysop-definable status lines }
  32.  
  33.  
  34.   { I/O drivers }
  35.  
  36.   _FOSSIL,             { . . . . . . . . . . . . . . . . . . FOSSIL support }
  37.   _CRT;                { . . . . . . . . Local I/O using Borland's CRT unit }
  38.  
  39.  
  40. CONST
  41.   TooBig  : STRING[80] = 'Too big, bird brain.';
  42.   TooLow  : STRING[80] = 'Too low, dog breath.';
  43.   Winner  : STRING[80] = 'Huh? Must have been a fluke.~p';
  44.   Results : STRING[80] = 'It took ya {tries} times.';
  45.                                      {^^^^^}
  46.                                      { Look at this carefully. }
  47.  
  48.  
  49. VAR
  50.   Entry  : STRING[3];
  51.   Number : Byte;
  52.   Tries  : Byte;
  53.  
  54.  
  55. BEGIN
  56.  
  57. { Setup door }
  58.  
  59. ProgName  := 'Guess It';
  60. Version   := '1.0';
  61. Copyright := '(c) ''81 Billy Bob Gates: I shall crush you.';
  62. Script('Init');
  63.  
  64. { Expand the script language with a few variables }
  65.  
  66. RegisterString('TooBig',  @TooBig,  SizeOf(TooBig)-1);
  67. RegisterString('TooLow',  @TooLow,  SizeOf(TooLow)-1);
  68. RegisterString('Winner',  @Winner,  SizeOf(Winner)-1);
  69. RegisterString('Results', @Results, SizeOf(Results)-1);
  70.           {      │          │        │
  71.                  │          │        └ Maximum length of the string.
  72.                  │          └───────── Address of the string.
  73.                  └──────────────────── Name of the script variable (case
  74.                                        does not matter.  The name does not
  75.                                        have to be the same as the name of
  76.                                        the associated variable in your
  77.                                        program. }
  78.  
  79.  
  80. RegisterByte ('Number', @Number);
  81. RegisterByte ('Tries',  @Tries);
  82.  
  83.  
  84. SO_ClrScr;
  85. Randomize;
  86. Number:=Random(100)+1;
  87.  
  88.  
  89. REPEAT
  90.  
  91.   Write(SO,'Enter your guess: ');
  92.   Entry:='';
  93.   SI_String(Entry,3,True);
  94.  
  95.   IF StrToInt(Entry)=Number THEN
  96.     BEGIN
  97.     WriteLn(SO,'{Winner}');
  98.     Halt;
  99.     END
  100.   ELSE
  101.     BEGIN
  102.     Inc(Tries);
  103.     IF StrToInt(Entry)>Number THEN
  104.       WriteLn(SO,'{TooBig}')
  105.     ELSE
  106.       WriteLn(SO,'{TooLow}');
  107.     END;
  108.  
  109. UNTIL False;
  110.  
  111. END.
  112.