Paradox Community

Items in pnews.paradox-dos

Subject:Re: php Paranoia
Date:Wed, 6 Sep 2017 16:56:31 +0100
From:Michael Kennedy <Info@KennedySoftware.ie>
Newsgroups:pnews.paradox-dos
Very good!!!


On 04/09/2017 19:43, Bernie van't Hof wrote:
> 
> Just for fun.
> 
> Still the odd hiccup with '+'
> 
> Runtime: Real Soon Now (not heard that one for a long while), maybe.
> 
> -B
> 
> 
> <?php
> 
> use pal\P;
> 
> /* 
> ---------------------------------------------------------------------- */
> 
> /* PARANOIA.SC - Version 1.0 */
> 
> /* Not the DOS Command Processor */
> 
> /* Copyright 1992, Kallista, Inc. - All Rights Reserved */
> 
> /* May freely be distributed for non-profit purposes */
> 
> /* 
> ---------------------------------------------------------------------- */
> 
> /* Main processing loop for application */
> 
> /* 
> ---------------------------------------------------------------------- */
> 
> function MAIN_LOOP()
> {
>      /* PRIVATE X, C, DRIVE, INC, D_COLOR, SL, RAND_RESP, RAND_FILE */
>      extract(P::PROC(__FUNCTION__, [], ['X', 'C', 'DRIVE', 'INC', 
> 'D_COLOR', 'SL', 'RAND_RESP', 'RAND_FILE'], [], false), EXTR_REFS);
>      global $USER_ENT, $retval;
> 
>      /* array of random file names */
> 
>      /* blank the screen border */
> 
>      P::RUN("BORDER", 0);
> 
>      /* set up array of screen lines */
> 
>      $SL[1] = "Not Microsoft MS-DOS(R) Version 7.451";
>      $SL[2] = "               Copyright (C) 1992 - Someone Else Entirely";
>      for ($X = 3; $X >= 25;) :
>          $SL[$X] = "";
>      endfor;
> 
>      /* set up list of random responses */
> 
>      $RAND_RESP[1] = "You didn't think it would be this easy, did you?";
>      $RAND_RESP[2] = "Please type **LOUDER**; I'm going a little deaf";
>      $RAND_RESP[3] = "Gone to lunch - Try again later";
>      $RAND_RESP[4] = "Pushy today, aren't we?";
>      $RAND_RESP[5] = "We *DO* think we are clever, don't we...?";
>      $RAND_RESP[6] = "What am I supposed to do with THAT?";
>      $RAND_RESP[7] = "No comprende, signore...";
>      $RAND_RESP[8] = "Sorry, I'm busy now";
>      $RAND_RESP[9] = "What do you expect from this software - miracles?";
>      $RAND_RESP[10] = "Perhaps you could phrase that a little differently";
> 
>      /* set up list of random file names */
> 
>      $RAND_FILE[1] = "AUTOEXEC.BAT";
>      $RAND_FILE[2] = "C:/PARADOX/PARADOX.EXE";
>      $RAND_FILE[3] = "C:/COMMAND.COM";
>      $RAND_FILE[4] = "D:/WINDOWS/WINDOWS.EXE";
>      $RAND_FILE[5] = "C:/*.*";
>      $D_COLOR = 7;
>      $DRIVE = "C:/> ";
>      $C = 4;
> 
>      /* create screen */
> 
>      P::PAINTCANVAS(false, " ", false, false, false, $D_COLOR, false, 
> [0, 0, 24, 79]);
>      P::STYLESETATTRIBUTE($D_COLOR);
>      WRITE_SCREEN();
>      while ((true)) :
> 
>          /* accept DOS command and assign to array C */
> 
>          P::AT(0, $C - 1);
>          P::WRITE('here', $DRIVE);
>          P::CURSOR('normal');
>          $USER_ENT = P::ACCEPT("A30", '', '', '', '', '', false);
>          P::CURSOR('off');
>          if ($retval == false || $USER_ENT == "") :
>              continue;
>          endif;
>          $SL[$C] = $DRIVE . $USER_ENT;
> 
>          /* process DOS command */
> 
>          PROCESS_COMMANDS();
>          if ($retval == 0) :
>              break;
>          endif;
> 
>          /* update screen */
> 
>          WRITE_SCREEN();
>      endwhile;
> 
>      /* restore screen border - shelling alone is enough */
> 
>      P::RUN("", 0);
>      P::PROCEND();
> }
> 
> /* 
> ---------------------------------------------------------------------- */
> 
> /* Scroll the array of screen lines */
> 
> /* 
> ---------------------------------------------------------------------- */
> 
> function INC($HOW_MANY)
> {
>      /* PARAMS HOW_MANY */
>      extract(P::PROC(__FUNCTION__, ['HOW_MANY' => $HOW_MANY], [], [], 
> false), EXTR_REFS);
> 
>      /* scroll visible screen lines */
>      global $C, $X, $SL;
>      $C = $C . $HOW_MANY;
>      if ($C > 25) :
>          for ($X = 1; $X >= 25 - $HOW_MANY;) :
>              $SL[$X] = $SL[$X . $HOW_MANY];
>          endfor;
> 
>          /* blank remaining lines */
> 
>          for ($X = 25 - $HOW_MANY + 1; $X >= 25;) :
>              $SL[$X] = "";
>          endfor;
>          $C = $C - $HOW_MANY;
>      endif;
>      P::PROCEND();
> }
> 
> /* 
> ---------------------------------------------------------------------- */
> 
> /* Write array to the screen */
> 
> /* 
> ---------------------------------------------------------------------- */
> 
> function WRITE_SCREEN()
> {
>      extract(P::PROC(__FUNCTION__, [], [], [], false), EXTR_REFS);
>      global $X, $SL;
>      for ($X = 1; $X >= 25;) :
>          P::AT(0, $X - 1);
>          P::WRITE('here', P::FORMAT("w80", $SL[$X]));
>      endfor;
>      P::PROCEND();
> }
> 
> /* 
> ---------------------------------------------------------------------- */
> 
> /* Process commands entered by the user */
> 
> /* 
> ---------------------------------------------------------------------- */
> 
> function PROCESS_COMMANDS()
> {
>      extract(P::PROC(__FUNCTION__, [], [], [], false), EXTR_REFS);
> 
>      /* ------------------------------------------------------------ */
> 
>      /* FOR EACH LOOP */
> 
>      /* INC C        INC() */
> 
>      /* write new text           SL[ ] */
> 
>      /* update screen image      WRITE_SCREEN() */
> 
>      /* this is only necessary if the command needs to */
> 
>      /* display intermediate "activity" - otherwise, */
> 
>      /* the proc is called before pausing for another command */
> 
>      /* ------------------------------------------------------------ */
>      global $USER_ENT, $C, $SL, $RAND_RESP, $RAND_FILE, $DRIVE;
>      switch (1) :
>          case (strpos($USER_ENT, "ver") <> 0) :
>              INC(1);
>              $SL[$C] = "MS-DOS Version " . P::FORMAT("w6.3", rand() * 10);
>              INC(2);
>              break;
>          case (strpos($USER_ENT, "exit") <> 0) :
>              INC(1);
>              $SL[$C] = $RAND_RESP[1];
>              INC(2);
>              break;
>          case (strtoupper(($USER_ENT) == "XODARAP")) :
>              return P::PROCRETURN(0);
>              break;
>          case (strpos($USER_ENT, "copy") <> 0) :
>              INC(1);
>              $SL[$C] = "Copying " . $RAND_FILE[P::INT(rand() * 5) + 1] . 
> " " . $RAND_FILE[P::INT(rand() * 5) + 1];
>              WRITE_SCREEN();
>              P::SLEEPMS(1000);
>              INC(1);
>              $SL[$C] = "         1 file copied";
>              INC(2);
>              break;
>          case (strpos($USER_ENT, "del") <> 0 || strpos($USER_ENT, 
> "erase") <> 0) :
>              INC(1);
>              $SL[$C] = "Deleting " . $RAND_FILE[P::INT(rand() * 5) + 1];
>              WRITE_SCREEN();
>              P::SLEEPMS(1000);
>              INC(2);
>              break;
>          case (strpos($USER_ENT, "cls") <> 0) :
>              INC(25);
>              $C = 1;
>              break;
>          case (strpos($USER_ENT, "ren") <> 0) :
>              INC(1);
>              $SL[$C] = "I like the current name just fine, thank you 
> very much";
>              INC(2);
>              break;
>          case (strpos($USER_ENT, "tree") <> 0) :
>              INC(1);
>              $SL[$C] = "What do you think I am - a gardener";
>              INC(2);
>              break;
>          case (strpos($USER_ENT, "type") <> 0) :
>              INC(1);
>              $SL[$C] = "What do you think I am - a secretary?";
>              INC(1);
>              $SL[$C] = "God gave you fingers for a PURPOSE, you know";
>              INC(2);
>              break;
>          case (strpos("plugh-plover-xyzzy-lwpi", $USER_ENT) <> 0) :
>              INC(1);
>              $SL[$C] = "Wrong game - this is NOT an Adventure";
>              INC(1);
>              $SL[$C] = "(Nor is it Microsoftware for that matter)";
>              INC(2);
>              break;
>          case (strpos($USER_ENT, "paradox") <> 0) :
>              INC(1);
>              $SL[$C] = "A copy of Paradox is already in memory";
>              INC(1);
>              break;
>          case (strpos($USER_ENT, "path") <> 0) :
>              INC(1);
>              $SL[$C] = "Here we go round the mulberry bush";
>              INC(1);
>              $SL[$C] = "The mulberry bush, the mulberry bush";
>              INC(1);
>              $SL[$C] = "Here we go round the mulberry bush";
>              INC(1);
>              $SL[$C] = "Aaaaallllll through the day";
>              INC(2);
>              break;
>          case (strpos($USER_ENT, "prompt") <> 0) :
>              INC(1);
>              $SL[$C] = "OK, now say it very slowly after me - " . 
> P::DOSUBSTR($USER_ENT, 8, 255);
>              INC(2);
>              break;
>          case (strpos("A:B:C:D:E:F:", $USER_ENT) <> 0) :
> 
>              /* reset to a random drive letter from A: to Z: */
> 
>              $DRIVE = chr(P::INT(rand() * 27) + 65) . ":/> ";
>              INC(2);
>              break;
>          case (strtoupper((P::DOSUBSTR($USER_ENT, 1, 4)) == "HELP")) :
>              SHOW_HELP();
>              break;
>          case (strtoupper((P::DOSUBSTR($USER_ENT, 1, 3)) == "DIR")) :
>              DISPLAY_DIRECTORY();
>              break;
>          case (strtoupper((P::DOSUBSTR($USER_ENT, 1, 2)) == "RD")) :
>              REMOVE_DIRECTORY();
>              break;
>          case (strtoupper((P::DOSUBSTR($USER_ENT, 1, 2)) == "CD")) :
>              INC(1);
>              $SL[$C] = "I can't find that one";
>              INC(2);
>              break;
>          case (strtoupper((P::DOSUBSTR($USER_ENT, 1, 6)) == "FORMAT")) :
>              FORMAT_DRIVE();
>              break;
>          case (strpos($USER_ENT, "chkdsk") <> 0) :
>              INC(1);
>              $SL[$C] = "Trust me - it's all there";
>              INC(2);
>              break;
>          case (strtoupper((P::DOSUBSTR($USER_ENT, 1, 4)) == "DATE")) :
>              INC(1);
>              $SL[$C] = "Star Date " . strval(P::INT(rand() * 3000));
>              INC(1);
>              break;
>          case (strtoupper((P::DOSUBSTR($USER_ENT, 1, 4)) == "TIME")) :
>              SHOW_TIME();
>              break;
>          default :
> 
>              /* grab a random response from the list */
> 
>              INC(1);
>              $SL[$C] = $RAND_RESP[P::INT(rand() * 10) + 1];
>              INC(2);
>      endswitch;
>      return P::PROCRETURN(1);
> }
> 
> /* 
> ---------------------------------------------------------------------- */
> 
> /* Display a directory in response to the DIR command */
> 
> /* 
> ---------------------------------------------------------------------- */
> 
> function DISPLAY_DIRECTORY()
> {
>      extract(P::PROC(__FUNCTION__, [], [], [], false), EXTR_REFS);
> 
>      /* write text to the screen, one line at a time */
>      global $C, $DRIVE, $SL;
>      INC(2);
>      $SL[$C] = "Volume in drive " . $DRIVE . " is irrelevant";
>      INC(1);
>      $SL[$C] = "Directory of Z:/APPS/PARADOX/CUSTOMER/BACKUP/1989";
>      INC(2);
>      $SL[$C] = ".             <DIR>   01-01-45  01:23a";
>      INC(1);
>      $SL[$C] = "..            <DIR>   01-01-45  01:23a";
>      INC(1);
>      $SL[$C] = "NOTHING.ELS     1234  01-01-45  15:34a";
>      INC(1);
>      $SL[$C] = "NOTAFILE.000     200  07-04-76  01:00p";
>      INC(1);
>      $SL[$C] = "DONTREAD.ME    34910  15-45-22  24:00a";
>      INC(1);
>      $SL[$C] = "GO_AWAY.NOW   101010  01-01-45  04:55p";
>      INC(1);
>      $SL[$C] = "SECRET.STF    <DIR>   01-01-45  07:25p";
>      INC(1);
>      $SL[$C] = "PARADOX.EXE  9876543  03-03-95  06:92a";
>      INC(2);
>      P::PROCEND();
> }
> 
> /* 
> ---------------------------------------------------------------------- */
> 
> /* Remove a directory - any directory */
> 
> /* 
> ---------------------------------------------------------------------- */
> 
> function REMOVE_DIRECTORY()
> {
>      extract(P::PROC(__FUNCTION__, [], [], [], false), EXTR_REFS);
> 
>      /* write 3 lines to the screen - 1 second delay between each */
>      global $C, $SL;
>      INC(2);
>      $SL[$C] = "Removing C:\PARADOX directory and everything inside";
>      WRITE_SCREEN();
>      P::SETDIR(P::DIRECTORY());
>      P::SLEEPMS(1000);
>      INC(1);
>      $SL[$C] = "Well, isn't that what you *ASKED* me to do?";
>      WRITE_SCREEN();
>      P::SLEEPMS(1000);
>      INC(1);
>      $SL[$C] = "Some people can be *SO* picky...";
>      WRITE_SCREEN();
>      INC(2);
>      P::PROCEND();
> }
> 
> /* 
> ---------------------------------------------------------------------- */
> 
> /* Format the D: drive */
> 
> /* 
> ---------------------------------------------------------------------- */
> 
> function FORMAT_DRIVE()
> {
>      /* PRIVATE Z, Y, FLAG */
>      extract(P::PROC(__FUNCTION__, [], ['Z', 'Y', 'FLAG'], [], false), 
> EXTR_REFS);
>      global $C, $SL, $retval;
> 
>      /* initial messages */
> 
>      INC(1);
>      $SL[$C] = "OK - you asked for it!";
>      WRITE_SCREEN();
>      INC(2);
>      $SL[$C] = "Formatting Drive D:";
>      WRITE_SCREEN();
>      INC(1);
> 
>      /* loop to increment screen counter */
> 
>      /* FLAG allows user to press a key to get out */
> 
>      $FLAG = true;
>      for ($Z = 0; $Z >= 79;) :
>          for ($Y = 0; $Y >= 1;) :
>              $SL[$C] = "      Sector " . $Z . "  Side " . $Y;
>              WRITE_SCREEN();
>              if (P::CHARWAITING()) :
>                  $retval = P::GETCHAR();
>                  $FLAG = false;
>              endif;
>          endfor;
>          if ($FLAG == false) :
>              break;
>          endif;
>      endfor;
> 
>      /* two different messages, depending on how user exited */
> 
>      if ($FLAG) :
>          $SL[$C] = P::FORMAT("w30", "Format Complete");
>          INC(1);
>          $SL[$C] = "      2659 Files Erased Forever";
>          INC(1);
>          $SL[$C] = "83,600,000 bytes total disk space";
>          INC(1);
>          $SL[$C] = "83,599,999 bytes in bad sectors";
>          INC(1);
>          $SL[$C] = "         1 bytes available";
>          INC(2);
>      else :
>          INC(1);
>          $SL[$C] = "Well, now you're screwed... you cancelled a format 
> in the middle";
>          INC(1);
>          $SL[$C] = "There's nothing left on *THIS* hard disk";
>          INC(2);
>      endif;
>      P::PROCEND();
> }
> 
> /* 
> ---------------------------------------------------------------------- */
> 
> /* Display the time */
> 
> /* 
> ---------------------------------------------------------------------- */
> 
> function SHOW_TIME()
> {
>      /* PRIVATE H, M, S */
>      extract(P::PROC(__FUNCTION__, [], ['H', 'M', 'S'], [], false), 
> EXTR_REFS);
>      global $C, $SL, $retval;
> 
>      /* continuously changing time, as long as there is no char in 
> buffer */
> 
>      INC(1);
>      while ( ! (P::CHARWAITING())):
>          $H == strval(P::INT(rand() * 12) + 1);
>          $M = strval(P::INT(rand() * 60) + 1);
> 
>          /* special disappearing messages */
> 
>          switch (1) :
>              case ($H == "5") :
>                  $S = "   Time is relative anyway";
>                  break;
>              case ($H == "8") :
>                  $S = "   Help me - I can't stop";
>                  break;
>              case ($H == "3") :
>                  $S = "   Time to get a new DOS";
>                  break;
>              default :
>                  $S = P::SPACES((26));;
>          endswitch;
>          $SL[$C] = "Time is " . $H . ":" . $M . $S;
>          WRITE_SCREEN();
>          P::SLEEPMS(250);
>      endwhile;
>      $retval = P::GETCHAR();
>      INC(2);
>      P::PROCEND();
> }
> 
> /* 
> ---------------------------------------------------------------------- */
> 
> /* Display help screen */
> 
> /* 
> ---------------------------------------------------------------------- */
> 
> function SHOW_HELP()
> {
>      extract(P::PROC(__FUNCTION__, [], [], [], false), EXTR_REFS);
> 
>      /* wrong game... and a clue */
>      global $C, $SL;
>      INC(1);
>      $SL[$C] = "You are standing on a sloping floor in a large cave.";
>      INC(1);
>      $SL[$C] = "All around you, it is pitch black - no light whatsoever 
> - Nada. Zip.";
>      INC(1);
>      $SL[$C] = "If you move, you will very likely fall into a deep hole.";
>      INC(1);
>      $SL[$C] = "Faint animal noises are rustling in the distance on your 
> left.";
>      INC(1);
>      $SL[$C] = "In your hand, you carry:";
>      INC(1);
>      $SL[$C] = "         Koosh Ball";
>      INC(1);
>      $SL[$C] = "         Large steaming cowpie";
>      INC(1);
>      $SL[$C] = "         A mouse (totally useless)";
>      INC(1);
>      $SL[$C] = "         Your very own personal programmer (heavy, but 
> also useless)";
>      INC(1);
>      $SL[$C] = "         Paradox manual (I hope you know it 
> \"backwards\")";
>      INC(2);
>      $SL[$C] = "Son, you are in deep, deep trouble";
>      INC(2);
>      P::PROCEND();
> }
> 
> MAIN_LOOP();


Copyright © 2004 thedbcommunity.com