home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / SCREDIT2.ZIP / SKELETON.DOC < prev    next >
Encoding:
Text File  |  1988-12-22  |  12.3 KB  |  336 lines

  1.    This program file is the skeleton code used by Turbo ScrEdit when it
  2.    generates the programs that access the screens in a screen file.
  3.  
  4.    You may modify this file if you wish. DO NOT change any line that has
  5.    words surrounded by "**". Turbo ScrEdit Locates these key words and
  6.    replaces them with code needed for the screen files. You may change
  7.    anything else that you wish.
  8.  
  9.    The discussion that follows will help you understand the way Turbo
  10.    ScrEdit uses this code. The source code in this file has been divided
  11.    into sections with labels surrounded by "**". In the text that follows
  12.    I will describe the code that is inserted by Turbo ScrEdit following
  13.    each of these labels. As you read the descriptions that follow, locate
  14.    each label in the code below.
  15.  
  16. *Version*
  17.  
  18.    For Pascal:
  19.  
  20.    This section is where a $INCLUDE or USES statement is placed depending
  21.    on the compiler that you select during source code generation. If you
  22.    are using Turbo Pascal 4.0 or 5.0 a USES statement is placed here that
  23.    will use the file ScrEd40.pas to compile the unit file ScrEd40.TPU. If
  24.    you are using Turbo Pascal 3.0 then a $include statement will include
  25.    the source file ScrEd30.pas at compile time.
  26.  
  27.    In either case the code used here contains all the procedures required
  28.    to open, process, and close screen files.
  29.  
  30.    For C:
  31.  
  32.    This section is where a #include statement is placed. The code placed
  33.    here contains all the procedures required to open, process, and close
  34.    screen files.
  35.  
  36.  
  37. *Buffers*
  38.  
  39.    When you create a screen using Turbo ScrEdit, a small file that contains
  40.    the record definition and screen initialization procedures is created.
  41.  
  42.    This is where the screen buffers and initialization procedures will be
  43.    placed. Turbo ScrEdit allows you to select whether the buffer modules
  44.    are to be copied into the code at this point or included at compile time
  45.    by using $include or #include statements.
  46.  
  47.  
  48. *User Variables*
  49.  
  50.    Turbo ScrEdit will not place any additional code here. You may define
  51.    your program's global variables and procedures beginning here.
  52.  
  53.  
  54. * Example of loading and displaying screens *
  55.  
  56.   The entire procedure "Load_Screen" is intended to illustrate how to load
  57.   and display screens in a screen file. You will probably want to delete
  58.   this procedure and copy the "S_LoadScreen" statements into your own
  59.   procedures.
  60.  
  61.   You may convert this into a working procedure for your programs by
  62.   changing the procedure to:
  63.  
  64.   For Pascal:
  65.  
  66.       Procedure Load_Screen;
  67.       Begin
  68.       Case S_Num of
  69.  
  70.         Don't change anything between Case and End;
  71.  
  72.         End;
  73.       End;
  74.  
  75.  
  76.   For C:
  77.  
  78.       void Load_Screen();
  79.       {
  80.       switch (S_Num)
  81.         {
  82.  
  83.         Don't change anything between switch and };
  84.  
  85.         }
  86.       }
  87.  
  88.   If you make this change you can load a screen by assigning "S_Num" the
  89.   screen number from the case statement that corresponds to the screen name
  90.   that you want loaded. Be aware that Turbo ScrEdit will change the value
  91.   of S_Num to the actual screen number in the screen file index.
  92.  
  93.   ** NOTE ** the field S_Num is defined in ScrEd30.pas or ScrEd40.tpu.
  94.   All of the fields that have been defined for use with Turbo ScrEdit
  95.   procedures start with "S_". Try not to use the "S_" naming convention
  96.   in your programs to avoid having conflicts with Turbo Scredit.
  97.  
  98.  
  99.  
  100. *ScreenFileName*
  101.  
  102.    Turbo ScrEdit places the statement here that will  open the screen file.
  103.  
  104.    An important thing to know about this call is that it turns the system
  105.    cursor off. If the program ends abnormally the cursor may be left off.
  106.    To insure that the cursor is not left off, always call S_CloseScreenFile.
  107.    S_CloseScreenFile is documented ahead in this document.
  108.  
  109.  
  110. *InitRoutines*
  111.  
  112.    After the screen file is opened the screen buffer initialization
  113.    procedures must be performed. There will be a procedure for each of the
  114.    screens that were selected in the screen file when the source code was
  115.    generated.
  116.  
  117.    ** IMPORTANT NOTE ** if for some reason the initialization procedures are
  118.    not performed, your program will malfunction. Data will not be moved to
  119.    and from the screen properly. In some cases your program will hang the
  120.    system because data is being move to a memory location pointed to by
  121.    memory pointers that have incorrect values. In most cases if you have
  122.    problems using Turbo ScrEdit this will be the cause.
  123.  
  124.  
  125. *System Switches*
  126.  
  127.   Turbo ScrEdit allows you to customize some features. You may change
  128.   the values of these fields any time you wish in your program.
  129.  
  130.  
  131.   S_Sound      + When set to TRUE will cause Turbo ScrEdit to Issue a
  132.                  tone of (S_Freq) frequency and (S_Dur) duration.
  133.                - When set to FALSE, no sounds will be issued no matter
  134.                  what the values of (S_Freq) and (S_Dur) may be.
  135.   S_Freq         Sound frequency
  136.   S_Dur          Duration of tone
  137.  
  138.   S_ShowStatus + When TRUE, Turbo ScrEdit will display the status of the
  139.                  keyboard switches INSERT, CAPS, NUMLOCK, and SCROLL LOCK
  140.                  on the bottom line (25th) of the screen. The Status line
  141.                  will be updated each time you call S_ReadField, S_ReadKey,
  142.                  or S_ReadScreen.
  143.                - When FALSE, No status line is displayed.
  144.  
  145.   S_Cursor     : This switch has three settings that can be used to define
  146.                  the type of system cursor used in data entry fields.
  147.                  S_Normal = Normal underline cursor.
  148.                  S_Bold   = Block size cursor.
  149.                  S_Off    = System cursor is removed from the screen and
  150.                             a non blinking block cursor is used.
  151.  
  152.   S_Point      : Is used as an index of the screen fields.
  153.                  Data entry will begin at the field pointed to by
  154.                  S_Point. See the discussion of S_READSCREEN and
  155.                  S_READFIELD for more information.
  156.  
  157.   S_Msg        : Is a string variable that can contain a string of up
  158.                  to 78 characters. Any string of characters assigned to
  159.                  this variable will be displayed on the bottom line of the
  160.                  screen with the next call to S_READSCREEN, S_READFIELD, or
  161.                  S_READKEY. After the call S_Msg is returned as null string.
  162.  
  163.  
  164. * 1st Example Code *
  165.  
  166.   This code initializes the pointers used to control the next screen to be
  167.   loaded by the demonstration part of this program. You will want to delete
  168.   these lines when you build your own program.
  169.  
  170.  
  171. There are three methods supported by Turbo ScrEdit to process your screens.
  172.  
  173.   S_READKEY    - returns a single key stroke in S_Ch and/or sets key flags.
  174.   S_READFIELD  - reads data into one field on the screen and sets key flags.
  175.   S_READSCREEN - reads data into all the data entry fields on a screen and
  176.                  sets key flags.
  177.  
  178.  
  179. * Demo Mode 2 * demonstrates S_READFIELD.
  180.  
  181.   This code is intended to illustrate how to read a single field at a time.
  182.   When your program needs to have control between each field that the user
  183.   keys you can use this method. Most of what you see in this code can be
  184.   removed when you use it in a program. The Code that you would use will
  185.   look like this:
  186.  
  187.   For Pascal:
  188.  
  189.        S_Point := field number;
  190.  
  191.        S_READFIELD;
  192.  
  193.   For C:
  194.  
  195.        S_Point = field number;
  196.  
  197.        S_ReadField();
  198.  
  199.  
  200.   The field number that S_POINT is assigned can be found on the screen
  201.   listing that is produced using the F5 option of Turbo ScrEdit's main
  202.   menu, or if you don't have a printer you can number the fields with
  203.   paper and pencil. Fields are numbered left to right and top to bottom.
  204.  
  205.   When you call S_READFIELD a number of things happen.
  206.  
  207.   - If you have set S_POINT to a display only field an error message will
  208.     be displayed. Remember when you use this method of processing a screen
  209.     you are taking responsibility to direct Turbo ScrEdit to the field that
  210.     you want used.
  211.  
  212.   - Any values that have been moved to fields in the screen record are
  213.     displayed on the screen.
  214.  
  215.   - If the field S_Msg has been assigned a message it is displayed on
  216.     the bottom line of the screen.
  217.  
  218.   - Turbo ScrEdit then prompts the user to enter data into the field.
  219.  
  220.   Turbo ScrEdit will continue to accept keystrokes into the field until
  221.   one of the following occurs:
  222.  
  223.   1 - Any of the special keys are pressed. See the section labeled
  224.       "* special key testing *" for more info on what special keys are.
  225.  
  226.   2 - The Field is filled with keystrokes.
  227.  
  228.   3 - The Left or Right arrows are used to move the cursor off either
  229.       end of the field.
  230.  
  231.   4 - The ENTER key is pressed.
  232.  
  233.   The field validation statements that are assigned to a field will only
  234.   be used to test the contents of a field when conditions 2, 3, or 4 occur.
  235.  
  236.   * NOTE * remember that when the special keys are pressed, data entry
  237.   ends and Turbo ScrEdit returns immediately to your program. Don't use
  238.   the data returned in the field unless your program verifies that it
  239.   is valid data. Keep in mind the only three conditions described above
  240.   that Turbo ScrEdit will validate the data using processing
  241.   specifications.
  242.  
  243.  
  244. * Demo mode 0 or 1 * demonstrates S_READSCREEN
  245.  
  246.   The if statement here is only needed to make the example of using
  247.   S_READSCREEN work in the demonstration mode 0 or 1. Your working code
  248.   will look like this:
  249.  
  250.   For Pascal:
  251.  
  252.       S_READSCREEN;
  253.  
  254.   For C:
  255.  
  256.       S_ReadScreen();
  257.  
  258.   When you call S_READSCREEN a number of things happen.
  259.  
  260.   - Any values that have been moved to fields in the screen record are
  261.     displayed on the screen.
  262.  
  263.   - If the field S_Msg has been assigned a message it is displayed on
  264.     the bottom line of the screen.
  265.  
  266.   - If S_Point has been assigned a screen field number, data entry will
  267.     begin on the specified field. If S_Point is set to a display only field
  268.     or a non-existent field, Turbo ScrEdit will advance to the next data
  269.     entry field on the screen.
  270.  
  271.     If the screen has no  fields Turbo ScrEdit calls S_READKEY and will
  272.     return when the next key is pressed. The value of the key pressed is
  273.     returned in the character field S_Ch.
  274.  
  275.     If the screen has only "display only" fields on it Turbo ScrEdit will
  276.     call S_READKEY and return when the next key is pressed.
  277.  
  278.     If the screen has data entry fields on it, Turbo ScrEdit will accept
  279.     data into the fields until a special keystroke is detected. See
  280.     "* special key testing *" for more info on what special keys are.
  281.  
  282.   - When the ENTER key is pressed the entire screen is returned to your
  283.     program. Any field validation specifications that have been defined
  284.     for the fields on the screen are only considered when ENTER is pressed.
  285.  
  286.   When Turbo ScrEdit returns to your program from this call, S_Point will
  287.   be set to zero for Pascal or -1 for C.
  288.  
  289.  
  290. * Example code for demonstration mode * demonstrates S_READKEY.
  291.  
  292.   This code can be deleted and is only used to demonstrate using S_READKEY
  293.   and providing a generic way of switching screens.
  294.  
  295.   In most cases you will use S_READKEY to prompt your user for a response.
  296.   You could do something like this:
  297.  
  298.      Repeat
  299.          S_Msg := 'Delete this record Y/N';
  300.          S_ReadKey;
  301.      Until UpCase(S_Ch) In['Y','N'];
  302.  
  303.   In this example several things happen:
  304.  
  305.   - The contents of the screen record are moved to the screen.
  306.  
  307.   - The message assigned to S_MSG is displayed on the bottom line of
  308.     the screen.
  309.  
  310.   - Turbo ScrEdit waits until a key is pressed, and then returns the
  311.     keystroke in S_CH.
  312.  
  313.   This example will continue prompting and displaying the message until
  314.   either "Y" or "N" is pressed.
  315.  
  316.   S_READKEY does not have any connection with screen fields, the key pressed
  317.   is returned to your program but not displayed on the screen.
  318.  
  319.  
  320.  
  321. * Special Key Testing *
  322.  
  323.   This code demonstrates the entire spectrum of special key strokes and
  324.   combinations of key strokes that you can test for. The best way to
  325.   understand this code is to try each condition as you run a program.
  326.  
  327.  
  328. * Closing the screen file *
  329.  
  330.   If your program ends without closing the screen file the system cursor
  331.   will be left off.
  332.  
  333.   If your program executes another program, close the file before executing
  334.   the next program, and reopen the screen file when control returns.
  335.  
  336.