home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / JJB.ZIP / JJBSHOW4.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-20  |  12.8 KB  |  248 lines

  1. /**************************************************************************
  2.  *                                                                        *
  3.  *                           JJBSHOW4.C                                   *
  4.  *                                                                        *
  5.  *   Copyright (c) 1988, 1989, JJB. All rights reserved.                  *
  6.  *                                                                        *
  7.  *   The purpose of JJB is to help you to write programs as quickly       *
  8.  *   as possible. JJB handles things for you and provides you with        *
  9.  *   an environment which allows you to concentrate on the functions      *
  10.  *   of your program.                                                     *
  11.  *                                                                        *
  12.  *   This example shows you how to use the following functions:           *
  13.  *                                                                        *
  14.  *      jjb_initalize()            initalizes JJB.                        *
  15.  *      jjb_setup()                sets up the JJB option arrays.         *
  16.  *      jjb_start()                begins executing the default option.   *
  17.  *                                                                        *
  18.  *      group(group description)   start setting up a group of options &  *
  19.  *                                  assign a description to the group.    *
  20.  *                                                                        *
  21.  *      option(option description) sets up an option.                     *
  22.  *                                                                        *
  23.  *      funct(function name)       assigned a function to the option.     *
  24.  *      default_opt()              assigns default to an option           *
  25.  *      help(functionname)        assigns a function to F1 help.          *
  26.  *                                                                        *
  27.  *    Turbo C is a trademark of Borland International, Inc.               *
  28.  *    Quick C is a trademark of Microsoft Corp.                           *
  29.  *    JJB, 9236 church Rd suite 1082, Dallas, Tx 75231 (214) 341-1635     *
  30.  **************************************************************************/
  31.  
  32.  
  33. /***************************************************************************
  34.  * For Turbo C programmers only:                                           *
  35.  *   To run this program from DOS:                                         *
  36.  *                                                                         *
  37.  *         Enter 'TC JJBSHOW4'    ( to load this file with Turbo C)        *
  38.  *         Press 'CTRL F9'        ( to compile and begin executing)        *
  39.  *                                                                         *
  40.  ***************************************************************************/
  41.  
  42. /***************************************************************************
  43.  * for Quick C programmers only:                                           *
  44.  *   To run this program, from DOS:                                        *
  45.  *                                                                         *
  46.  *         Enter 'JJBQCS4'    ( to load this file with JJB.QLB)            *
  47.  *         Press 'F5'         ( to compile and begin executing)            *
  48.  *                                                                         *
  49.  *   To make the .exe file JJBSHOW4.EXE, from DOS enter:                   *
  50.  *         QCL  /c  /AM  JJBSHOW4.C                                        *
  51.  *         LINK  JJBSHOW4.OBJ + JJBQC.OBJ + JJBQCINP.OBJ ,,, C:LIB\,       *
  52.  *                                                                         *
  53.  ***************************************************************************/
  54.  
  55. /***************************************************************************
  56.  *                                                                         *
  57.  * for both TURBO C and QUICK C programmers:                               *
  58.  *                                                                         *
  59.  * Not all options have been assigned functions. The options unassigned    *
  60.  * execute the JJB copyright function.                                     *
  61.  *                                                                         *
  62.  * As JJB executes (runs) a program, the following keys can be pressed:    *
  63.  *                                                                         *
  64.  *    ALT X     to exit.                                                   *
  65.  *    F1        to display a help screen.                                  *
  66.  *    F2-F9     to instantly select another option.                        *
  67.  *    ALT       to select a group of options.                              *
  68.  *    ALT       and a letter to select a specific group.                   *
  69.  *    ESC       means nevermind.                                           *
  70.  *       ->        to select the group to the right.                       *
  71.  *       <-        to select the group to the left.                        *
  72.  *       UPARROW   to highlight the option above.                          *
  73.  *       DOWNARROW to highlight the option below.                          *
  74.  *       RETURN    to select the option highlighted.                       *
  75.  *       A LETTER  to select a specific option.                            *
  76.  *       ALT and a letter to select a different group.                     *
  77.  *       ESC       return exactly where you were in the function           *
  78.  *                      currently being executed.                          *
  79.  *                                                                         *
  80.  * If another option is selected, JJB will execute:                        *
  81.  *                                                                         *
  82.  *         the leave function for the current option.                      *
  83.  *         the leave function for the current group.                       *
  84.  *         the initalization function for the selected group.              *
  85.  *         the initalization function for the selected option.             *
  86.  *         and option function.                                            *
  87.  *                                                                         *
  88.  ***************************************************************************/
  89.  
  90. /* see JJB-READ.DOC for an additional explanation of the functions below.  */
  91.  
  92. #include <jjbkbd.h>
  93. #include <jjbset.h>
  94.  
  95. main() {
  96.  
  97.   jjb_initalize();      /* initalize JJB arrays and video screen */
  98.  
  99.   jjb_setup();          /* set up the options */
  100.  
  101.   jjb_start();          /* start executing the default option   */
  102.  
  103.   }
  104.  
  105.  
  106. /****************************************************************************
  107.  *                                                                          *
  108.  *                        sample_function()                                 *
  109.  *                                                                          *
  110.  *   This is a sample function which is assigned to the options             *
  111.  *   to show you how functions can be executed when you select              *
  112.  *   an option.                                                             *
  113.  *                                                                          *
  114.  *   if you do not assign a function to each option, JJB will initalize     *
  115.  *                                                                          *
  116.  *   each option with a null function which just gets a character.          *
  117.  *                                                                          *
  118.  ****************************************************************************/
  119.  
  120.  
  121. /* Below is just a sample of some of the video fast 'vf' functions          */
  122. /*   you will be able to use in the JJB library, see JJBREAD.ME             */
  123.  
  124. /* 'vfs(string)'         video fast a string direct to video memory.        */
  125. /* 'vfsdo(string,2,14)'  sets up all subsequent 'vfsdo' down 2 over  14     */
  126. /* 'vfsdo(string,SAME)'  does 2 carr. rets and goes over to column 14       */
  127. /* All the 'vf' functions are portable and work for all video controllers   */
  128. /* 'vfsc(string)' places physical cursor after putting out string.          */
  129.  
  130.  
  131. /* 'vfwc' puts out a window centered on the screen. It is not used in this
  132.        source. 'vfwc(50,14);' will center a box 50 positions wide, 14 deep.*/
  133.  
  134. vfwc(width,depth) int width,depth; { int row,col;
  135.     row = (25 - depth) / 2;   /* compute row for making the window  */
  136.     col = (80 - width) / 2;   /* compute col for making the window  */
  137.     vfw(row,col,width,depth); /* now make the window                */
  138.     }
  139.  
  140.  
  141. int scr1_arry[2000];
  142.  
  143. sample_help() {
  144.      vsave_scr(&scr1_arry);  /* save the screen   */
  145.      set_color(RED ONBLUE);
  146.      vfw(6,11,64,14);
  147.  
  148.      vloc(8,14);      /* position for video fast functions */
  149.  
  150.     /* 'vfsdo(' videos fast a string and then does a carriage ret.
  151.        '2,14' sets up all subsequent to come down two and over 14. */
  152.  
  153.      vfsdo("F1 is reserved for help.",2,14);
  154.  
  155.      vfsdo("You can set up a function and call it by using the F1 key.",SAME);
  156.      vfsdo("JJB will use whatever function you assign in jjb_setup().",SAME);
  157.      vfsdo("In this example, jjb_setup assigns sample_help() as follows:",SAME);
  158.      vfsdo("      'help(sample_help);'",3,14);
  159.      vfsc( pak() );     /* video fast 'Press any key'and put cursor after  */
  160.      getch();           /* getch() is ok here.                             */
  161.      normal();
  162.      vrest_scr(&scr1_arry);    /* restore the screen                              */
  163.      }
  164.  
  165. sample_function()  {  char str[31]; char *sp = "  "; int tab = 8;
  166.  
  167.  vloc(4,8);        /* prepare for a video fast at row 4, column 8  */
  168.  vfsdo("Look at the file JJBSHOW4.C to see how JJB works.",2,tab);
  169.  vfsdo("JJB may be used for any programming application.",SAME);
  170.  vfs("JJB LA (Large Application)");
  171.  vfsdo(" is to be released in the spring of 1989.",3,tab);
  172.  vfsdo("At any time while typing, you may press ALT and change options.",2,tab);
  173.  vfs("The option selected is displayed in bottom left corner.");
  174.  
  175.    while (1)
  176.       {
  177.   /* see JJBSHOW5.C for an example of how you can use the enter   */
  178.   /* functions to input entire screens of data.                   */
  179.  
  180.   enter(16,20,"Enter a string ",&str[0],30,16,36);
  181.   enter(18,20,"Press any key  ",&str[0],1,ATEND);
  182.  
  183.   vloc(18,20); vspaces(55);   /* clear press any key.    */
  184.  
  185.  
  186.     }
  187. }
  188.  
  189.  
  190. /****************************************************************************
  191.  *                                                                          *
  192.  *                       jjb_setup()                                        *
  193.  *                                                                          *
  194.  *   jjb_setup() is where you set up all your program option descriptions   *
  195.  *      and assign function names to each option.                           *
  196.  *                                                                          *
  197.  ****************************************************************************/
  198.  
  199. /*  The groups and options descriptions being set up have no meaning.      */
  200. /*  Any description can be chosen.                                         */
  201. /*  Try changing them and see what happens when you press 'F5'.            */
  202. /*  Some of the options below do not have a function assigned to them.     */
  203. /*  To keep this example simple, more than one function is assigned to     */
  204. /*     the sample function. Normally, you would not assign a function      */
  205. /*     to more than one option.                                            */
  206. /*                                                                         */
  207.  
  208. jjb_setup() {
  209.  
  210.   group("Application");          /* this starts a group of options */
  211.  
  212.       option("Applications Test #1");
  213.           funct(sample_function);
  214.       option("Applications 'V'ideo Test");
  215.           funct(sample_function);
  216.  
  217.       option("Applications 'D'isk  Test");
  218.           funct(sample_function);
  219.           default_opt();   /* start with this option          */
  220.  
  221.       option("C'o'mmunicatyion Test");
  222.           funct(sample_function);
  223.  
  224.  
  225.   group("Reports");          /* this starts a group of options */
  226.  
  227.       option("General ledger F7");    /* assign F7 to this option */
  228.       option("Trial Balance");
  229.           funct(sample_function);
  230.       option("Chart of Accounts Report");
  231.           funct(sample_function);
  232.       option("Profit & Loss");
  233.           funct(sample_function);
  234.       option("Balance Sheet",DRAWLINE); /* DRAWLINE separates */
  235.           funct(sample_function);
  236.       option("More Reports");
  237.           funct(sample_function);
  238.  
  239.   group("More");
  240.       option("Miscellaneous Options");
  241.       option("Month-end Closing");
  242.  
  243.   help(sample_help);
  244.  
  245.   }
  246.  
  247.  
  248.