home *** CD-ROM | disk | FTP | other *** search
/ Mega Top 1 / os2_top1.zip / os2_top1 / APPS / PROG / C_PLUS / CNVLIB2 / OS2DEMO.CMD < prev    next >
Encoding:
Text File  |  1994-05-27  |  40.3 KB  |  1,115 lines

  1. @ECHO OFF
  2. REM *************************************************************
  3. REM *** OS2DEMO.CMD - Unattended demo script for showing off  ***
  4. REM *** ver.3         the powers of OS/2 running Windows, DOS ***
  5. REM ***               and PM programs. Thanks to Bob Weeks    ***
  6. REM ***               for the idea.                           ***
  7. REM *************************************************************
  8.  
  9. ::***************************************************************************
  10. ::***                   START OF CONFIGURATION SECTION
  11. ::***
  12. ::*** 1) Set the following GRAPHIC_PROGRAM_SPEC to specify a DOS program
  13. ::***    that runs at hi-resolution and looks good in a DOS box.
  14. ::***    If you can't think of something then just use COMMAND.COM.
  15.   SET GRAPHIC_PROGRAM_SPEC=E:\Personal\AcidWarp.exe
  16. ::***
  17. ::*** 2) During the demo, a coach window always shows at the bottom of
  18. ::***    the screen.  In the following lines, specify the the size of
  19. ::***    the font for that window (use a valid font size) and change
  20. ::***    the number of lines showing if you wish.
  21.  SET COACH_LINECOUNT=2
  22.  REM SETTING FOR VGA
  23.  SET COACH_FONTSIZE=18x8
  24.  REM SETTING FOR 8514
  25.  REM SET COACH_FONTSIZE=30x12
  26. ::***
  27. ::*** 3) The fancier Windows parts of this demo must communicate with
  28. ::***    multiple windows session using Nombas' CEnvi for Windows.
  29. ::***    If you don't already have CEnvi for Windows then you can
  30. ::***    probably download the software from wherever you got CEnvi
  31. ::***    for OS/2. If you register CEnvi for OS/2 then you also get
  32. ::***    CEnvi for Windows.  Contact Nombas is you need more help.
  33. ::***    Using CEnvi for Windows, you next need to create the
  34. ::***    ServeOS2.exe program.  To do this start windows, run
  35. ::***    CEnvi.exe, and at the CEnvi prompt enter:
  36. ::***           /BIND=ServeOS2 ServeOS2
  37. ::***    This will create the ServeOS2.exe file.  In the following
  38. ::***    line, set the SERVEOS2_SPEC variable to the location of
  39. ::***    the ServeOS2.exe executable.
  40.  SET SERVEOS2_SPEC=ServeOS2.exe
  41. ::***
  42. ::*** 4) This demo does some pretty fancy stuff, with complicated
  43. ::***    interactions between parts, and so it is not unreasonable
  44. ::***    to expect it to get "stuck" now and then.  (On the latest
  45. ::***    test on my system, which was also running a BBS at the same
  46. ::***    time as this demo, the demo ran for about 200 repetitions
  47. ::***    before it got stuck when a Windows applications had a GPF
  48. ::***    in the wrong place.  If you want the computer to reboot
  49. ::***    if anything goes wrong with the demo (for example, if the
  50. ::***    demo is to run unattended in a store, and the computer runs
  51. ::***    OS2DEMO.CMD when it reboots) then uncomment the following
  52. ::***    line.  DEMO_HUNG_REBOOT_TIMEOUT, if it exists in the
  53. ::***    environment block, specifies how many minutes the computer
  54. ::***    must appear to be hung (the focus window stops changing) before
  55. ::***    the computer reboots itself.  Warning: the computer doesn't
  56. ::***    do a controlled shutdown, but simplu mimics ctrl-alt-del.  This
  57. ::***    is very unlikely to cause any problems after minutes of the
  58. ::***    computer doing nothing.
  59.  REM SET DEMO_HUNG_REBOOT_TIMEOUT=3
  60. ::***
  61. ::*** 5) If you are experiencing periodic hangs of this DEMO, then
  62. ::***    it is useful to have some idea later about where the demo
  63. ::***    stopped running.  If you uncomment the following line and
  64. ::***    set it to specify a log file, then some information will be
  65. ::***    stored in the file to examine for the state of OS2DEMO.CMD
  66. ::***    to know where it hung.
  67.  REM SET OS2DEMO_LOGFILE=C:\OS2DEMO.LOG
  68. ::***
  69. ::*** 6) Set a good font size for your display for showing multiple DOS
  70. ::***    DOS section tiled one upon another
  71.  REM SETTING FOR VGA
  72.  SET DOS_MEMCONFIG_FONTSIZE=10x6
  73.  REM SETTING FOR 8514
  74.  REM SET DOS_MEMCONFIG_FONTSIZE=14x8
  75. ::***
  76. ::*** 7) Set two different font sizes for two DOS sessions that will be
  77. ::***    executing the same batch file at the same time.
  78.  REM SETTINGS FOR VGA
  79.  SET ONE_DOS_FONTSIZE=14x6
  80.  SET ANOTHER_DOS_FONTSIZE=10x6
  81.  REM SETTINGS FOR 8514
  82.  REM SET ONE_DOS_FONTSIZE=16x8
  83.  REM SET ANOTHER_DOS_FONTSIZE=8x8
  84. ::***
  85. ::*** 8) This is not necessary, but to make the Windows section of this
  86. ::***    demo look its best, you should start Windows and configure the
  87. ::***    CLOCK so that it is analog with seconds showing, the CALCULATOR
  88. ::***    so that is is in standard and not scientific mode, and the
  89. ::***    NOTEPAD so that the text is readable
  90. ::***
  91. ::*** 9) Register CEnvi.  Otherwise, this demo will occasionally get
  92. ::***    halted by a "PLEASE REGISTER, I NEED THE MONEY" message, which
  93. ::***    does not make for an impressive demo.
  94. ::***
  95. ::*** 10) Put a "REM" in front of the following line to avoid jumping to
  96. ::***    the "please configure" message
  97.  REM GOTO CONFIGURED
  98. ::***
  99. ::***                    END OF CONFIGURATION SECTION
  100. ::***************************************************************************
  101.  
  102. ECHO OS2DEMO: This is a very comprehensive stand-alone demo of
  103. ECHO          OS2. Before using this demo you should edit this
  104. ECHO          OS2Demo.cmd file and check the settings in the
  105. ECHO          Configuration section. After OS2Demo.cmd has been
  106. ECHO          edited then run it again to amaze your family and
  107. ECHO          friends.
  108. PAUSE
  109. EXIT
  110.  
  111.  
  112. :CONFIGURED
  113. IF "%1" == "CALLING_MYSELF" GOTO CALLING_MYSELF
  114.  
  115. REM *** KILL ANY SESSIONS WE MAY HAVE LEFT RUNNING
  116. call kill "OS/2 Demo"
  117. call kill "One DOS Session"
  118. call kill "Another DOS Session"
  119. call kill "OS2DEMO.BAT"
  120. call kill "Session:ServeOS2"
  121. call kill "OS2Demo Rebooter"
  122.  
  123. CALL SESSION.CMD /Title "OS/2 Demo" /F /WIN /MAX /FONT %COACH_FONTSIZE% %COMSPEC% /C %0 CALLING_MYSELF
  124.  
  125. EXIT
  126.  
  127. :CALLING_MYSELF
  128. REM **********************************************************
  129. REM *** This section is called by the first pass, but will ***
  130. REM *** have a better title and bigger font size, and put  ***
  131. REM *** this screen in lower right corner of the screen    ***
  132. REM **********************************************************
  133.  
  134. REM Make this window take up few lines only in
  135. mode 80,%COACH_LINECOUNT%
  136. call winset "OS/2 Demo" BIGGEST
  137. call winset "OS/2 Demo" BIGGEST
  138.  
  139. REM CEnvi script to move this window to the lower right corner of the screen
  140. CEnvi #include '%0,cmd,,GOTO END_LOWER_RIGHT,:END_LOWER_RIGHT'
  141. GOTO END_LOWER_RIGHT
  142.  
  143.    // Move this window to lower right corner of screen
  144.    #include "WinTools.lib"
  145.  
  146.    suspend(1000);
  147.    GetScreenSize(ScreenWidth,ScreenHeight);
  148.    GetSize(Info().WinHandle,MyWidth,MyHeight);
  149.    SetPosition(Info().WinHandle,max(-4,ScreenWidth - MyWidth),0);
  150.    suspend(2000);
  151.  
  152. :END_LOWER_RIGHT
  153.  
  154. REM ****************************************************************
  155. REM *** HUNG_REBOOT: If the DEMO_HUNG_REBOOT_TIMEOUT environment ***
  156. REM *** variable was specified then start a hidden background    ***
  157. REM *** session that will reboot the computer if the window      ***
  158. REM *** focus stops changing                                     ***
  159. REM ****************************************************************
  160.  
  161. IF ""=="%DEMO_HUNG_REBOOT_TIMEOUT%" GOTO END_HUNG_REBOOT
  162. CALL SESSION.CMD /Title "OS2Demo Rebooter" /B /FS /HID CEnvi.exe #include '%0,CMD,,GOTO END_HUNG_REBOOT,:END_HUNG_REBOOT' RebootIfHung(%DEMO_HUNG_REBOOT_TIMEOUT%)
  163. GOTO END_HUNG_REBOOT
  164.  
  165. #define SUSPEND_BETWEEN_CHECKS   10 // approx. seconds between checks
  166.  
  167. RebootIfHung(MinutesToTimeout)
  168. {
  169.    MillisecondSuspend = 1000 * SUSPEND_BETWEEN_CHECKS;
  170.    SecondsToTimeout = 60 * MinutesToTimeout;
  171.    PreviousFocusWindow = GetFocus();
  172.    TimeOfLastFocusChange = time();
  173.  
  174.    for ( ; ; ) {
  175.       suspend(MillisecondSuspend);
  176.       if ( (FocusWindow = GetFocus()) != PreviousFocusWindow ) {
  177.          // focus window has changed. Good!
  178.          TimeOfLastFocusChange = time();
  179.          PreviousFocusWindow = FocusWindow;
  180.       } else {
  181.          // focus window has not changed
  182.          if ( SecondsToTimeout < difftime(time(),TimeOfLastFocusChange) ) {
  183.             RebootSystemEEEEK();
  184.          }
  185.       }
  186.    }
  187. }
  188.  
  189. GetFocus()
  190. {
  191.    #define HWND_DESKTOP 1
  192.    #define ORD_WIN32QUERYFOCUS   817
  193.    return DynamicLink("PMWIN",ORD_WIN32QUERYFOCUS,BIT32,CDECL,HWND_DESKTOP);
  194. }
  195.  
  196. RebootSystemEEEEK()
  197. {
  198.    #define ORD_DOS32OPEN   273
  199.    #define FILE_NORMAL     0x0000
  200.    #define FILE_OPEN       0x0001
  201.    #define OPEN_SHARE_DENYNONE      0x0040
  202.    #define OPEN_ACCESS_READWRITE    0x0002
  203.    if ( !DynamicLink("doscalls",ORD_DOS32OPEN,BIT32,CDECL,
  204.                      "\\DEV\\DOS$",FileHandle,ActionTaken,0,
  205.                      FILE_NORMAL,FILE_OPEN,
  206.                      OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,0) ) {
  207.  
  208.       #define ORD_DOS32DEVIOCTL     284
  209.       #define CATEGORY_DOSSYS       0xD5
  210.       #define FUNCTION_REBOOT       0xAB
  211.       DynamicLink("doscalls",ORD_DOS32DEVIOCTL,BIT32,CDECL,
  212.                   FileHandle,CATEGORY_DOSSYS,FUNCTION_REBOOT,
  213.                   NULL,0,NULL,NULL,0,NULL);
  214.  
  215.       #define ORD_DOS32CLOSE  257
  216.       DynamicLink("doscalls",ORD_DOS32CLOSE,BIT32,CDECL,FileHandle);
  217.    }
  218. }
  219.  
  220. :END_HUNG_REBOOT
  221.  
  222. REM *************************************************************
  223. REM *** STAY ON TOP: will now run code to stay on top, and    ***
  224. REM *** spawn a new CMD.EXE to continue with this batch file  ***
  225. REM *************************************************************
  226.  
  227. SET OS2DEMO_FILESPEC=%0
  228. SET DELDIR=
  229. CEnvi.exe #include '%0,cmd,,GOTO END_STAY_ON_TOP,:END_STAY_ON_TOP'
  230. GOTO END_STAY_ON_TOP
  231.  
  232.    #define ON_TOP_DELAY 1800
  233.    sprintf(SpawnCommand,"%s /C CEnvi #include \'%s,CMD,,AUTOMATED_SCRIPT_AT_LAST\' RunForever()",
  234.            defined(OS2_SHELL) ? OS2_SHELL : "CMD.EXE",OS2DEMO_FILESPEC);
  235.    CmdChildID = spawn(P_NOWAIT,SpawnCommand);
  236.  
  237.    while ( ValidProcessID(CmdChildID) ) {
  238.       PutMyselfOnTop();
  239.       suspend(ON_TOP_DELAY);
  240.    }
  241.  
  242.    ValidProcessID(id)   // return TRUE if this ID is OK
  243.    {
  244.       if ( pList = ProcessList(False) ) {
  245.          for ( li = GetArraySpan(pList); 0 <= li; li-- ) {
  246.             if ( id == pList[li].id )
  247.                return(True);
  248.          }
  249.       }
  250.       return False;
  251.    }
  252.  
  253.    SetWindowPos(pHandle,pBehindHandle,pColumn,pRow,pWidth,pHeight,pFlags)
  254.    {
  255.       #define ORD_WIN32SETWINDOWPOS 875
  256.       PMDynamicLink("PMWIN",ORD_WIN32SETWINDOWPOS,BIT32,CDECL,
  257.                     pHandle,pBehindHandle,pColumn,pRow,pWidth,pHeight,pFlags);
  258.    }
  259.  
  260.    PutMyselfOnTop()
  261.    {
  262.       #define HWND_TOP     3
  263.       #define SWP_ZORDER   4
  264.       SetWindowPos(Info().WinHandle,HWND_TOP,0,0,0,0,SWP_ZORDER);
  265.    }
  266.  
  267. :END_STAY_ON_TOP
  268. CEnvi printf('\a\a\a\a\a\a\a\a\a\a'); getch();
  269. EXIT
  270.  
  271.  
  272. AUTOMATED_SCRIPT_AT_LAST
  273. //***********************************************************************
  274. //***********************************************************************
  275. //************************                       ************************
  276. //************************  FINALLY! THE SCRIPT  ************************
  277. //************************                       ************************
  278. //***********************************************************************
  279. //***********************************************************************
  280.  
  281. #include <WinTools.lib>
  282. #include <TextBoss.lib>
  283. #include <Win_Boss.lib>
  284. #include <KeyPush.lib>
  285.  
  286. /*************** MANY DOS SESSIONS ***************/
  287. ManyDosSessions()
  288. {
  289.    LogHere("ManyDosSession()");
  290.    SetWindowTitle(Info().WinHandle,"OS/2 Demo: MULTIPLE SIMULTANEOUS DOS SESSIONS");
  291.  
  292.    EraseScreen();
  293.    printf("With OS/2, you can run as many DOS sessions in as many different ways\n"
  294.           "as you want.  ALL AT THE SAME TIME!!!");
  295.  
  296.    // Make a batch file for the DOS commands, and the GO file
  297.    lFp = fopen("C:\\OS2DEMO.BAT","wt");
  298.    fprintf(lFp,":AGAIN\n");
  299.    fprintf(lFp,"DIR /On\n");
  300.    fprintf(lFp,"CLS\n");
  301.    fprintf(lFp,"TYPE C:\\AUTOEXEC.BAT\n");
  302.    fprintf(lFp,"C:\n");
  303.    fprintf(lFp,"CD OS2\n");
  304.    fprintf(lFp,"DIR *.EXE /W\n");
  305.    fprintf(lFp,"CD \\\n");
  306.    fprintf(lFp,"SET\n");
  307.    fprintf(lFp,"ver\n");
  308.    fprintf(lFp,"@IF EXIST C:\\OS2DEMO.GO GOTO AGAIN\n");
  309.    fprintf(lFp,"EXIT\n");
  310.    fclose(lFp);
  311.    fclose(fopen("C:\\OS2DEMO.GO","w"));
  312.  
  313.    // start two DOS sessions
  314.    RestoreDefaultDOSSettings();
  315.    QCall("session_cmd", "/TITLE", "Another DOS session", "/F", "/WIN", "/DOS",
  316.          "/FONT", ANOTHER_DOS_FONTSIZE,
  317.          "/SET", "IDLE_SECONDS=0", "/SET", "IDLE_SENSITIVITY=60" );
  318.    AnotherHwnd = GetWindowHandle("Another DOS session");
  319.    QCall("session_cmd", "/TITLE", "One DOS session", "/F", "/WIN", "/DOS",
  320.          "/FONT", ONE_DOS_FONTSIZE,
  321.          "/SET", "IDLE_SECONDS=0", "/SET", "IDLE_SENSITIVITY=70" );
  322.    OneHwnd = GetWindowHandle("One DOS session");
  323.  
  324.    // Start DOS windows 25-line mode
  325.    PasteToTextWindow("One DOS session","mode 80,25\rcls\r");
  326.    PasteToTextWindow("Another DOS session","mode 80,25\rcls\r");
  327.    WaitSeconds(3);
  328.  
  329.    // adjust one DOS window in upper-right edge of screen
  330.    ShowWindow(OneHwnd,SW_SHOWMAXNOACTIVE);
  331.    GetSize(OneHwnd,width,height);
  332.    SetPosition(OneHwnd,ScreenWidth-width,ScreenHeight-height);
  333.  
  334.    // adjust other DOS window so it's near left and just above this one
  335.    SetPosition(AnotherHwnd,4,MyHeight - 2);
  336.  
  337.    // Tell each DOS session to run the batch file
  338.    PasteToTextWindow("One DOS session","C:\\OS2DEMO.BAT\r");
  339.    PasteToTextWindow("Another DOS session","C:\\OS2DEMO.BAT\r");
  340.  
  341.    WaitSeconds(1);
  342.    SetWindowTitle(OneHwnd,"One DOS Session");
  343.    SetWindowTitle(AnotherHwnd,"Another DOS Session");
  344.  
  345.  
  346.    WaitSeconds(20);
  347.  
  348.    sprintf(lPosition,"%d,%d",ScreenWidth/10,ScreenHeight/4);
  349.    RestoreDefaultDOSSettings()
  350.    QCall("session_cmd", "/TITLE", "Hi-res graphics session", "/F", "/POS", lPosition, "/WIN", "/DOS",
  351.          "/SET", "IDLE_SECONDS=0", "/SET", "IDLE_SENSITIVITY=100",
  352.          "/SET", "HW_TIMER=1", "/SET", "VIDEO_8514A_XGA_IOTRAP=1",
  353.          GRAPHIC_PROGRAM_SPEC);
  354.    printf("  Including hi-res graphics...");
  355.  
  356.    WaitSeconds(20);
  357.  
  358.    EraseScreen();
  359.    printf("The DOS sessions may be windowed, as you see here\n"
  360.           "or they may be full screen...");
  361.    WaitSeconds(1);
  362.    QCall( "domenu_cmd", "Hi-res graphics session", "Full-screen" );
  363.  
  364.    // also tell the other DOS windows to go away
  365.    // tell both DOS sessions to exit
  366.    WaitSeconds(3);
  367.    printf("  or windowed again.");
  368.    QCall( "switch_cmd", "OS/2 Demo" );
  369.    QCall( "domenu_cmd", "Hi-res graphics session", "Windowed" );
  370.    WaitSeconds(5);
  371.  
  372.    QCall( "kill_cmd", "Hi-res graphics session");
  373.    EraseScreen();
  374.    printf("Give these DOS sessions a moment to exit...");
  375.    remove("C:\\OS2DEMO.GO");
  376.  
  377.    // Wait up to 20 seconds for these sessions to exit
  378.    StartTime = time();
  379.    while ( (IsWindow(OneHwnd) || IsWindow(AnotherHwnd))
  380.         && difftime(time(),StartTime) < 20 )
  381.       suspend(100);
  382.    // kill the windows just in case they're not already dead
  383.    QCall( "kill_cmd", "One DOS Session" );
  384.    QCall( "kill_cmd", "Another DOS Session" );
  385.    remove("C:\\OS2DEMO.BAT");
  386. }
  387.  
  388. /*************** MANY WINDOWS SESSIONS ***************/
  389.  
  390. NombasAdvertisement =
  391.    "MEMO\rTo: All personnel\r\r"
  392.    "I just saw an amazing computer demo. The automated demo was controlled "
  393.    "by a program called CEnvi, from Nombas, for OS/2, DOS, and Windows.\r\r"
  394.    "We need CEnvi NOW! Contact:\r"
  395.    "   Nombas\r"
  396.    "   PO BOX 875\r"
  397.    "   MEDFORD MA 02155-0007\r\r"
  398.    "CEnvi interprets the simple yet powerful Cmm language for our OS/2, DOS, "
  399.    "and Windows systems. CEnvi also creates hundreds of the simplest "
  400.    "programs you ever saw.  Our problems are solved by CEnvi: The Mother of "
  401.    "All Utilities!\r\r"
  402.    "I just can't say enough about Nombas' CEnvi. It's a scripting language, "
  403.    "a programmer's toolbox, a glue to connect all applications and operating "
  404.    "systems, and CEnvi (\'C\' Envy) is a catchy name.\r\r"
  405.    "IS and PC experts don't have to waste time anymore "
  406.    "customizing all of our computer systems, as now they can write simple "
  407.    "CEnvi scripts for every system, and customize them for each system.\r\r"
  408.    "Call Nombas: (617)391-6595 and get us a good deal on CEnvi for all "
  409.    "our systems all over the world.\r\r"
  410.    "Also, tell our application programmers to stop fiddling with their "
  411.    "internal macro language and use Nombas Cmm-interpreter.\r\r"
  412.    "Somebody get me a cheesburger!";
  413.  
  414.  
  415. ManyWindowsSessions()
  416. {
  417.    LogHere("ManyWindowsSessions()");
  418.    // start two ServeOS2 sessions to wait for our calls
  419.    RestoreDefaultDOSSettings();
  420.  
  421.    SetWindowTitle(Info().WinHandle,"OS/2 Demo: MULTIPLE SIMULTANEOUS WINDOWS SESSIONS");
  422.    EraseScreen();
  423.    printf("OS/2 supports your Windows applications.");
  424.    QCall("session_cmd", "/W", "/WIN", "/SEP",
  425.          "/SET", "IDLE_SECONDS=2", "/SET", "IDLE_SENSITIVITY=75",
  426.          "/SET", "DPMI_MEMORY_LIMIT=7",
  427.          SERVEOS2_SPEC, "/NAME", "Right", "/DELAY", "500" );
  428.    printf("\b,\nand OS/2 supports more Windows applications");
  429.    while ( !WinBossSelect("Right") ) suspend(800);
  430.    printf(", better,");
  431.  
  432.    // get the process ID of this session, so we can kill it later
  433.    lSwitchList = WinQuerySwitchList(Info().hab);
  434.    lSwitchCount = 1 + GetArraySpan(lSwitchList);
  435.    RightProcessID = 0;
  436.    for ( li = 0; li < lSwitchCount; li++ ) {
  437.       if ( 0 == WinQuerySwitchEntry(lSwitchList[li],lSwEntry)
  438.         && lSwEntry.title  &&  !stricmp(lSwEntry.title,"Session:ServeOS2.exe") ) {
  439.          RightProcessID = lSwEntry.process;
  440.          break;
  441.       }
  442.    }
  443.  
  444.    printf("\nthan ANY other operating system...");
  445.    QCall("session_cmd", "/W", "/WIN", "/SEP", "/ENH",
  446.          "/SET", "DPMI_MEMORY_LIMIT=4",
  447.          "/SET", "IDLE_SECONDS=2", "/SET", "IDLE_SENSITIVITY=75",
  448.          SERVEOS2_SPEC, "/NAME", "Left", "/DELAY", "500" );
  449.    printf("\b\b\b - bar none!");
  450.    while ( !WinBossSelect("Left") ) suspend(800);
  451.  
  452.    EraseScreen();
  453.    printf("With OS/2, you can run MULTIPLE copies of Windows 3.x sessions.");
  454.  
  455.    // start clock in left session at top, in middle
  456.    LClockWidth = LClockHeight = ScreenHeight / 4;
  457.    LClockLeft = (ScreenWidth/2-LClockWidth)/2;
  458.    LClockTop = ScreenHeight / 14;
  459.    LClockRight = LClockLeft + LClockWidth;
  460.    LClockBottom = LClockTop + LClockHeight;
  461.    WinBossSelect("Left");
  462.    if ( !WinFunction("spawn",LeftClockHandle,P_NOWAIT,"Clock.exe") )
  463.       FatalError("Unable to start clock.");
  464.    WinVoidFunction("SetWindowRect",LeftClockHandle,LClockLeft,LClockTop,LClockRight,LClockBottom);
  465.  
  466.    // start bigger clock on right
  467.    RClockWidth = RClockHeight = ScreenHeight / 3;
  468.    RClockLeft = ScreenWidth/2+(ScreenWidth/2-RClockWidth)/2;
  469.    RClockTop = LClockTop;
  470.    RClockRight = RClockLeft + RClockWidth;
  471.    RClockBottom = RClockTop + RClockHeight;
  472.    WinBossSelect("Right");
  473.    if ( !WinFunction("spawn",RightClockHandle,P_NOWAIT,"Clock.exe") )
  474.       FatalError("Unable to start clock.");
  475.    WinVoidFunction("SetWindowRect",RightClockHandle,RClockLeft,RClockTop,RClockRight,RClockBottom);
  476.  
  477.    printf("\nSuch as these two Windows clocks, each in its own separate session.");
  478.    WaitSeconds(13);
  479.  
  480.    // show that each different session is in a diff. mode with diff. settings
  481.    EraseScreen();
  482.    printf("Like DOS sessions under OS/2, each Windows session can have any configuration.");
  483.    WinVoidFunction("KeyPushFocusID",0);
  484.    WinVoidFunction("KeyStroke",WVK_ALT,'S');
  485.    WinVoidFunction("KeyStroke",WVK_UP);
  486.    WinVoidFunction("KeyStroke",WVK_RETURN);
  487.    printf("\nOn the right: Standard mode with 7 megabytes of memory.");
  488.    WaitSeconds(4);
  489.  
  490.    WinBossSelect("Left");
  491.    WinVoidFunction("SetActiveWindow",LeftClockHandle);
  492.    WinVoidFunction("KeyPushFocusID",0);
  493.    WinVoidFunction("KeyStroke",WVK_ALT,'S');
  494.    WinVoidFunction("KeyStroke",WVK_UP);
  495.    WinVoidFunction("KeyStroke",WVK_RETURN);
  496.    printf("\nOn the left: Enhanced mode with 4 megabytes of memory.");
  497.    WaitSeconds(7);
  498.    WinVoidFunction("KeyStroke",WVK_SPACE);
  499.  
  500.    WinBossSelect("Right");
  501.    WinVoidFunction("SetActiveWindow","About Clock");
  502.    WinVoidFunction("KeyStroke",WVK_SPACE);
  503.    WaitSeconds(3);
  504.  
  505.    EraseScreen();
  506.    printf("Each separate, seamless Windows session is just like one single Windows 3.x\n"
  507.           "running under DOS.");
  508.  
  509.    // Start Program Manager on the left and right, but with clock on top.  These
  510.    // program managers will fill up most of the screen side by side
  511.    ProgManWidth = ScreenWidth / 2 - ScreenWidth / 25;
  512.    ProgManTop = 0;
  513.    ProgManHeight = ScreenHeight - MyHeight - 20;
  514.    LProgmanLeft = ((ScreenWidth/2)-ProgManWidth)/2;
  515.    RProgmanLeft = ScreenWidth/2 + lProgmanLeft;
  516.    if ( !WinFunction("spawn",RightProgmanHandle,P_NOWAIT,"Progman.exe") )
  517.       FatalError("Unable to start right progman.");
  518.    WinVoidFunction("SetWindowRect",RightProgmanHandle,
  519.                    RProgmanLeft,ProgManTop,RProgmanLeft+ProgManWidth,ProgManTop+ProgManHeight);
  520.    WinVoidFunction("SetActiveWindow",RightClockHandle);
  521.  
  522.    // program manager on the left
  523.    WinBossSelect("Left");
  524.    if ( !WinFunction("spawn",LeftProgmanHandle,P_NOWAIT,"Progman.exe") )
  525.       FatalError("Unable to start left progman.");
  526.    WinVoidFunction("SetWindowRect",LeftProgmanHandle,
  527.                    LProgmanLeft,ProgManTop,LProgmanLeft+ProgManWidth,ProgManTop+ProgManHeight);
  528.    WinVoidFunction("SetActiveWindow",LeftClockHandle);
  529.  
  530.    // start Notepad.exe on the left side, bleeding a little onto the right
  531.    if ( !WinFunction("spawn",NotepadHandle,P_NOWAIT,"NotePad.exe") )
  532.       FatalError("Unable to start notepad.exe.");
  533.    NotepadTop = LClockBottom - 8;
  534.    NotepadLeft = 0;
  535.    NotepadRight = (ScreenWidth / 2) - (ScreenWidth / 20);
  536.    NotepadBottom = ScreenHeight - MyHeight - 2;
  537.    WinVoidFunction("SetWindowRect",NotepadHandle,NotepadLeft,NotepadTop,NotepadRight,NotepadBottom);
  538.  
  539.    WinBossSelect("Right");
  540.    if ( !WinFunction("spawn",RightCalcHandle,P_NOWAIT,"Calc.exe") )
  541.       FatalError("Unable to start calculator.");
  542.    WinVoidFunction("SetPosition",RightCalcHandle,
  543.                    ScreenWidth/2+ScreenWidth/30,RClockHeight + RClockTop - 13);
  544.    printf(" These two sessions, for example, are each SEPARATELY busy...");
  545.  
  546.    // spend a little while pushing buttons on the calculators
  547.    WinBossSelect("Left");
  548.    WinVoidFunction("SetActiveWindow",NotepadHandle);
  549.    // Make sure notepad has word wrap on
  550.    WinFunction("GetMenu",NotepadMenu,NotepadHandle);
  551.    WinFunction("FindMenuString",WordWrapID,NotepadMenu,"Word Wrap");
  552.    #define WMF_CHECKED      0x08    // checkmark is next to item
  553.    #define WMF_BYCOMMAND    0x0000  // use the item ID
  554.    WinFunction("GetMenuState",WordWrapState,NotepadMenu,WordWrapID,WMF_BYCOMMAND);
  555.    if ( !(WMF_CHECKED & WordWrapState) )
  556.       WinVoidFunction("MenuCommand",NotepadHandle,WordWrapID);
  557.  
  558.    // send long Nombas advertisement to notpad
  559.    WinNoWaitFunction("SpeedKeys",NombasAdvertisement,50);
  560.  
  561.    WinBossSelect("Right");
  562.    WinVoidFunction("SetActiveWindow",RightCalcHandle);
  563.    WinVoidFunction("SpeedKeys","3.14159/-345+212.456=",900);
  564.  
  565.    // Cause a GPF in the right session, and wait till the GPF shows up
  566.    PreGPFWindow = GetActiveWindow();
  567.    WinNoWaitFunction("poke",0,UWORD32);
  568.    while ( PreGPFWindow == GetActiveWindow() ) suspend(800);
  569.    WaitSeconds(2);
  570.  
  571.    EraseScreen();
  572.    printf("OOOPS!  There's that dreaded Windows GPF in the session on the right.");
  573.    for ( i = 0; i < 4; i++ ) {
  574.       DosBeep(400,300);
  575.       DosBeep(200,300);
  576.    }
  577.    WaitSeconds(2);
  578.    printf("\nBut OS/2's crash protection lets the other Windows session continue...");
  579.    WaitSeconds(8);
  580.  
  581.    EraseScreen();
  582.    printf("OS/2 can end the \"CRASHED\" windows session...");
  583.    WaitSeconds(2);
  584.  
  585.    KeyStroke(VK_SPACE);
  586.    QCall( "kill_cmd", RightProcessID );
  587.    printf("\b\b\b, and continue without worry.");
  588.    WaitSeconds(7);
  589.  
  590.    EraseScreen();
  591.    printf("OS/2 truly is a better Window(s) than Windows\n"
  592.           "(More Wow than WOW!)");
  593.    WaitSeconds(4);
  594.    printf("   Let's continue...");
  595.    WaitSeconds(1);
  596.  
  597.    QCall( "kill_cmd", "Session:ServeOS2" );
  598.  
  599. }
  600.  
  601. /*************** DOS CONFIGURATIONS ***************/
  602. DosConfigurations()
  603. {
  604.    LogHere("DosConfigurations()");
  605.    SetWindowTitle(Info().WinHandle,"OS/2 Demo: BYE BYE MEMORY MANAGERS");
  606.  
  607.    EraseScreen();
  608.    printf("With OS/2, you don't need DOS memory managers, reboots, and frustration.\n"
  609.           "Each simultaneous DOS session in OS/2 has independent memory configuration.");
  610.  
  611.    lRowIncrement = ScreenHeight / 30;  // how much to raise each window
  612.    lColIncrement = ScreenWidth / 30;   // how much to push each window to the right
  613.  
  614.    lRow = MyHeight + ScreenHeight / 50;
  615.    lCol = ScreenWidth / 30;
  616.    sprintf(lPosition,"%d,%d",lCol,lRow);
  617.    RestoreDefaultDOSSettings();
  618.    QCall( "session_cmd", "/TITLE", "Teeny-Tiny DOS Memory", "/F", "/WIN", "/DOS",
  619.           "/FONT", DOS_MEMCONFIG_FONTSIZE,
  620.           "/POS", lPosition, "/K",
  621.           "/SET", "DPMI_DOS_API=DISABLED",
  622.           "/SET", "DPMI_MEMORY_LIMIT=0",
  623.           "/SET", "DPMI_NETWORK_BUFF_SIZE=0",
  624.           "/SET", "EMS_FRAME_LOCATION=NONE",
  625.           "/SET", "EMS_MEMORY_LIMIT=0",
  626.           "/SET", "EMS_LOW_OS_MAP_REGION=0",
  627.           "/SET", "EMS_MEMORY_LIMIT=0",
  628.           "/SET", "XMS_HANDLES=0",
  629.           "/SET", "XMS_MEMORY_LIMIT=0",
  630.           "/SET", "XMS_MINIMUM_HMA=0",
  631.           "/SET", "DOS_RMSIZE=90",
  632.           "MEM.EXE" );
  633.    WaitSeconds(2);
  634.    EraseScreen();
  635.    printf("Here is a session with a mere 90K of memory...");
  636.    WaitSeconds(10);
  637.  
  638.    lRow += lRowIncrement; lCol += lColIncrement;
  639.    sprintf(lPosition,"%d,%d",lCol,lRow);
  640.    RestoreDefaultDOSSettings();
  641.    QCall( "session_cmd", "/TITLE", "Lots of EMS Memory", "/F", "/WIN", "/DOS",
  642.           "/FONT", DOS_MEMCONFIG_FONTSIZE,
  643.           "/POS", lPosition, "/K",
  644.           "/SET", "DPMI_DOS_API=DISABLED",
  645.           "/SET", "DPMI_MEMORY_LIMIT=0",
  646.           "/SET", "DPMI_NETWORK_BUFF_SIZE=0",
  647.           "/SET", "EMS_FRAME_LOCATION=AUTO",
  648.           "/SET", "EMS_LOW_OS_MAP_REGION=0",
  649.           "/SET", "EMS_MEMORY_LIMIT=32768",
  650.           "/SET", "XMS_HANDLES=0",
  651.           "/SET", "XMS_MEMORY_LIMIT=0",
  652.           "/SET", "XMS_MINIMUM_HMA=0",
  653.           "MEM.EXE" );
  654.    WaitSeconds(1);
  655.    EraseScreen();
  656.    printf("Here is a session with 32 megabytes of EMS memory...");
  657.    WaitSeconds(7);
  658.  
  659.    lRow += lRowIncrement; lCol += lColIncrement;
  660.    sprintf(lPosition,"%d,%d",lCol,lRow);
  661.    RestoreDefaultDOSSettings();
  662.    QCall( "session_cmd", "/TITLE", "Lots of XMS Memory", "/F", "/WIN", "/DOS",
  663.           "/FONT", DOS_MEMCONFIG_FONTSIZE,
  664.           "/POS", lPosition, "/K",
  665.           "/SET", "DPMI_DOS_API=DISABLED",
  666.           "/SET", "DPMI_MEMORY_LIMIT=0",
  667.           "/SET", "DPMI_NETWORK_BUFF_SIZE=0",
  668.           "/SET", "EMS_FRAME_LOCATION=NONE",
  669.           "/SET", "EMS_MEMORY_LIMIT=0",
  670.           "/SET", "EMS_LOW_OS_MAP_REGION=0",
  671.           "/SET", "EMS_MEMORY_LIMIT=0",
  672.           "/SET", "XMS_HANDLES=127",
  673.           "/SET", "XMS_MEMORY_LIMIT=16384",
  674.           "/SET", "XMS_MINIMUM_HMA=63",
  675.           "MEM.EXE" );
  676.    WaitSeconds(1);
  677.    EraseScreen();
  678.    printf("Here is a session with 16 megabyte of XMS memory...");
  679.    WaitSeconds(7);
  680.  
  681.    lRow += lRowIncrement; lCol += lColIncrement;
  682.    sprintf(lPosition,"%d,%d",lCol,lRow);
  683.    RestoreDefaultDOSSettings();
  684.    QCall( "session_cmd", "/TITLE", "Tons of Virtual Memory", "/F", "/WIN", "/DOS",
  685.           "/FONT", DOS_MEMCONFIG_FONTSIZE,
  686.           "/POS", lPosition, "/K",
  687.           "/SET", "DPMI_DOS_API=ENABLED",
  688.           "/SET", "DPMI_MEMORY_LIMIT=512",
  689.           "/SET", "DPMI_NETWORK_BUFF_SIZE=0",
  690.           "/SET", "EMS_FRAME_LOCATION=AUTO",
  691.           "/SET", "EMS_LOW_OS_MAP_REGION=0",
  692.           "/SET", "EMS_MEMORY_LIMIT=32768",
  693.           "/SET", "XMS_HANDLES=127",
  694.           "/SET", "XMS_MEMORY_LIMIT=16384",
  695.           "/SET", "XMS_MINIMUM_HMA=63",
  696.           "MEM.EXE" );
  697.    WaitSeconds(1);
  698.    EraseScreen();
  699.    printf("Plus this session with 32 Mbyte EMS, 16 MByte XMS, and 512 MByte DPMI memory."
  700.           "\nThat's 560 Megs of memory--much more memory than is in this computer!");
  701.    WaitSeconds(7);
  702.  
  703.    lRow += lRowIncrement; lCol += lColIncrement;
  704.    sprintf(lPosition,"%d,%d",lCol,lRow);
  705.    RestoreDefaultDOSSettings();
  706.    QCall( "session_cmd", "/TITLE", "Lots of DOS Memory", "/F", "/WIN", "/DOS",
  707.           "/FONT", DOS_MEMCONFIG_FONTSIZE,
  708.           "/POS", lPosition, "/K",
  709.           "/SET", "VIDEO_MODE_RESTRICTION=CGA            ",
  710.           "/SET", "DOS_DEVICE=",
  711.           "/SET", "DOS_FCBS=1",
  712.           "/SET", "DOS_FCBS_KEEP=1",
  713.           "/SET", "DOS_FILES=20",
  714.           "/SET", "DOS_HIGH=1",
  715.           "/SET", "DOS_RMSIZE=640",
  716.           "/SET", "DOS_UMB=1",
  717.           "/SET", "DPMI_DOS_API=DISABLED",
  718.           "/SET", "DPMI_MEMORY_LIMIT=0",
  719.           "/SET", "DPMI_NETWORK_BUFF_SIZE=0",
  720.           "/SET", "EMS_FRAME_LOCATION=NONE",
  721.           "/SET", "EMS_MEMORY_LIMIT=0",
  722.           "/SET", "EMS_LOW_OS_MAP_REGION=0",
  723.           "/SET", "EMS_MEMORY_LIMIT=0",
  724.           "/SET", "XMS_HANDLES=0",
  725.           "/SET", "XMS_MEMORY_LIMIT=0",
  726.           "/SET", "XMS_MINIMUM_HMA=0",
  727.           "MEM.EXE" );
  728.    WaitSeconds(1);
  729.    EraseScreen();
  730.    printf("Finally, here is a DOS session with over 700K conventional memory.");
  731.    WaitSeconds(8);
  732.  
  733.    QCall( "domenu_cmd", "Lots of DOS Memory", "Close" );
  734.    QCall( "domenu_cmd", "Tons of Virtual Memory", "Close" );
  735.    QCall( "domenu_cmd", "Lots of XMS Memory", "Close" );
  736.    QCall( "domenu_cmd", "Lots of EMS Memory", "Close" );
  737.    QCall( "domenu_cmd", "Teeny-Tiny DOS Memory", "Close" );
  738. }
  739.  
  740. /******************* PMApplets *******************/
  741.  
  742. PMApplets()
  743. {
  744.    LogHere("PMApplets()");
  745.    SetWindowTitle(Info().WinHandle,"OS/2 Demo: PM Appletts");
  746.  
  747.    EraseScreen();
  748.    printf("OS/2, the 32-bit multi-threaded, multi-tasking operating system\n"
  749.           "truly shines when running true 32-bit PM applications...");
  750.  
  751.    // start pmspread
  752.    PMSpreadWidth = ScreenWidth * 3 / 5 ;
  753.    PMSpreadHeight = (ScreenHeight - MyHeight) * 3 / 5 ;
  754.    PMSpreadCol = ScreenWidth - PMSpreadWidth;
  755.    PMSpreadRow = MyHeight;
  756.    sprintf(lSize,"%d,%d",PMSpreadWidth,PMSpreadHeight);
  757.    sprintf(lPos,"%d,%d",PMSpreadCol,PMSpreadRow);
  758.    QCall( "session_cmd", "/Title", "untitled - Spreadsheet", "/PM",
  759.           "/SIZE", lSize, "/POS", lPos, "PMSpread.exe" );
  760.  
  761.    // start klondike
  762.    KlondikeWidth = ScreenWidth * 5 / 7 ;
  763.    KlondikeHeight = (ScreenHeight - MyHeight) * 5 / 7 ;
  764.    KlondikeCol = 0;
  765.    KlondikeRow = MyHeight + (ScreenHeight - MyHeight) - KlondikeHeight;
  766.    sprintf(lSize,"%d,%d",KlondikeWidth,KlondikeHeight);
  767.    sprintf(lPos,"%d,%d",KlondikeCol,KlondikeRow);
  768.    QCall( "session_cmd", "/Title", "Klondike", "/PM", "/B",
  769.           "/SIZE", lSize, "/POS", lPos, "Klondike.exe" );
  770.    QCall( "domenu_cmd", "Klondike", "None" );
  771.  
  772.    EraseScreen();
  773.    printf("What do you want to do?  Work?  Play?");
  774.  
  775.    // tell klondike to go automatic
  776.    QCall( "domenu_cmd", "Klondike", "Very Slow" );
  777.    QCall( "domenu_cmd", "Klondike", "Auto play" );
  778.  
  779.    printf("  How about Work AND play?!\n"
  780.           "OS/2 will even play solitaire for you.  Talk about productivity!");
  781.  
  782.    #define PLAY_TIME    30    // how many seconds to play
  783.    StartPlay = time();
  784.    KeyPushFocusID(NULL);
  785.    directions = { VK_LEFT, VK_UP, VK_RIGHT, VK_DOWN };
  786.    do {
  787.       // enter a number in the spreadsheet
  788.       for ( backspace = 0; backspace < 3; backspace++ ) {
  789.          suspend(250);
  790.          KeyStroke(VK_BACKSPACE);
  791.       } 
  792.       sprintf(RandomNumber,"%d",rand() % 1000);
  793.       SpeedKeys(RandomNumber,300);
  794.       suspend(300);
  795.       KeyStroke(VK_ENTER);
  796.       suspend(300);
  797.       KeyStroke(directions[rand() % 4]);
  798.       suspend(300);
  799.    } while ( difftime(time(),StartPlay) < PLAY_TIME );
  800.  
  801.    // turn off auto play
  802.    QCall( "switch_cmd", "Klondike" );
  803.    WaitSeconds(1);
  804.    KeyStroke(VK_CTRL,'P');
  805.    WaitSeconds(2);
  806.  
  807.    QCall( "kill_cmd", "Spreadsheet" );
  808.    QCall( "kill_cmd", "Klondike" );
  809. }
  810.  
  811. /************** QCall ************************
  812.  *** Quick call to included .CMD utilities ***
  813.  *********************************************/
  814.  
  815. QCall(pCmdName /*lotta args */)
  816. {
  817.    lArgc = va_arg();
  818.    for ( lVarCount = 0; lVarCount < lArgc; lVarCount++ ) {
  819.       lVar = va_arg(lVarCount);
  820.       if ( 1 == DataDimension(lVar) )
  821.          strcpy(lArgv[lVarCount],lVar);
  822.       else
  823.          sprintf(lArgv[lVarCount],"%d",lVar);
  824.    }
  825.    function(pCmdName,lArgc,lArgv);
  826. }
  827.  
  828.  
  829. #define main session_cmd
  830. #include <Session.cmd>
  831.  
  832. #define main switch_cmd
  833. #include <Switch.cmd>
  834.  
  835. #define main kill_cmd
  836. #include <Kill.cmd>
  837. KillQuietMode = True;
  838.  
  839. #define main winset_cmd
  840. #include <WinSet.cmd>
  841.  
  842. #define main domenu_cmd
  843. #include <DoMenu.cmd>
  844.  
  845. #define main switch_cmd
  846. #include <Switch.cmd>
  847.  
  848. /************************ SESSION ************************
  849.  *** session_cmd is called a lot here, so provide this ***
  850.  *** means to restore original sessions settings       ***
  851.  *********************************************************/
  852.  
  853. gDefaultDOSSettings = {
  854.    //"COM_DIRECT_ACCESS=0",  // 0 or 1
  855.    //"COM_HOLD=0",           // 0 or 1
  856.    //"COM_RECEIVE_BUFFER_FLUSH="   // select one of the following
  857.       //"ALL",
  858.       //"RECEIVE DATA INTERRUPT ENABLE",
  859.       //"SWITCH TO FOREGROUND",
  860.       //"NONE",
  861.    //"COM_SELECT="
  862.       //" ALL",
  863.       //"COM1",
  864.       //"COM2",
  865.       //"COM3",
  866.       //"COM4",
  867.       //"NONE",
  868.    //"DOS_AUTOEXEC=C:\\AUTOEXEC.BAT",
  869.    "DOS_BACKGROUND_EXECUTION=1", // 0 or 1
  870.    //"DOS_BREAK=1", // 0 or 1
  871.    //"DOS_DEVICE=SIZE=0  C:\\OS2\\MDOS\\ANSI.SYS",
  872.    //"DOS_FCBS=16",
  873.    //"DOS_FCBS_KEEP=8",
  874.    //"DOS_FILES=75",
  875.    //"DOS_HIGH=0",  // 0 or 1
  876.    //"DOS_LASTDRIVE=Z",
  877.    //"DOS_RMSIZE=640",
  878.    //"DOS_SHELL=C:\\OS2\\MDOS\\COMMAND.COM C:\\OS2\\MDOS",
  879.    //"DOS_UMB=0",   // 0 or 1
  880.    //"DOS_VERSION=DCJSS02.EXE,3,40,255"
  881.       //"\nDFIA0MOD.SYS,3,40,255"
  882.       //"\nDXMA0MOD.SYS,3,40,255"
  883.       //"\nEXCEL.EXE,10,10,4"
  884.       //"\nIBMCACHE.COM,3,40,255"
  885.       //"\nIBMCACHE.SYS,3,40,255"
  886.       //"\nISAM.EXE,3,40,255"
  887.       //"\nISAM2.EXE,3,40,255"
  888.       //"\nISQL.EXE,3,40,255"
  889.       //"\nMSD.EXE,5,00,255"
  890.       //"\nNET3.COM,3,40,255"
  891.       //"\nNETX.COM,4,00,255"
  892.       //"\nNETX.EXE,5,00,255"
  893.       //"\nPSCPG.COM,3,40,255"
  894.       //"\nSAF.EXE,3,40,255"
  895.       //"\nWIN200.BIN,10,10,4",
  896.    //"DPMI_DOS_API="   // select one of the following
  897.       //"AUTO",
  898.       //"ENABLED",
  899.       //"DISABLED",
  900.    //"DPMI_MEMORY_LIMIT=4",
  901.    //"DPMI_NETWORK_BUFF_SIZE=8",
  902.    //"EMS_FRAME_LOCATION="
  903.       //"AUTO",
  904.       //"NONE",
  905.       //"C000",
  906.       //"C400",
  907.       //"C800",
  908.       //"CC00",
  909.       //"D000",
  910.       //"D400",
  911.       //"D800",
  912.       //"DC00",
  913.       //"8000",
  914.       //"8400",
  915.       //"8800",
  916.       //"8C00",
  917.       //"9000",
  918.    //"EMS_HIGH_OS_MAP_REGION=0",
  919.    //"EMS_LOW_OS_MAP_REGION=384",
  920.    //"EMS_MEMORY_LIMIT=2048",
  921.    //"HW_NOSOUND=0",      // 0 or 1
  922.    //"HW_ROM_TO_RAM=0",   // 0 or 1
  923.    //"HW_TIMER=0",        // 0 or 1
  924.    //"IDLE_SECONDS=0",
  925.    "IDLE_SENSITIVITY=75",
  926.    //"INT_DURING_IO=0",   // 0 or 1
  927.    //"KBD_ALTHOME_BYPASS=0", // 0 or 1
  928.    //"KBD_BUFFER_EXTEND=1",  // 0 or 1
  929.    "KBD_CTRL_BYPASS="   // select one of the following
  930.       "NONE",
  931.       //"ALT_ESC",
  932.       //"CTRL_ESC",
  933.    //"KBD_RATE_LOCK=0",   // 0 or 1
  934.    //"MEM_EXCLUDE_REGIONS=",
  935.    //"MEM_INCLUDE_REGIONS=",
  936.    //"MOUSE_EXCLUSIVE_ACCESS=0",   // 0 or 1
  937.    //"PRINT_SEPARATE_OUTPUT=1",    // 0 or 1
  938.    //"PRINT_TIMEOUT=15",
  939.    //"VIDEO_8514A_XGA_IOTRAP=1",   // 0 or 1
  940.    //"VIDEO_FASTPASTE=0",          // 0 or 1
  941.    //"VIDEO_MODE_RESTRICTION="  // select one of the following
  942.       //"NONE         ",
  943.       //"CGA            ",
  944.       //"MONO           ",
  945.    //"VIDEO_ONDEMAND_MEMORY=1",    // 0 or 1
  946.    //"VIDEO_RETRACE_EMULATION=1",  // 0 or 1
  947.    //"VIDEO_ROM_EMULATION=1",      // 0 or 1
  948.    //"VIDEO_SWITCH_NOTIFICATION=0",// 0 or 1
  949.    //"VIDEO_WINDOW_REFRESH=1",
  950.    //"XMS_HANDLES=32",
  951.    //"XMS_MEMORY_LIMIT=2048",
  952.    //"XMS_MINIMUM_HMA=0",
  953. };
  954.  
  955. RestoreDefaultDOSSettings()
  956. {
  957.    lSetCount = 1 + GetArraySpan(gDefaultDOSSettings);
  958.    undefine(MyDefaultDOSSettings);
  959.    for ( lSetting = 0; lSetting < lSetCount; lSetting++ )
  960.       strcpy(MyDefaultDOSSettings[lSetting],gDefaultDOSSettings[lSetting]);
  961. }
  962.  
  963. /*************** UTILITIES ************/
  964. SetScreenColors(pFore,pBack)
  965. {
  966.    // set color for bright white on blue background
  967.    #define BOLD_ON      1
  968.    #define BLACK_FOR    30
  969.    #define RED_FORE     31
  970.    #define GREEN_FORE   32
  971.    #define YELLOW_FORE  33
  972.    #define BLUE_FORE    34
  973.    #define MAGENTA_FORE 35
  974.    #define CYAN_FORE    36
  975.    #define WHITE_FORE   37
  976.    #define BLACK_BACK   40
  977.    #define RED_BACK     41
  978.    #define GREEN_BACK   42
  979.    #define YELLOW_BACK  43
  980.    #define BLUE_BACK    44
  981.    #define MAGENTA_BACK 45
  982.    #define CYAN_BACK    46
  983.    #define WHITE_BACK   47
  984.    printf("\033[0;%d;%d;%dm",YELLOW_FORE,BLUE_BACK,BOLD_ON);
  985. }
  986.  
  987. EraseScreen()  // clear screen
  988. {
  989.    printf("\033[2J");
  990. }
  991.  
  992. WaitSeconds(lSec)
  993. {
  994.    lStartTime = time();
  995.    while ( difftime(time(),lStartTime) < lSec )
  996.       suspend(500);
  997. }
  998.  
  999. FatalError(lFormatString/*,arg1,arg2...*/)
  1000. {
  1001.    va_start(lVaList,lFormatString);
  1002.    printf("\a\a\a\n");
  1003.    vprintf(lFormatString,lVaList);
  1004.    va_end(lVaList);
  1005.    abort();
  1006. }
  1007.  
  1008. DosBeep(Frequency,Duration)   // play specified Frequency, in Hz, for specified
  1009. {                             // duration, in milliseconds
  1010.    #define ORD_DOS32BEEP   286
  1011.    return DynamicLink("doscalls",ORD_DOS32BEEP,BIT32,CDECL,Frequency,Duration)
  1012. }
  1013.  
  1014. //***************************************************************************
  1015. //*** LogFile routines - If the OS2DEMO_LOGFILE environment variable is   ***
  1016. //*** not defined then these do nothing.  Else they initialize the log    ***
  1017. //*** file to append when the demo started at the end of the existing     ***
  1018. //*** log file.  LogHere() messages are added to the log file whenever    ***
  1019. //*** LogHere() is called, however these messages ovewrite each other so  ***
  1020. //*** that the log file does not grow too very large.  LogHere() messages ***
  1021. //*** timestamp and put a brief message so that you can look at the       ***
  1022. //*** file later to get an idea of what the last message was before a     ***
  1023. //*** demo ever hangs                                                     ***
  1024.  
  1025. gLogFileSeek;
  1026. #define EOF_CHAR  ( 'Z' - 'A' + 1 ) // ctrl-Z = EOF
  1027. InitializeLogFile(); // initialize log file when starting OS2DEMO
  1028.  
  1029.  
  1030. LogHere(FormatString/*,arg1,arg2,arg3*/)
  1031. {
  1032.    if ( defined(gLogFileSeek) ) {
  1033.       if ( fp = fopen(OS2DEMO_LOGFILE,"r+t") ) {
  1034.  
  1035.          // print this messages where the log messages go
  1036.          fseek(fp,gLogFileSeek);
  1037.          va_start(va_list,FormatString);
  1038.          vfprintf(fp,FormatString,va_list);
  1039.          va_end(va_list);
  1040.  
  1041.          // print the current time
  1042.          CurrentTime = ctime(time());
  1043.          CurrentTime[strlen(CurrentTime)-1] = '\0';
  1044.          fprintf(fp,"\nLogHere at: %s\n",CurrentTime);
  1045.  
  1046.          // add ctrl-z (EOF) character after this message
  1047.          fprintf(fp,"%c",EOF_CHAR);
  1048.          fclose(fp);
  1049.       }
  1050.    }
  1051. }
  1052.  
  1053. InitializeLogFile()  // start log, set timestamp of start, and save seek position
  1054. {
  1055.    if ( defined(OS2DEMO_LOGFILE) ) {
  1056.       if ( (fp = fopen(OS2DEMO_LOGFILE,"r+b"))
  1057.         || (fp = fopen(OS2DEMO_LOGFILE,"wb")) ) {
  1058.          // read to end of file or EOF_CHAR
  1059.          fseek(fp,0,SEEK_SET);
  1060.          gLogFileSeek = ftell(fp);
  1061.          while ( EOF != (lChar = fgetc(fp))  &&  EOF_CHAR != lChar ) {
  1062.             gLogFileSeek = ftell(fp);
  1063.          }
  1064.  
  1065.          // write log time start message
  1066.          fseek(fp,gLogFileSeek);
  1067.          CurrentTime = ctime(time());
  1068.          CurrentTime[strlen(CurrentTime)-1] = '\0';
  1069.          fprintf(fp,"\r\n\r\n\r\nStartTest at: %s\r\n\r\n",CurrentTime);
  1070.          // remember where to write following messages
  1071.          gLogFileSeek = ftell(fp);
  1072.          fclose(fp);
  1073.       }
  1074.    }
  1075. }
  1076.  
  1077.  
  1078.  
  1079. /********************** MAIN OS2DEMO ROUTINE ***********************/
  1080.  
  1081. // Make a nicer screen color using ANSI codes;  Black on white?
  1082. SetScreenColors();
  1083. EraseScreen();
  1084.  
  1085. // get screen dimensions
  1086. GetScreenSize(ScreenWidth,ScreenHeight);
  1087. GetSize(Info().WinHandle,MyWidth,MyHeight);
  1088.  
  1089. RunForever()
  1090. {
  1091.    for( ; ; ) {
  1092.  
  1093.       LogHere("Start sesson all over again");
  1094.  
  1095.       ManyDosSessions();
  1096.  
  1097.       DosConfigurations();
  1098.  
  1099.       ManyWindowsSessions();
  1100.  
  1101.       PMApplets();
  1102.  
  1103.       //WorkplaceShell();  not written yet
  1104.  
  1105.       //WorkingTogether(); not written yet
  1106.  
  1107.       EraseScreen();
  1108.       SetWindowTitle(Info().WinHandle,"OS/2 Demo: ALL DONE!");
  1109.       printf("That was such a fun demo!  Let's do it again.");
  1110.       WaitSeconds(6);
  1111.    }
  1112. }
  1113.  
  1114.  
  1115.