home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a075 / 1.img / TOOLKIT1.EXE / SST172.PRG < prev    next >
Encoding:
Text File  |  1989-08-08  |  16.9 KB  |  259 lines

  1. ********************
  2.  
  3. PROCEDURE Gen_code
  4.  
  5.    SET ALTERNATE TO &sstfile
  6.  
  7.    only1_more = .F.
  8.    tdate = DTOC(DATE())
  9.    ttime = TIME()
  10.    DO Writ_it_out WITH "**************************************************", 2
  11.    DO Writ_it_out WITH "* This procedure/program file was generated via  *", 3
  12.    DO Writ_it_out WITH "*                                                *", 3
  13.    DO Writ_it_out WITH "* Steve Straley's ToolkiT(tm) - Release 2        *", 3
  14.    DO Writ_it_out WITH "* Copyright 1989 Stephen J. Straley & Associates *", 3
  15.    DO Writ_it_out WITH "*                All Rights Reserved             *", 3
  16.    DO Writ_it_out WITH "*                                                *", 3
  17.    DO Writ_it_out WITH "*        This message MUST remain within the     *", 3
  18.    DO Writ_it_out WITH "*      general location of the following coded   *", 3
  19.    DO Writ_it_out WITH "*        portion; either in the main header      *", 3
  20.    DO Writ_it_out WITH "*           or within the confines of this       *", 3
  21.    DO Writ_it_out WITH "*                     procedure!                 *", 3
  22.    DO Writ_it_out WITH "*                                                *", 3
  23.    DO Writ_it_out WITH "* Program Name:                                  *", 3
  24.    DO Writ_it_out WITH "*       Author:                                  *", 3
  25.    DO Writ_it_out WITH "*         Date: &tdate.                          *", 3
  26.    DO Writ_it_out WITH "*         Time: &ttime.                          *", 3
  27.    DO Writ_it_out WITH "*                                                *", 3
  28.    DO Writ_it_out WITH "**************************************************", 3
  29.  
  30.    DO Writ_it_out WITH "||PARAMETERS direction||IF PCOUNT() = 0|   print_way = " + LTRIM(TRIM(STR(print_way))), 3
  31.    DO Writ_it_out WITH "ELSE|   IF TYPE('direction') = 'C'|      print_way = VAL(direction)", 3
  32.    DO Writ_it_out WITH "   ELSE|      print_way = direction|   ENDIF|ENDIF", 3
  33.    DO Writ_it_out WITH "print_file = '" + TRIM(sstfile) + "'", 3
  34.    DO Writ_it_out WITH "IF TYPE('sstfile') = 'U'|   sstfile = print_file|ENDIF", 3
  35.    DO Writ_it_out WITH "sststot1 = [" + sststot1 + "]|sststot2 = [" + sststot2 + "]|sststot3 = [" + sststot3 + "]", 3
  36.    DO Writ_it_out WITH "ssttotal1 = [" + ssttotal1 + "]|ssttotal2 = [" + ssttotal2 + "]|ssttotal3 = [" + ssttotal3 + "]", 3
  37.    DO Writ_it_out WITH "sstccnt = " + LTRIM(TRIM(STR(sstccnt))) + "|sst_tog1 = " + IF(sst_tog1, ".T.", ".F."), 3
  38.    DO Writ_it_out WITH "sstfcnt = " + LTRIM(TRIM(STR(sstfcnt))), 3
  39.    DO Writ_it_out WITH "ssthcnt = " + LTRIM(TRIM(STR(ssthcnt))), 3
  40.    DO Writ_it_out WITH "sst_filter = '"  + LTRIM(TRIM(sst_filter)) + "'", 3
  41.    DO Writ_it_out WITH "sstgroup = '" + sstgroup + "'", 3
  42.  
  43.  
  44.    FOR qaz = 1 TO sstccnt
  45.       extt = LTRIM(TRIM(STR(qaz)))
  46.       DO Writ_it_out WITH "STORE [" + sstcon&extt. + "] TO sstcon&extt.", 3
  47.    NEXT
  48.  
  49.    FOR qaz = 1 TO sstfcnt
  50.       extt = LTRIM(TRIM(STR(qaz)))
  51.       DO Writ_it_out WITH "STORE [" + sstfoot&extt. + "] TO sstfoot&extt.", 3
  52.    NEXT
  53.  
  54.    FOR qaz = 1 TO ssthcnt
  55.       tteqw = TRANSFORM(qaz, "9")
  56.       DO Writ_it_out WITH "STORE [" + ssthead&tteqw. + "] TO ssthead&tteqw", 3
  57.    NEXT
  58.  
  59.    DO Writ_it_out WITH "STORE 0.00 TO grand_tot1, grand_tot2, grand_tot3, subtot1, subtot2, subtot3", 3
  60.    DO Writ_it_out WITH "CLEAR SCREEN| |print_header = .T.|row_counter = 10|STORE '0' TO sstpage", 3
  61.  
  62.    ret_area = LTRIM(TRIM(STR(SELECT())))
  63.    FOR qaz = 10 TO 1 STEP -1
  64.       extt = LTRIM(TRIM(STR(qaz)))
  65.       SELECT &extt.
  66.       IF !EMPTY(ALIAS())
  67.          DO Writ_it_out WITH "SELECT &extt.|USE " + UPPERLOWER(ALIAS()), 3
  68.          IF !EMPTY(INDEXKEY(INDEXORD()))
  69.             thekey = INDEXKEY(INDEXORD())
  70.             INDEX ON &thekey. TO Order&extt.
  71.             DO Writ_it_out WITH "IF FILE('Order&extt..N*')|   SET INDEX TO Order&extt.", 3
  72.             DO Writ_it_out WITH "ELSE|   INDEX ON &thekey. TO Order&extt.|ENDIF", 3
  73.          ENDIF
  74.       ENDIF
  75.    NEXT
  76.    SELECT &ret_area.
  77.    DO Writ_it_out WITH "SELECT &ret_area.|SET FILTER TO &" + "sst_filter.", 3
  78.  
  79.    IF !EMPTY(sstgroup + ".grp")
  80.       get_file = sstgname + ".grp"
  81.       IF !EMPTY(sstgname)
  82.          DO Writ_it_out WITH "IF FILE('" + UPPERLOWER(get_file) + "')|   SET INDEX TO " + UPPERLOWER(get_file) + "|ENDIF|set_value = " + IF(EMPTY(sstgroup), "' '", UPPERLOWER(ALIAS()) + "->" + LOWER(sstgroup)), 3
  83.       ENDIF
  84.       DO Writ_it_out WITH "|GO TOP", 3
  85.    ELSE
  86.       DO Writ_it_out WITH "set_value = ''", 3
  87.    ENDIF
  88.    IF EMPTY(AT("EOF()", sst_filter))
  89.       sst_filter = TRIM(sst_filter) + IF(EMPTY(sst_filter), "", " .AND. ") + "!EOF() .AND. CONTINUE()"
  90.    ENDIF
  91.    IF EMPTY(AT("CONTINUE()", sst_filter))
  92.       sst_filter = TRIM(sst_filter) + " .AND. CONTINUE()"
  93.    ENDIF
  94.    sst_filter = FILL_OUT(TRIM(sst_filter), 100)
  95.    DO Writ_it_out WITH "|sstdate = '" + DTOC(DATE()) + "'|ssttime = '" + TIME() +"'", 3
  96.  
  97.    DO Writ_it_out WITH "only1_more = .F.|DO WHILE &sst_filter.", 3
  98.    IF !EMPTY(sstgroup)
  99.       DO Writ_it_out WITH "   only1_more = (" + UPPERLOWER(ALIAS()) + "->" + LOWER(sstgroup) + " <> set_value)", 3
  100.    ENDIF
  101.  
  102.    DO Writ_it_out WITH "|   IF only1_more|      IF !EMPTY(sststot1) .OR. !EMPTY(sststot2) .OR. !EMPTY(sststot3)|         IF print_header", 3
  103.    DO Writ_it_out WITH "            IF !PRINT_CASE()|               RETURN|           ENDIF|           row_counter = 1|           DO P_the_head", 3
  104.    DO Writ_it_out WITH "         ENDIF|         DO End_group|      ENDIF|      set_value = " + IF(EMPTY(sstgroup), "' '", UPPERLOWER(ALIAS()) + "->" + LOWER(sstgroup)), 3
  105.    DO Writ_it_out WITH "      DO Beg_group|      only1_more = .F.|   ENDIF", 3
  106.  
  107.  
  108.    DO Writ_it_out WITH "|   IF print_header|      IF !PRINT_CASE()|         RETURN|      ENDIF", 3
  109.    DO Writ_it_out WITH "|      row_counter = 1|      DO P_the_head|   ENDIF", 3
  110.  
  111.    DO Writ_it_out WITH "|   IF !EMPTY(sstccnt)|      FOR now_try = 1 TO sstccnt|          tteqww = LTRIM(TRIM(STR(now_try)))", 3
  112.    DO Writ_it_out WITH "          outputstr = PRINT_STRI(TRIM(sstcon&tteqww.))", 3
  113.    DO Writ_it_out WITH "          IF LEN(outputstr) > 80 .AND. print_way = 1", 3
  114.    DO Writ_it_out WITH "             ? SUBSTR(outputstr, 1, 79)", 3
  115.    DO Writ_it_out WITH "          ELSE|                ? outputstr|             ENDIF", 3
  116.    DO Writ_it_out WITH "|         FOR y = 1 TO 3|            ny = TRANSFORM(y, '9')|            IF !EMPTY(ssttotal&ny.)", 3
  117.    DO Writ_it_out WITH "               IF !sst_tog1  .OR. (sst_tog1 .AND. ssttotal&ny.$sstcon&tteqww.)", 3
  118.    DO Writ_it_out WITH "                  the_ww_rd = ssttotal&ny.|                     new_value = &the_ww_rd.", 3
  119.    DO Writ_it_out WITH "                  old_value = grand_tot&ny.|                     grand_tot&ny. = old_value + new_value", 3
  120.    DO Writ_it_out WITH "               ENDIF|            ENDIF|               IF !EMPTY(sststot&ny.)", 3
  121.    DO Writ_it_out WITH "|                  IF !sst_tog1  .OR. (sst_tog1 .AND. sststot&ny.$sstcon&tteqww.)", 3
  122.    DO Writ_it_out WITH "                     the_ww_rd = sststot&ny.|                     new_value = &the_ww_rd.", 3
  123.    DO Writ_it_out WITH "                     old_value = subtot&ny.|                     subtot&ny. = old_value + new_value|                  ENDIF", 3
  124.    DO Writ_it_out WITH "               ENDIF|            NEXT|         NEXT|      ENDIF", 3
  125.  
  126.  
  127.    DO Writ_it_out WITH "|   row_counter = row_counter + sstccnt| |   SKIP | |   DO End_routine", 3
  128.    DO Writ_it_out WITH "|   IF LASTKEY() = ASC('Q') .OR. LASTKEY() = ASC('q')|      EXIT", 3
  129.    DO Writ_it_out WITH "   ENDIF| |   IF only1_more|      only1_more = .F.|   ENDIF| |ENDDO", 3
  130.    DO Writ_it_out WITH "|   breakpoint = 80|   only1_more = .T.||   IF LASTKEY() = ASC('Q') .OR. LASTKEY() = ASC('q')|   ELSE", 3
  131.    DO Writ_it_out WITH "|      IF only1_more .AND. (!EMPTY(sststot1) .OR. !EMPTY(sststot2) .OR. !EMPTY(sststot3))", 3
  132.    DO Writ_it_out WITH "|         IF print_header|            IF !PRINT_CASE()|               RETURN", 3
  133.    DO Writ_it_out WITH "|            ENDIF|            row_counter = 1|            DO P_the_head|         ENDIF", 3
  134.    DO Writ_it_out WITH "|         DO End_group|      ENDIF|      DO Tot_check|      IF print_way = 2", 3
  135.    DO Writ_it_out WITH "|         FOR pan_on = 56 TO row_counter STEP -1|            ?|         NEXT", 3
  136.    DO Writ_it_out WITH "|         @ 10,00 CLEAR|         DO Print_foot|         EJECT|      ELSE", 3
  137.    DO Writ_it_out WITH "|         IF print_way = 1|            DO Print_foot|         ENDIF|      ENDIF|   ENDIF", 3
  138.    DO Writ_it_out WITH "||   DO End_way2 WITH 0,0,23,79|   SET FILTER TO", 3
  139.  
  140.    Note : These are for the functions/procedures that make the above loop work!
  141.  
  142.    DO Writ_it_out WITH "|Note:  The Following functions/procedures may be already defined|Note:  if you are using SST_1 as part of your application.", 3
  143.    DO Writ_it_out WITH "Note:  To remove the duplicate symbols at LINK time, just BLOCK|Note:  DELETE everything from this point on.  Re-compile", 3
  144.    DO Writ_it_out WITH "Note:  and re-link the application.", 3
  145.  
  146.    *****************
  147.    * Func Continue
  148.    *****************
  149.  
  150.    DO Writ_it_out WITH "| |********************| |FUNCTION Continue| |   RETURN( !(INKEY() = 27) )", 3
  151.  
  152.    *******************
  153.    * Proc End_routine
  154.    *******************
  155.  
  156.    DO Writ_it_out WITH "| |********************| |PROCEDURE End_routine| |   DO CASE|      CASE print_way = 1", 3
  157.    IF only1_more .AND. (!EMPTY(sststot1) .OR. !EMPTY(sststot2) .OR. !EMPTY(sststot3))
  158.       DO Writ_it_out WITH "         bounce_off = 14|", 3
  159.    ELSE
  160.       DO Writ_it_out WITH "         bounce_off = 18|", 3
  161.    ENDIF
  162.    DO Writ_it_out WITH "         IF row_counter >= bounce_off", 3
  163.    DO Writ_it_out WITH "            print_header = .T.|            DO Print_foot|            @ 24,00 SAY 'Press Any Key or Q to Quit...'|            QWAIT('Q')", 3
  164.    DO Writ_it_out WITH "         ENDIF|      CASE print_way = 2", 3
  165.    IF !EMPTY(sststot1) .OR. !EMPTY(sststot2) .OR. !EMPTY(sststot3)
  166.       DO Writ_it_out WITH "         bounce_off = 52|", 3
  167.    ELSE
  168.       DO Writ_it_out WITH "         bounce_off = 58|", 3
  169.    ENDIF
  170.    DO Writ_it_out WITH "         IF row_counter >= 58|            print_header = .T.", 3
  171.    DO Writ_it_out WITH "            DO Print_foot|            EJECT|         ENDIF|      CASE print_way = 3|   ENDCASE", 3
  172.  
  173.    *******************
  174.    * Proc Print_foot
  175.    *******************
  176.  
  177.    DO Writ_it_out WITH "| |********************| |PROCEDURE Print_foot| |   ?", 3
  178.    DO Writ_it_out WITH "|IF !EMPTY(sstfcnt)", 3
  179.    DO Writ_it_out WITH "|   FOR now_try = 1 TO " + LTRIM(TRIM(STR(sstfcnt))), 3
  180.    DO Writ_it_out WITH "      tteqww = TRANSFORM(now_try, '9')", 3
  181.    DO Writ_it_out WITH "      outputstr = PRINT_STRI(TRIM(sstfoot&tteqww.))", 3
  182.    DO Writ_it_out WITH "      IF LEN(outputstr) > 80 .AND. print_way = 1", 3
  183.    DO Writ_it_out WITH "            ? SUBSTR(outputstr, 1, 79)|          ELSE|             ? outputstr", 3
  184.    DO Writ_it_out WITH "         ENDIF|    NEXT|ENDIF", 3
  185.  
  186.    *******************
  187.    * Func Print_str
  188.    *******************
  189.  
  190.    DO Writ_it_out WITH "| |********************| |FUNCTION Print_stri| |   PARAMETER ye_old_it| |   x_times = OCCURENCE(CHR(174), ye_old_it)", 3
  191.    DO Writ_it_out WITH "|   IF EMPTY(x_times)|      RETURN(ye_old_it)|   ENDIF|   FOR go_th_it = 1 TO x_times|      f_stop = AT(CHR(174), ye_old_it)", 3
  192.    DO Writ_it_out WITH "      b_stop = AT(CHR(175), ye_old_it)|      front_it = SUBSTR(ye_old_it, 1, f_stop-1)|      mid_it = SUBSTR(ye_old_it, f_stop  + 1, b_stop-1-f_stop)", 3
  193.    DO Writ_it_out WITH "      rest_it = SUBSTR(ye_old_it, b_stop+1)|      IF '->'$mid_it|         new_it = &" + "mid_it|         ye_old_it = front_it + STRVALUE(new_it) + rest_it", 3
  194.    DO Writ_it_out WITH "      ELSE|         ye_old_it = front_it +  STRVALUE(&" + "mid_it) +  rest_it|      ENDIF|   NEXT|   RETURN(ye_old_it)| |********************", 3
  195.  
  196.    *******************
  197.    * Func Occurence
  198.    *******************
  199.  
  200.    DO Writ_it_out WITH "| |FUNCTION Occurence| |   PARAMETERS astring, bstring| |   return_cnt = 0| |   DO WHILE !EMPTY(AT(astring, bstring))", 3
  201.    DO Writ_it_out WITH "      return_cnt = return_cnt + 1|      bstring = SUBSTR(bstring, AT(astring, bstring) + 1)|   ENDDO| |   RETURN(return_cnt)", 3
  202.  
  203.    ******************
  204.    * Func Strvalue
  205.    ******************
  206.  
  207.    DO Writ_it_out WITH "| |********************| |FUNCTION Strvalue| |   PARAMETERS showstring| |   DO CASE|   CASE TYPE('showstring') = 'C'", 3
  208.    DO Writ_it_out WITH "      RETURN(showstring)|   CASE TYPE('showstring') = 'N'|      RETURN(STR(showstring))|   CASE TYPE('showstring') = 'M'|      RETURN(' ')", 3
  209.    DO Writ_it_out WITH "   CASE TYPE('showstring') = 'D'|      RETURN(DTOC(showstring))|   OTHERWISE|      RETURN(IF(showstring, 'True', 'False'))|   ENDCASE", 3
  210.  
  211.    ******************
  212.    * Func Print_case
  213.    ******************
  214.  
  215.    DO Writ_it_out WITH "| |********************| |FUNCTION Print_case| |    DO CASE|       CASE print_way = 1", 3
  216.    DO Writ_it_out WITH "|          @ 0,0 CLEAR|       CASE print_way = 2|          SET PRINT OFF|          SET CONSOLE ON", 3
  217.    DO Writ_it_out WITH "|          IF TYPE('_a_scr') = 'U'|             PUBLIC _a_scr|             _a_scr = SAVESCREEN(10,10,12,70)|          ELSE", 3
  218.    DO Writ_it_out WITH "|             RESTSCREEN(10,10,12,70,_a_scr)|          ENDIF|          @ 10,10 CLEAR TO 12,70", 3
  219.    DO Writ_it_out WITH "|          @ 10,10 TO 12,70 DOUBLE|          IF ISPRINTER()|             @ 11,25 SAY 'Printing Out Report.  One Moment!'|          ELSE", 3
  220.    DO Writ_it_out WITH "|             @ 11,18 SAY 'Your Printer is OFF LINE.  Any key to Continue'|             INKEY(0)|             RESTSCREEN(10,10,12,70,_a_scr)", 3
  221.    DO Writ_it_out WITH "|             RETURN(.F.)|          ENDIF|          SET CONSOLE OFF|          SET PRINT ON|       CASE print_way = 3|          SET CONSOLE ON", 3
  222.    DO Writ_it_out WITH "|          @ 0,0 CLEAR|          @ 10,10 TO 12,70 DOUBLE|          @ 11,15 SAY 'Printing Out Report ==> ' + TRIM(sstfile) + '.  One Moment!'", 3
  223.    DO Writ_it_out WITH "|          print_file = TRIM(sstfile)|          SET CONSOLE OFF|          SET ALTERNATE ON|          SET ALTERNATE TO &print_file.|    ENDCASE|    RETURN(.T.)", 3
  224.  
  225.  
  226.    ********************
  227.    * Func Parsing
  228.    ********************
  229.  
  230.    DO Writ_it_out WITH "|********************||FUNCTION Parsing||   PARAMETERS getstring, for_code||   IF PCOUNT() = 1", 3
  231.    DO Writ_it_out WITH "      for_code = .F.|   ENDIF||   IF for_code|      whereat   = AT(CHR(124), getstring)|   ELSE", 3
  232.    DO Writ_it_out WITH "|      whereat   = IF(EMPTY(AT('+', getstring)), AT('/', getstring), AT('+', getstring))", 3
  233.    DO Writ_it_out WITH "|   ENDIF|   newstring = IF(!EMPTY(whereat), SUBSTR(getstring, 1, whereat - 1), getstring)", 3
  234.    DO Writ_it_out WITH "|   getstring = IF(!EMPTY(whereat), SUBSTR(getstring, whereat + 1), '')", 3
  235.    DO Writ_it_out WITH "|   RETURN(newstring)", 3
  236.  
  237.    ********************
  238.    * Proc End_way2
  239.    ********************
  240.  
  241.    DO Writ_it_out WITH "********************|PROCEDURE End_way2||   PARAMETERS line_no, the_cent, a_row, a_col, a_row2, a_col2", 3
  242.    DO Writ_it_out WITH "   IF PCOUNT() = 4|      a_row2 = a_row|      a_col2 = a_col|   ENDIF||   DO CASE|   CASE print_way = 1", 3
  243.    DO Writ_it_out WITH "      @ 24,00 SAY 'End of Report.  Press Any key to RETURN               '|      INKEY(0)|   CASE print_way = 2", 3
  244.    DO Writ_it_out WITH "      SET CONSOLE OFF|      SET PRINT ON|      IF the_cent > 0|         skipping = breakpoint|         DO WHILE skipping <= 55", 3
  245.    DO Writ_it_out WITH "            ?|            skipping = skipping + 1|         ENDDO|         IF LASTKEY() = 27|            ? MESS_CENT('Partial Report Printed', the_cent)", 3
  246.    DO Writ_it_out WITH "         ELSE|            ? MESS_CENT('End of Report', the_cent)|         ENDIF|         EJECT|         IF screject", 3
  247.    DO Writ_it_out WITH "            EJECT|         ENDIF|      ENDIF|      SET CONSOLE ON|      SET PRINT OFF|      DO Clear_area WITH a_row-1, a_col-5, a_row+3, a_col+65", 3
  248.    DO Writ_it_out WITH "      SAVE SCREEN|      @ a_row, a_col - 5 TO a_row + 2, a_col + 60 DOUBLE|      @ a_row + 1, a_col SAY 'Requested Information has been Printed.  Any Key to RETURN'", 3
  249.    DO Writ_it_out WITH "      INKEY(0)|      RESTORE SCREEN|   OTHERWISE|      IF TYPE('the_cent') = 'U'|         the_cent = 0|      ENDIF", 3
  250.    DO Writ_it_out WITH "      IF the_cent > 0|         ?|         ?|         ? MESS_CENT('End of Report', the_cent)|      ENDIF||      SET ALTERNATE OFF", 3
  251.    DO Writ_it_out WITH "      SET ALTERNATE TO|      CLOSE ALTERNATE|      SET CONSOLE ON|      SAVE SCREEN|      SCROLL(a_row, a_col, a_row + 2, a_col + 60, 0)", 3
  252.    DO Writ_it_out WITH "      @ a_row, a_col TO a_row + 2, a_col + 60 DOUBLE|      say_what = TRIM(print_file) + ' is now on the disk.  Any key to RETURN'", 3
  253.    DO Writ_it_out WITH "      @ a_row + 1, CENTER(say_what, 30) + a_col SAY say_what|      INKEY(0)|      RESTORE SCREEN|   ENDCASE", 3
  254.  
  255.    DO Writ_it_out WITH "", 4   && Close the window display
  256.    CLOSE ALTERNATE
  257.  
  258. * End of File
  259.