home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a046 / 5.img / TEMPLATE / SSBAPPE.INC < prev    next >
Encoding:
Text File  |  1992-04-01  |  6.9 KB  |  284 lines

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