home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a070 / 3.ddi / FOXPRO / TEMPLGEN / AP1EDIT.INC < prev    next >
Encoding:
Text File  |  1988-02-10  |  6.3 KB  |  268 lines

  1. <<* APPEDIT.INC *>>
  2.  
  3. <<procedure GenEditBody>>
  4. <<integer menutotal>>
  5. <<begin>>
  6. PARAMETER isedited
  7. PRIVATE row,lastpage,editchoice,ndxchoice
  8. PRIVATE IsBlank,IsUnique
  9. <<select all>>
  10. <<if LiteBar and (pagtotal > 2)>>
  11. PRIVATE pagechoice
  12. <<endif>>
  13. row = PromptRow
  14. expr = ""
  15. STORE .F. TO isedited,IsBlank,IsUnique
  16. <<if ismultials>>
  17.   <<GenPrivateFlds( 0 )>>
  18. <<endif>>
  19. DO {fileprefix}_FORM
  20. DO SayRec
  21. <<#
  22.   if LiteBar
  23.     menutotal := 8
  24.     if ismultials
  25.       menutotal := menutotal + 1
  26.     endif
  27.     if ismultipage
  28.       menutotal := menutotal + 1
  29.     endif
  30.     if feat(featlabel)
  31.       menutotal := menutotal + 1
  32.     endif
  33.     genln( 'menuchoice = ',menutotal )
  34.   endif
  35. #>>
  36. editchoice = "*"
  37. ndxchoice = "*"
  38. * ---Loop until {{}Return} is pressed.
  39. * ---The following loop is really a "REPEAT/UNTIL <cond>".
  40. DO WHILE .T.
  41.    <<GenColor( 1,'PROMPT' )>>
  42.    IF .NOT. (editchoice $ "NP"+DelRecord)
  43.       @ row,0 CLEAR
  44.    ENDIF
  45. <<#
  46.    pushmargin(1)
  47.    if LiteBar
  48.      if ismultipage
  49.        EditLitePage
  50.      else
  51.        EditLiteOne
  52.      endif
  53.    else
  54.      if ismultipage
  55.        EditPage
  56.      else
  57.        EditOne
  58.      endif
  59.    endif
  60.    popmargin
  61. #>>
  62.    DO CASE
  63.    CASE editchoice = Returnkey
  64.       EXIT
  65.    CASE editchoice = "F"
  66.       * ---Find a record.
  67.    <<select all databases>>
  68.    <<if ndxtotal = 0>>
  69.       DO SayLine WITH row,"*** NO INDEX FILE IN USE"
  70.       WAIT
  71.       @ row,0 CLEAR
  72.    <<elsif ismultindx>>
  73.       DO {fileprefix}_NDXS WITH row,ndxchoice
  74.       IF ndxchoice > "0"
  75.          oldrecnum = RECNO()
  76.          DO {fileprefix}_SEEK WITH row
  77.          IF EOF()
  78.             DO SayLine WITH row,"No find."
  79.             WAIT
  80.             GOTO oldrecnum
  81.          ELSE
  82.             DO SayRec
  83.          ENDIF
  84.       ENDIF
  85.    <<else>>
  86.       oldrecnum = RECNO()
  87.       DO {fileprefix}_SEEK WITH row
  88.       IF EOF()
  89.          DO SayLine WITH row,"No find."
  90.          WAIT
  91.          GOTO oldrecnum
  92.       ELSE
  93.          DO SayRec
  94.       ENDIF
  95.    <<endif>>
  96. <<if feat(featlabel)>>
  97.    CASE editchoice = "O"
  98.       * ---Print one label/record.
  99.       <<if AutoMem>>
  100.       DO {fileprefix}_STOR
  101.       <<endif>>
  102.       <<pushmargin( 2 )>>
  103.       <<GenOutputItems>>
  104.       <<popmargin>>
  105. <<endif>>
  106.    CASE editchoice = "N"
  107.       * ---Next record.
  108.       oldrecnum = RECNO()
  109.       SKIP
  110.       IF EOF()
  111.          DO SayEOF WITH row,oldrecnum
  112.       ELSE
  113.          DO SayRec
  114.       ENDIF
  115.    CASE editchoice = "P"
  116.       * ---Previous record.
  117.       oldrecnum = RECNO()
  118.       SKIP -1
  119.       IF BOF()
  120.          DO SayEOF WITH row,oldrecnum
  121.       ELSE
  122.          DO SayRec
  123.       ENDIF
  124.    CASE editchoice = "E"
  125.       * ---Edit the record.
  126.       isedited = .T.
  127.       <<if AutoMem>>
  128.       DO {fileprefix}_STOR
  129.       <<endif>>
  130. <<if ismultipage>>
  131.       lastpage = pageno
  132.       DO {fileprefix}_AREA
  133.       IF pageno <> lastpage
  134.          DO {fileprefix}_FORM
  135.          DO SayRec
  136.          lastpage = pageno
  137.       ENDIF
  138.       DO WHILE .T.
  139.          DO SayLine WITH row,"Press {Ctrl-W} to Exit"
  140.          IF pageno = lastpage
  141.             DO {fileprefix}_KEYS WITH expr,IsBlank,IsUnique
  142.             * ---If you don't want the user to edit the
  143.             * ---key fields, then delete this IF structure.
  144.          ENDIF
  145.          DO {fileprefix}_GETS
  146.          DO Page WITH pageno,1,PageMax
  147.          DO {fileprefix}_FORM
  148.    <<if AutoMem>>
  149.          IF pageno = lastpage
  150.             EXIT
  151.          ENDIF
  152.          DO SayRec
  153.       ENDDO
  154.       DO {fileprefix}_REPL
  155.       DO SayRec
  156.    <<else>>
  157.          DO SayRec
  158.          IF pageno = lastpage
  159.             EXIT
  160.          ENDIF
  161.       ENDDO
  162.    <<endif>>
  163. <<else>> <<*single page format*>>
  164.       DO SayLine WITH row,"Press {Ctrl-W} to Exit"
  165.       * ---If you don't want the user to edit the
  166.       * ---key fields, then delete the following line.
  167.       DO {fileprefix}_KEYS WITH expr,IsBlank,IsUnique
  168.       DO {fileprefix}_GETS
  169.       <<if AutoMem>>
  170.       DO {fileprefix}_REPL
  171.       <<endif>>
  172. <<endif>> <<*single page format*>>
  173. <<if ismultipage>>
  174.   <<select all>>
  175.   <<if LiteBar and (pagtotal > 2)>>
  176.    CASE editchoice = PgDn
  177.       <<pushmargin( 2 )>>
  178.       <<GenPageItems>>
  179.       <<popmargin>>
  180.   <<else>>
  181.    CASE editchoice = PgDn
  182.       DO Page WITH pageno,1,PageMax
  183.       DO {fileprefix}_FORM
  184.       DO SayRec
  185.    CASE editchoice = PgUp
  186.       DO Page WITH pageno,-1,PageMax
  187.       DO {fileprefix}_FORM
  188.       DO SayRec
  189.  <<endif>>
  190. <<endif>>
  191.    CASE editchoice = "L"
  192.       * ---Locate a record.
  193.       <<GenColor( 2,'WINDOW' )>>
  194.       @ 1,0 CLEAR
  195.      <<select database 8>>  <<*Is SELECT H being used?*>>
  196.      <<if dbfnam>>          <<*Yes, then use old <expr> system...*>>
  197.       DO {fileprefix}_EXPR WITH expr
  198.      <<else>>               <<*No, use new and improved...*>>
  199.       DO {fileprefix}_COND WITH expr
  200.      <<endif>>
  201.       <<if ismultipage>>
  202.       DO {fileprefix}_FORM
  203.       <<else>>
  204.       DO {fileprefix}_FORM
  205.       <<endif>>
  206.       DO SayRec
  207.       IF "" <> TRIM( expr )
  208.          * ---Check for valid LOGICAL expression.
  209.          IF TYPE( expr ) = "L"
  210.             DO DoLOCATE WITH row,expr
  211.          ELSE
  212.            <<GenColor( 4,'PROMPT' )>>
  213.             @ row,0 CLEAR
  214.             @ row,0 SAY "Invalid expression."
  215.             WAIT
  216.          ENDIF
  217.       ENDIF
  218.    CASE editchoice = "G"
  219.       * ---Goto a record.
  220.       DO DoGOTO WITH row,recnum,LastRec
  221.       IF recnum > 0
  222.          DO SayRec
  223.       ENDIF
  224. <<if LiteBar>>
  225.       menuchoice = 3
  226. <<endif>>
  227.    CASE editchoice = DelRecord
  228.       * ---Delete the record.
  229.       isedited = .T.
  230.       IF DELETED()
  231.          RECALL
  232.       ELSE
  233.          DELETE
  234.       ENDIF
  235.       DO StatLine WITH RECNO(),DELETED()
  236. <<if ismultials>>
  237.    CASE editchoice = "S"
  238.       * ---Select database file.
  239. <<#
  240.       pushmargin( 2 )
  241.       GenPrivateFlds( 1 )
  242.       popmargin
  243. #>>
  244.     <<if ismultipage>>
  245.       lastpage = pageno
  246.       DO {fileprefix}_FILE WITH row,choice
  247.       IF lastpage = pageno
  248.          DO StatLine WITH RECNO(),DELETED()
  249.       ELSE
  250.          DO {fileprefix}_FORM
  251.          DO SayRec
  252.       ENDIF
  253.     <<else>>
  254.       DO {fileprefix}_FILE WITH row,choice
  255.       DO StatLine WITH RECNO(),DELETED()
  256.     <<endif>>
  257. <<#
  258.       pushmargin( 2 )
  259.       GenPrivateFlds( 0 )
  260.       popmargin
  261. #>>
  262. <<endif>>
  263.    ENDCASE
  264. ENDDO
  265. <<end>> <<*GenEditBody*>>
  266.  
  267. <<*EOF: APPEDIT.INC*>>
  268.