home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / SCREDIT2.ZIP / SCRDEMO.P < prev    next >
Encoding:
Text File  |  1989-03-02  |  12.3 KB  |  390 lines

  1. Program ScrDemo;
  2. {
  3.  
  4. <C>opyright 1989 by iHn Systems - all rights reserved
  5.  
  6. Read ScrEdit.Tut for a description of how to use this program.
  7.  
  8. }
  9. {---------------------------------------------------------------------------}
  10.  
  11. You will get a compiler error here until you select the appropriate interface
  12. for your compiler and delete these comments.
  13.  
  14. This interface is for Turbo Pascal 3.0
  15.  
  16. {$I \scredit\interfac\ScrEd30.Pas}
  17. {$I \scredit\interfac\ScrEd3&4.Pas}
  18.  
  19. This interfac is for Turbo Pascal 4.0 & 5.0
  20.  
  21. USES Crt,SCRED40;
  22.  
  23. {---------------------------------------------------------------------------}
  24.  
  25. {$I ScrDemo.001}
  26. {$I ScrDemo.002}
  27.  
  28. Var
  29.     Option          : Integer;
  30.     Screen_Mode     : Integer;
  31.     Cursor_Position : Integer;
  32.  
  33.  
  34. Procedure Back_To_Turbo_Pascal_Land;
  35. Var
  36. Response : String[10];
  37. Begin
  38. ClrScr;
  39. Repeat
  40.     ClrScr;
  41.     WriteLn('This is regular pascal code now.');
  42.     WriteLn('');
  43.     WriteLn('You can do anything now that you want to, use any ');
  44.     WriteLn('programming statement that you wish to.  When you');
  45.     WriteLn('are ready to resume with Turbo ScrEdit just return');
  46.     WriteLn('and the screen will be reloaded and you will resume');
  47.     WriteLn('at the point where you left the screen.');
  48.     WriteLn;
  49.     Write('Type "RETURN" in upper case to end this example...');
  50.     ReadLn(Response);
  51. Until (Response = 'RETURN')
  52. End;
  53.  
  54. Procedure ScrDemo_Init;
  55. Begin
  56.  
  57. S_Init;{<==DO NOT USE TURBO SCREDIT PROCEDURES WITHOUT CALLING S_INIT}
  58.  
  59. S_OpenScreenFile('ScrDemo.SCR');
  60.  
  61. Initialize_Demo_Menu_buf;
  62. Initialize_Demo_Screen_Buf;
  63.  
  64. S_LoadScreen('Demo_Menu');
  65.  
  66. TextBackGround(Black);
  67. TextColor(Green);
  68.  
  69. Screen_Mode  := 0;
  70. S_Cursor     := S_Normal;
  71. S_Sound      := False;
  72. Option       := 1;
  73. S_ShowStatus := True;
  74. End;
  75.  
  76.  
  77. Procedure Process_Screen;
  78. Begin
  79. If  Screen_Mode = 1 Then
  80.     Begin
  81.     Cursor_Position := Trunc(Demo_Screen_Buf.OP + 0.005);
  82.     Case Cursor_Position of
  83.        0 : S_Point := S_FirstField;
  84.        1 : S_Point := 2;
  85.        2 : S_Point := 5;
  86.        3 : S_Point := 12;
  87.        4 : S_Point := 9;
  88.     End; {Case of}
  89.     End;
  90.  
  91. If  Screen_Mode = 2 then
  92.     Begin
  93.     S_Point         := S_Point + 1;
  94.     Cursor_Position := Trunc(Demo_Screen_Buf.OP + 0.005);
  95.     Case Cursor_Position of
  96.        0 : S_Point := 1;
  97.        1 : If (S_Point > 4) Or
  98.               (S_Point < 2) Then
  99.               S_Point := 2;
  100.        2 : Begin
  101.            If (S_Point > 10) Or
  102.               (S_Point < 5)  Then
  103.               S_Point := 5;
  104.            If S_Point = 9 Then
  105.               S_Point := 10;
  106.            End;
  107.        3 : If (S_Point > 13) Or
  108.               (S_Point < 12) Then
  109.               S_Point := 12;
  110.        4 : Begin
  111.            If (S_Point > 11) Or
  112.               (S_Point < 9)  Then
  113.               S_Point := 9;
  114.               If S_Point = 10 Then
  115.                  S_Point := 11;
  116.            End;
  117.     End; {Case of}
  118.     End;
  119.  
  120. S_Msg := ' <F1>=Ininialize Screen <F2>=Return to Menu ';
  121.  
  122. Case Screen_Mode of
  123.    2 : S_ReadField;
  124.    1 : S_ReadScreen;
  125. End; {Case of}
  126.  
  127. If  S_Fkey Then
  128.     Begin
  129.     If  (Not S_Shift) And
  130.         (Not S_Ctrl)  And
  131.         (Not S_Alt)   Then
  132.         Begin
  133.         If  S_F1 Then
  134.             Begin
  135.             Initialize_Demo_Screen_Buf;
  136.             S_Point := S_FirstField;
  137.             S_Msg   := 'Screen has been reset.';
  138.             End;
  139.         If  S_F2 Then
  140.             Screen_Mode   := 0;
  141.         End;
  142.     End;
  143. End;
  144.  
  145.  
  146.  
  147.  
  148.  
  149. Procedure Read_Menu_Screen;
  150. Var
  151. X,Y,Z : Integer;
  152. Begin
  153. S_LoadScreen('Demo_Menu');
  154. Repeat
  155.     FillChar(Demo_Menu_Buf,SizeOf(Demo_Menu_Buf),00);
  156.  
  157.     Demo_Menu_Buf.O1 := 'This Menu';
  158.     Demo_Menu_Buf.O2 := 'Using S_ReadScreen';
  159.     Demo_Menu_Buf.O3 := 'Using S_ReadField';
  160.     Demo_Menu_Buf.O4 := 'Using S_ReadKey';
  161.     Demo_Menu_Buf.O5 := 'Using S_NextKey';
  162.     Demo_Menu_Buf.O6 := 'Using Windows';
  163.     Demo_Menu_Buf.O7 := 'Using The Message Line';
  164.     Demo_Menu_Buf.O8 := 'Mixed ScrEdit';
  165.     Demo_Menu_Buf.O13:= 'Remaining Memory';
  166.  
  167.     If  Option < 1 Then Option := 9;
  168.     If  Option > 9 Then Option := 1;
  169.  
  170.     With Demo_Menu_Buf Do
  171.         Begin
  172.         Case Option of
  173.             1  : Begin
  174.                  P1 := '==>';
  175.                  M1 := 'To use this menu, have a listing of the';
  176.                  M2 := 'file SCRDEMO.P with you and follow';
  177.                  M3 := 'each of the examples through the pascal';
  178.                  M4 := 'code. This program is designed to help';
  179.                  M5 := 'you understand how to implement Turbo';
  180.                  M6 := 'ScrEdit procedures in your programs.';
  181.                  End;
  182.             2  : Begin
  183.                  P2 := '==>';
  184.                  M1 := 'S_ReadScreen - process an entire screen';
  185.                  M2 := 'with one call. Control returns to your ';
  186.                  M3 := 'program when ENTER, UP or DOWN arrows,';
  187.                  M4 := 'HOME, END, PGUP, PGDN, INSERT, DEL, one';
  188.                  M5 := 'the F keys, or any key is pressed in ';
  189.                  M6 := 'conjuction with ALT or CTRL.';
  190.                  End;
  191.             3  : Begin
  192.                  P3 := '==>';
  193.                  M1 := 'S_ReadField - Process a single screen';
  194.                  M2 := 'field at a time. Control returns to';
  195.                  M3 := 'your program when the cursor is moved  ';
  196.                  M4 := 'off of the field with the left or right';
  197.                  M5 := 'arrow keys, TAB key, or Any of the';
  198.                  M6 := 'other key listed with S_ReadScreen.';
  199.                  End;
  200.             4  : Begin
  201.                  P4 := '==>';
  202.                  M1 := 'S_ReadKey - This demonstrates how to';
  203.                  M2 := 'display a message on the message line';
  204.                  M3 := 'and accept a keystroke response from';
  205.                  M4 := 'the user. The key pressed does not';
  206.                  M5 := 'echo to the screen and will not be ';
  207.                  M6 := 'placed in any screen field.';
  208.                  End;
  209.             5  : Begin
  210.                  P5 := '==>';
  211.                  M1 := 'S_NextKey - This demonstrates how to';
  212.                  M2 := 'read the next key pressed only. No ';
  213.                  M3 := 'message can be displayed. Turbo Scredit';
  214.                  M4 := 'waits for the next key pressed and     ';
  215.                  M5 := 'returns to your program.';
  216.                  End;
  217.             6  : Begin
  218.                  P6 := '==>';
  219.                  M1 := 'A method of using windows to display';
  220.                  M2 := 'data on your screens and then restore';
  221.                  M3 := 'the screen to its original state.';
  222.                  End;
  223.             7  : Begin
  224.                  P7 := '==>';
  225.                  M1 := 'Demonstrates several way of using ';
  226.                  M2 := 'the message line to communicate with';
  227.                  M3 := 'the user of your program.';
  228.                  End;
  229.             8  : Begin
  230.                  P8 := '==>';
  231.                  M1 := 'This demonstrates how you can exit a';
  232.                  M2 := 'procedure using a Turbo ScrEdit screen';
  233.                  M3 := 'to use your language`s standard inupt';
  234.                  M4 := 'and output statements, and then resume ';
  235.                  M5 := 'using Turbo ScrEdit when you wish.';
  236.                  End;
  237.              9 : Begin
  238.                  P13 := '==>';
  239.                  M1 := 'Use this option to see how much     ';
  240.                  M2 := 'memory is left on your machine while';
  241.                  M3 := 'you run this program.';
  242.                  End;
  243.             End;{Case of};
  244.     End;
  245.     Repeat
  246.         S_ReadKey;
  247.         If  (S_Up)   Or
  248.             (S_Down) Or
  249.             (S_Enter)Or
  250.             (S_Esc)  Then
  251.             Begin
  252.             If  S_Down Then
  253.                 Option := Option + 1;
  254.  
  255.             If  S_Up Then
  256.                 Option := Option - 1;
  257.  
  258.             If  S_Enter Then
  259.                 Begin
  260.                 If  Option = 1 Then
  261.                     S_Msg := ' Please read the text in the Option Descript'
  262.                            + 'ion window.';
  263.  
  264.                 If  Option = 2 Then
  265.                     Begin
  266.                     Screen_Mode := 1;
  267.                     S_LoadScreen('Demo_Screen');
  268.  
  269.                     While Not S_F2 Do Process_Screen;
  270.  
  271.                     S_LoadScreen('Demo_Menu');
  272.                     End;
  273.  
  274.                 If  Option = 3 Then
  275.                     Begin
  276.                     Screen_Mode := 2;
  277.                     S_LoadScreen('Demo_Screen');
  278.  
  279.                     While Not S_F2 Do Process_Screen;
  280.  
  281.                     S_LoadScreen('Demo_Menu');
  282.                     End;
  283.  
  284.                 If  Option = 4 Then
  285.                     Begin
  286.                     S_Msg := 'Demo of S_READKEY - Press "C" key to continue';
  287.  
  288.                     Repeat
  289.                         S_ReadKey;
  290.                         S_Msg := 'OOPS!! wrong key - Press "C" key to continue';
  291.                     Until UpCase(S_Ch) = 'C';
  292.  
  293.                     S_Msg := ' "C" has been pressed - You may continue';
  294.                     End;
  295.  
  296.                 If  Option = 5 Then
  297.                     Begin
  298.                     For X := 1 to 6 Do
  299.                         Begin
  300.                         Gotoxy(39,14+X);
  301.                         Write('                                         ');
  302.                         End;
  303.                     gotoxy(39,17);
  304.                     Write('   << OKAY PRESS SHIFT C TO CONTINUE >>');
  305.                     Repeat
  306.                         S_NextKey;
  307.                     Until (S_Shift) and (UpCase(S_Ch)='C');
  308.                     End;
  309.  
  310.                 If  Option = 6 Then
  311.                     Begin
  312.                     TextColor(Black);
  313.                     Y := 1;
  314.                     For X := 1 to 4 Do
  315.                         Begin
  316.                         TextBackground(Y);
  317.                         Y := Y + 1;
  318.                         Window(X*5,(X*2),(X*5)+40,(X*2)+10);
  319.                         ClrScr;
  320.                         Write('This is window ',X:2);
  321.                         Delay(600);
  322.                         End;
  323.                     Window(25,10,65,20);
  324.                     TextColor(White);
  325.                     TextBackground(Y);
  326.                     ClrScr;
  327.                     gotoxy(10,5);Writeln('<<< This is a window >>>');
  328.                     gotoxy(10,7);WriteLn('Press any key to Exit..');
  329.                     S_NextKey;
  330.                     Window(1,1,80,25);
  331.                     TextBackGround(Black);
  332.                     TextColor(Green);
  333.                     S_LoadScreen('Demo_Menu');
  334.                     End;
  335.  
  336.                 If  Option = 7 Then
  337.                     Begin
  338.                     S_Msg := 'Do You want to continue Y/N ';
  339.                     Repeat
  340.                         S_ReadKey;
  341.                         If  UpCase(S_Ch) In ['Y','N'] Then
  342.                             Begin
  343.                             If  UpCase(S_Ch) = 'N' Then
  344.                                 S_Msg := ' How about now..Do you want to continue? Y/N ';
  345.                             End
  346.                         Else
  347.                             S_Msg := '<' + S_Ch + '> Please respond with Y or N';
  348.                     Until UpCase(S_Ch)='Y';
  349.                     S_Msg := 'Ok you may continue';
  350.                     End;
  351.  
  352.                 If  Option = 8 Then
  353.                     Begin
  354.                     Back_To_Turbo_Pascal_Land;
  355.                     S_LoadScreen('Demo_Menu');
  356.                     End;
  357.  
  358.                 If  Option = 9 Then
  359.                     Begin
  360.                     For X := 1 to 6 Do
  361.                         Begin
  362.                         Gotoxy(39,14+X);
  363.                         Write('                                         ');
  364.                         End;
  365.                     gotoxy(39,15);
  366.                     Write('MaxAvail =',MaxAvail:6);
  367.                     gotoxy(39,16);
  368.                     Write('MemAvail =',MemAvail:6);
  369.                     gotoxy(39,19);
  370.                     Write('   << OKAY PRESS ANY KEY TO CONTINUE >>');
  371.                     S_NextKey;
  372.                     End;
  373.  
  374.                 S_ResetKeyFlags;
  375.                 End;
  376.             End
  377.         Else
  378.             S_Msg := ' Only UP and DOWN arrows and ENTER and ESC are valid';
  379.  
  380.     Until (S_Esc)Or(S_UP)Or(S_Down);
  381.  
  382. Until (S_Esc);
  383. End;
  384.  
  385. Begin
  386. ScrDemo_Init;
  387. Read_Menu_Screen;
  388. S_CloseScreenFile;
  389. End.
  390.