home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a040 / 2.ddi / SHRWARE4.ARC / MSAAPPE.INC < prev    next >
Encoding:
Text File  |  1988-06-03  |  7.2 KB  |  294 lines

  1. <<* MSAAPPE.INC *>>
  2. <<#
  3.  
  4. function fixfldini : string
  5. string strg
  6. begin
  7.   strg := fldini
  8.   if fldtyp = 'C'
  9.     if not (strg[1] $ '["'+"'")
  10.       strg := '"' + strg + '"'
  11.     endif
  12.   elsif fldtyp = 'L'
  13.     if strg[1] <> '.'
  14.       strg := '.' + strg + '.'
  15.     endif
  16.   endif
  17.   RETURN strg
  18. end fixfldini
  19.  
  20.  
  21. procedure GenInitFlds
  22. begin
  23.   select all
  24.   genln( '* ---Initialize fields/memvars.' )
  25.   if not ismultials
  26.     select database 1
  27.     select fields on fldini and (fldtyp $ 'CDLN')
  28.     if fldtotal > 0
  29.       forall fields
  30.         genln( 'STORE ',fixfldini,' TO ',fixfldnam )
  31.       endfor
  32.     else
  33.       genln( '* ---<none>.' )
  34.     endif
  35.   else
  36.     genln( 'DO CASE' )
  37.     forall databases
  38.       filespec( dbfnam,fpath,fname,fext )
  39.       genln( 'CASE dbfarea = "',dbfcount,'"' )
  40.       pushmargin( 1 )
  41.       select fields on fldini and (fldtyp $ 'CDLN')
  42.       if fldtotal > 0
  43.         forall fields
  44.           genln( 'STORE ',fixfldini,' TO ',fixfldnam )
  45.         endfor
  46.       else
  47.         genln( '* ---<none>.' )
  48.       endif
  49.       popmargin
  50.     endfor
  51.     genln( 'ENDCASE' )
  52.   endif
  53. end GenInitFlds
  54. #>>
  55.  
  56.  
  57. <<procedure AppendPages>>
  58. <<begin>>
  59. * ---Edit and page through the record.
  60. * ---The following loop is really a "REPEAT/UNTIL <cond>".
  61. DO WHILE .T.
  62.    DO StatLine WITH LastRec+recnumOFS,IsDeleted
  63.    @ 0,50 SAY "*BLANK*  "
  64.      <<GenColor( 2,'SCREEN' )>>
  65.    @ 24,0 CLEAR
  66.    @ 24,0 SAY 'Enter Record...'
  67.    DO {fileprefix}_GETS
  68.    <<if ismultials>>
  69.    DO Page WITH pageno,1,dbfpagemax
  70.    <<else>>
  71.    DO Page WITH pageno,1,PageMax
  72.    <<endif>>
  73.    * ---Condition to exit inner loop.
  74.    IF pageno = 1
  75.       EXIT
  76.    ENDIF
  77.    DO {fileprefix}_FORM
  78. ENDDO
  79. <<if ismultials>>
  80. pageno = dbfpagemax
  81. <<endif>>
  82. <<end AppendPages>>
  83.  
  84.  
  85. <<procedure GenUniqueOne>>  <<* Assumes one or more indexes *>>
  86. <<begin>>
  87. * ---Check for duplicate record.
  88. DO WHILE .T.
  89.      <<GenColor( 2,'SCREEN' )>>
  90.    @ 24,0 CLEAR
  91.    @ 24,0 SAY 'Enter Record...'
  92.    * ---Enter key field values.
  93.    DO {fileprefix}_KEYS WITH expr,IsBlank,IsUnique
  94.    IF IsBlank .OR. .NOT. IsUnique
  95.       EXIT
  96.    ENDIF
  97.    * ---Check for duplicate key in master file.
  98.    SEEK expr
  99.    IF EOF()
  100.       * ---No duplicate key found, so leave.
  101.       EXIT
  102.    ELSE
  103.       * ---Found a duplicate record in the file.
  104.      <<GenColor( 2,'STATUS' )>>
  105.       @ 0,50 SAY "*DELETED*"
  106.       DO SayLine WITH row,;
  107.          "DUPLICATE KEY encountered.  Record cannot be appended."
  108.       WAIT
  109.    ENDIF
  110. ENDDO
  111. <<end GenUniqueOne>>
  112.  
  113.  
  114. <<#
  115. procedure AppendWithEdit
  116. logical iswithndx
  117. begin
  118.   iswithndx := false
  119.   select all
  120.   forall databases
  121.     if ndxtotal > 0
  122.       iswithndx := true
  123.     endif
  124.   endfor
  125. #>>
  126.   <<if iswithndx>>
  127.     <<GenUniqueOne>>
  128.   <<else>>
  129. * ---Enter key field values.
  130.      <<GenColor( 2,'SCREEN' )>>
  131.    @ 24,0 CLEAR
  132.    @ 24,0 SAY 'Enter Record...'
  133. DO {fileprefix}_KEYS WITH expr,IsBlank,IsUnique
  134.   <<endif>>
  135. IF IsBlank
  136.    IsDeleted = .T.
  137. ELSE
  138. <<if ismultipage>>
  139.    <<pushmargin( 1 )>>
  140.    <<AppendPages>>
  141.    <<popmargin>>
  142. <<else>>
  143.    DO {fileprefix}_GETS
  144. <<endif>>
  145. ENDIF
  146. <<end AppendWithEdit>>
  147.  
  148.  
  149. <<procedure GenAppendBody>>
  150. <<string line>>
  151. <<begin>>
  152. PRIVATE row,recnum,recnumOFS
  153. PRIVATE IsBlank,IsUnique,IsCarry,IsDeleted,IsEdited
  154. <<if ismultials>>
  155.   <<GenPrivateFlds( 0 )>>
  156. <<endif>>
  157. * ---Initialize local memory variables.
  158. row = PromptRow
  159. recnumOFS = 0
  160. STORE .F. TO IsBlank,IsUnique,IsCarry,IsDeleted,IsEdited
  161. expr = ""
  162. <<if not ismultipage>>
  163. DO {fileprefix}_FORM
  164. <<endif>>
  165. * ---Start by adding one record.
  166. choice = Returnkey
  167. * ---The following loop is really a "REPEAT/UNTIL <cond>".
  168. DO WHILE .T.
  169.   <<if ismultials and ismultipage>>
  170.    * ---Start database file on correct page.
  171.    DO CASE
  172.    <<forall databases>>
  173.    CASE dbfarea = {"}{dbfcount}{"}
  174.       <<select field 1>>
  175.       pageno = {fldpag}
  176.    <<endfor>>
  177.    ENDCASE
  178.   <<endif>>
  179.   <<if ismultipage>>
  180.    DO {fileprefix}_FORM
  181.   <<endif>>
  182.    IF (choice = Returnkey) .OR. IsCarry
  183.       * ---Add another record.
  184.       recnumOFS = recnumOFS + 1
  185.       IF .NOT. IsCarry
  186.          * ---Initialize memory variables with blanks.
  187.          GOTO BOTTOM
  188.          IF .NOT. EOF()
  189.             SKIP
  190.          ENDIF
  191.          DO {fileprefix}_SAYS
  192.          DO {fileprefix}_STOR
  193.          GOTO BOTTOM
  194.          <<pushmargin( 3 )>>
  195.          <<GenInitFlds>>
  196.          <<popmargin>>
  197.       ENDIF
  198.       IsCarry = .F.
  199.    ENDIF
  200.    DO StatLine WITH LastRec+recnumOFS,IsDeleted
  201.    @ 0,50 SAY "*BLANK*  "
  202. <<#
  203.    pushmargin( 1 )
  204.    AppendWithEdit
  205.    popmargin
  206. #>>
  207.    DO StatLine WITH LastRec+recnumOFS,IsDeleted
  208.    * ---Loop until Add, Carry, Edit, or Finished is selected.
  209.    * ---The following loop is really a "REPEAT/UNTIL <cond>".
  210.    menuchoice = 4
  211.    DO WHILE .T.
  212.       * ---You can add other prompts and options in this inner loop.
  213.       * ---For example, to add an invoicing routine:
  214.       *
  215.       *    (1) Insert "{I}nvoice" in the prompt line below,
  216.       *    (2) Include "I" in the values for GetKey, and
  217.       *    (3) Add a CASE to the DO CASE structure, such as:
  218.       *
  219.       *        CASE choice = "I"
  220.       *           DO <invoice_program_name>
  221.       *
  222. <<*
  223.           1         2         3         4         5         6
  224. 0123456789012345678901234567890123456789012345678901234567890123
  225. APPEND:   Add-another   Carry-add   Edit   Finished   <Del> "
  226. APPEND:   Add-another   Carry-add   Edit   Finished   Output  <Del> "
  227. *>>
  228. SAVE SCREEN TO APPENDSCR
  229. <<GenColor(0,'SCREEN')>>
  230. @ 22,0 CLEAR
  231. menuchoice = 0
  232.   <<if feat(featlabel)>>
  233.      MSG1 = "Add-another"
  234.      MSG2 = "Carry-add"
  235.      MSG3 = "Edit"
  236.      MSG4 = "Delete"
  237.      MSG5 = "Output"
  238.      MSG6 = "Return"
  239.      DO {fileprefix}_MENU WITH 1,60,6,13
  240.       choice =SUBSTR( "F"+Returnkey+"CE"+DelRecord+"OF",menuchoice + 1,1 )
  241.   <<else>>
  242.      MSG1 = "Add-another"
  243.      MSG2 = "Carry-add"
  244.      MSG3 = "Edit"
  245.      MSG4 = "Delete"
  246.      MSG5 = "Return"
  247.      DO {fileprefix}_MENU WITH 1,60,5,13
  248.       choice =SUBSTR( "F"+Returnkey+"CE"+DelRecord+"F",menuchoice + 1,1 )
  249.   <<endif>>
  250.      RESTORE SCREEN FROM APPENDSCR
  251.       DO CASE
  252.       CASE choice = DelRecord
  253.          * ---Toggle IsDeleted flag.
  254.          IsDeleted = .NOT. IsDeleted
  255.          DO StatLine WITH LastRec+recnumOFS,IsDeleted
  256.       CASE choice = "E"
  257.          * ---Re-edit the record.
  258.          IsDeleted = .F.
  259.       CASE choice $ "CF"+Returnkey
  260.          * ---Finished, Add-another, or Carry-add.
  261.          IsCarry = (choice = "C")
  262.          IF IsDeleted
  263.             * ---Reset offset so as not to increment.
  264.             recnumOFS = recnumOFS - 1
  265.          ELSE
  266.             * ---Save the memvar values.
  267.             APPEND BLANK
  268.             DO {fileprefix}_REPL
  269.          ENDIF
  270. <<if feat(featlabel)>>
  271.       CASE choice = "O"
  272.          * ---Print one label/record.
  273.          <<pushmargin( 3 )>>
  274.          <<GenOutputItems>>
  275.          <<popmargin>>
  276.          choice = "O"
  277. <<endif>>
  278.       ENDCASE
  279.       * ---Condition to exit inner loop.
  280.       IF choice $ "CEF"+Returnkey
  281.          EXIT
  282.       ENDIF
  283.    ENDDO
  284.    * ---Condition to exit outer loop.
  285.    IF choice = "F"
  286.       EXIT
  287.    ENDIF
  288. ENDDO
  289. LastRec = LastRec + recnumOFS
  290. GOTO TOP
  291. <<end>> <<*GenAppendBody*>>
  292.  
  293. <<* EOF: MSAAPPE.INC *>>
  294.