home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / PROKIT29.ZIP / PROKIT.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1989-03-01  |  6.8 KB  |  257 lines

  1.  
  2.  
  3. (*
  4.  * ProKit.PAS - demo program for the ProKit system
  5.  *
  6.  * (C) 1988 Samuel H, Smith (22-Jan-88)
  7.  *
  8.  *)
  9.  
  10. {!!!IMPORTANT!!! F5 WON'T WORK WITHOUT THE FOLLOWING LINE}
  11. {$M 6000,14000,14000}  {Stack, minheap, maxheap}
  12. {$S-,R-}
  13. {$L+,D+}
  14.  
  15.  
  16. Program ProKit_demo;
  17.  
  18. {$i prokit.inc}    {include standard 'uses' statement}
  19.  
  20.  
  21.  
  22. (* ---------------------------------------------------------------- *)
  23. procedure display_info;
  24. begin
  25.    displn(WHITE);
  26.    displn(first_name+', here is your User information:'+GREEN);
  27.    displn('   Current date   = '+system_date+' '+system_time);
  28.    displn('   Full name      = '+username);
  29.    displn('   Phone numbers  = '+user.busphone + ' / ' + user.phone);
  30.    displn('   City           = '+user.city);
  31.    displn('   Security level = '+itoa(user.level));
  32.    displn('   Baud rate      = '+baudrate);
  33.  
  34.    displn('   Last call date = '+user.date+' '+user.time+
  35.            ', Used = '+itoa(user.lastused));
  36.  
  37.    displn('   Conference     = '+conference_name+' ('+
  38.                   itoa(pcbsys.curconf)+'/'+itoa(user.curconf)+')');
  39.  
  40.    displn('   TimeOn (mins)  = '+itoa(pcbsys.time_on)+
  41.            ', Now = '+itoa(get_mins));
  42.  
  43.    displn('   Minutes left   = '+wtoa(minutes_left)+
  44.            ', Used = '+itoa(time_used)+
  45.            ', Credit = '+itoa(pcbsys.time_credit)+
  46.            ', Limit = '+itoa(pcbsys.time_limit)+
  47.            ', Added = '+itoa(pcbsys.time_added));
  48.  
  49.    displn('   Event schedule = '+itoa(minutes_before_event)+' minutes');
  50.  
  51.    displn('   Downloads      = '+itoa(user.downloads)+
  52.             ', Total = '+dtok(user.downtotal)+
  53.             'k, Today = '+dtok(user.downbytes)+
  54.             'k, Allowed = '+wtoa(download_k_allowed)+'k');
  55.  
  56.    displn('   Uploads        = '+itoa(user.uploads)+
  57.             ', Total = '+dtok(user.uptotal)+
  58.             'k, Earned = '+wtoa(user.earned_k)+
  59.             'k');
  60.  
  61.    disp  ('   Expert mode    = ');
  62.    if expert then displn('ON') else displn('OFF');
  63.  
  64.    disp  ('   Graphics       = ');
  65.    if graphics then displn('ON') else displn('OFF');
  66.  
  67.    force_enter;
  68. end;
  69.  
  70.  
  71.  
  72. (* ---------------------------------------------------------------- *)
  73. procedure take_chance;
  74. var
  75.    thinking_of:  anystring;
  76.  
  77. begin
  78.    {think of a number - based on the time of day}
  79.    thinking_of := itoa(random(9));
  80.  
  81.    {check for a stacked response- prompt if not}
  82.    if length(cmdline) = 0 then
  83.    begin
  84.       disp(CYAN);
  85.       displn('I''m thinking of a number from 0 to 9.   If you guess the');
  86.       displn('number, you will be given an extra 10 minutes online.  If you');
  87.       displn('get it wrong, your time will be reduced by 2 minutes.');
  88.       newline;
  89.       disp(YELLOW);
  90.       disp('What''s your guess? ');
  91.       get_cmdline;
  92.       newline;
  93.    end;
  94.  
  95.    {get the input and process it}
  96.    get_nextpar;
  97.    if par = thinking_of then
  98.    begin
  99.       disp(GREEN);
  100.       displn('That''s right!  You get a 10 minute bonus!');
  101.       adjust_time_allowed(10 * 60);
  102.    end
  103.    else
  104.  
  105.    begin
  106.       disp(BLUE);
  107.       displn('Wrong!  You lose 2 minutes!  I was thinking of '+thinking_of+'.');
  108.       adjust_time_allowed(-120);
  109.    end;
  110.  
  111. end;
  112.  
  113.  
  114.  
  115. (* ---------------------------------------------------------------- *)
  116. procedure test_pattern;
  117. var
  118.    i:     integer;
  119.    start: longint;
  120.  
  121. begin
  122.    flush_com;
  123.    start := lget_ms;
  124.    for i := 1 to 20 do
  125.       displn('(1234567890-abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789)');
  126.    flush_com;
  127.    displn('Speed = '+ftoa(1580000.0 / int(lget_ms - start),0,1)+' char/sec');
  128. end;
  129.  
  130.  
  131. (* ---------------------------------------------------------------- *)
  132. procedure ansi_demo;
  133. var
  134.    x,y: integer;
  135.  
  136. begin
  137.    if not graphics then
  138.    begin
  139.       displn('You must be in GRAPHICS mode to run this demo.');
  140.       displn('Use the (M) command from the main board.');
  141.       exit;
  142.    end;
  143.  
  144.    disp(GREEN);
  145.    clear_screen;
  146.  
  147.    for y := 2 to 21 do
  148.    begin
  149.       position(1,y);  dispc('│');
  150.       position(79,y); dispc('│');
  151.    end;
  152.  
  153.    position(2,1);
  154.    for x := 2 to 78 do
  155.       dispc('─');
  156.  
  157.    position(2,22);
  158.    for x := 2 to 78 do
  159.       dispc('─');
  160.  
  161.    position(1,1);   dispc('┌');
  162.    position(79,1);  dispc('┐');
  163.    position(1,22);  dispc('└');
  164.    position(79,22); dispc('┘');
  165.  
  166.    disp(RED);
  167.    position(30,10);  disp(' P r o   K i t ');
  168.    disp(YELLOW);
  169.    position(12,12);  disp(' This is only a SMALL sample of what ProKit can do! ');
  170.    disp(WHITE);
  171.    position(30,18);  disp('Press (Enter): ');
  172.    get_cmdline;
  173.  
  174.    cmdline := '';
  175.    clear_screen;
  176. end;
  177.  
  178.  
  179. (* ---------------------------------------------------------------- *)
  180. procedure menu;
  181. begin
  182.  
  183.    newline;
  184.    displn(GRAY);
  185.    displn('ProKit DEMO - Based on ProKit '+version);
  186.    newline;
  187.    display_file('prokit.m');  {uses prokit.mg in graphics mode}
  188.    force_enter;
  189.    newline;
  190.  
  191.    {main command loop}
  192.    repeat
  193.  
  194.       {prompt for input only if there is not a stacked command pending}
  195.       if length(cmdline) = 0 then
  196.       begin
  197.          displn(WHITE);
  198.          displn('Main menu:');
  199.          displn(RED    +' (I)  Display system information');
  200.          displn(GREEN  +' (C)  Take a chance for more time online');
  201.          displn(MAGENTA+' (T)  Display a test pattern, calculate speed');
  202.          displn(CYAN   +' (A)  Ansi graphics demo');
  203.          displn(RED    +' (G)  Goodbye, hang up');
  204.          displn(BLUE   +' (Q)  Return to PCBoard');
  205.          newline;
  206.  
  207.          repeat
  208.             display_time_left;
  209.             disp(YELLOW+'Command? ');
  210.             get_cmdline;              {get cmdline, map to upper case}
  211.             newline;
  212.          until dump_user or (length(cmdline) > 0);
  213.       end;
  214.  
  215.       if dump_user then exit;   {leave menu if carrier lost}
  216.       get_nextpar;              {scan next parameter from cmdline into par}
  217.  
  218.       {process commands}
  219.       case par[1] of
  220.          'I':   display_info;
  221.          'C':   take_chance;
  222.          'T':   test_pattern;
  223.          'A':   ansi_demo;
  224.  
  225.          'G':   begin
  226.                    dump_user := true;
  227.                    option := o_logoff;
  228.                 end;
  229.  
  230.          'Q':   exit;
  231.          else   displn(MAGENTA+'('+par+') is not allowed!  Try again:');
  232.       end;
  233.  
  234.    until dump_user;
  235.  
  236. end;
  237.  
  238.  
  239. (* ---------------------------------------------------------------- *)
  240.  
  241. begin  {main block}
  242.    init;     {must be first - opens com port, loads setup and user data}
  243.  
  244.    load_cnames_file;       {make conference information available}
  245.  
  246.    load_color_constants('PROCOLOR');
  247.                            {use 'PROCOLOR' to redefine colors; defaults used
  248.                             if this file is missing}
  249.  
  250.    progname := 'Demo';    {program name on status line}
  251.    display_info;
  252.    menu;                  {insert your code here}
  253.  
  254.    uninit;   {must be last - closes com port and updates database}
  255. end.
  256.  
  257.