home *** CD-ROM | disk | FTP | other *** search
/ Phoenix CD 2.0 / Phoenix_CD.cdr / 02a / pardoxed.zip / EDITOR.SC < prev    next >
Text File  |  1987-08-15  |  6KB  |  230 lines

  1. PROC FANCEDIT(tblname)
  2.  
  3. Clear     ; clear environment
  4. ClearAll
  5.  
  6. View tblname  ; view table choice passed to procedure
  7.  
  8. keystrk = 1  ; this sets counter for autosave feature
  9.  
  10. While (true)  ; infinite loop, will break upon F2
  11.  
  12. ; if table is empty FormKey will cause an error if not in edit mode
  13.  
  14. if sysmode() <> "Edit"
  15.    then
  16.      EditKey
  17. endif
  18. ; simple error check to insure form mode
  19.  
  20. if NOT(isformview())
  21.  then
  22.   Formkey
  23. endif
  24.  
  25.  Wait Record
  26.  Until "F1","CtrlPgUp","CtrlPgDn","F2","F7","Home","End","F9","F10",
  27.        "Del","F6","F5","F4","F3","F8"
  28.  
  29.  if retval = "F1"
  30.   then
  31.    Play "help"
  32.  endif
  33.  
  34.  If retval = "F4"    ; is ditto plus clears field first
  35.   then
  36.    CtrlBackspace
  37.    Ditto
  38.  endif
  39.  
  40.  IF retval = "CtrlPgUp"  ; in formmode user can only go one Page at a time
  41.   then                   ; this is quicker method to move up
  42.    value = recno()
  43.    if value < 15
  44.     then
  45.      value = 1
  46.      message "At beginnng of file"
  47.     else
  48.      value = value -15
  49.    endif
  50.     moveto record value
  51.  endif
  52.  
  53.  if retval = "CtrlPgDn"  ; same as above only goes down
  54.   then
  55.    value = recno()
  56.    if (value+15) > nrecords(tblname)
  57.     then
  58.       value = nrecords(tblname)
  59.       message "At end of file"
  60.     else
  61.       value = value + 15
  62.    endif
  63.    MOVETO RECORD value
  64.  endif
  65.  
  66.  if retval = "F7"  ; in edit mode in Paradox this allows user to enter
  67.    then            ; a table mode - most normal editing keys work
  68.     FormKey        ; for data entry people this may be a dangerous
  69.     Wait Table
  70.      message  "when done scrolling in table mode to exit type F7"
  71.     Until "F7"
  72.     FormKey        ; function to allow since the del key is not protected
  73.  endif             ; in this version, in form mode del key is caught, so veri-
  74.                    ; fication is possible - you can modify to your requirements
  75.  
  76.  if retval = "F8"  ; Duplicates record a certain number of times. repeat
  77.   then             ; is included in the archive
  78.    Do_it!
  79.    Play "repeat"
  80.    Do_It!
  81.  endif
  82.  
  83.  if retval = "F2"  ; saves, F2 because that is PDX standard
  84.   then
  85.    Do_It!
  86.    ClearAll
  87.    Clear
  88.    Return
  89.  endif
  90.  
  91.  if retval = "F3"
  92.    then
  93.     Do_It! ; save work, this function is disk intensive
  94.     ClearAll
  95.     Savevars tblname
  96.     Play "search"
  97.   endif
  98.  
  99.  if retval = "F10"  ; this will move one record down in form mode,
  100.   then              ; in normal form mode if form is multipage user would
  101.    value = recno()  ; have to use PgDn a great deal, this is better
  102.    if value = nrecords(tblname)
  103.     then
  104.       FormKey
  105.       Down
  106.       CtrlHome
  107.       Message " At Bottom of file! "
  108.       sleep 250
  109.     else
  110.       value = value +1
  111.       moveto record value
  112.    endif
  113.  endif
  114.  
  115.  if retval = "F9" ; same as F10 but moves user up
  116.   then
  117.    value = recno()
  118.    if (value - 1) = 0
  119.     then
  120.      message "You are at beginning of file"
  121.      sleep 250
  122.     else
  123.      value = value -1
  124.      moveto record value
  125.    endif
  126.  endif
  127.  
  128. if retval = "Home"  ; similar to PDX edit mode HOME moves user to beg of file
  129.   then
  130.    Do_It!
  131.    moveto record 1
  132. endif
  133.  
  134. if retval = "End"  ; similar to PDX edit mode END moves user to end of file
  135.   then
  136.    Do_It!
  137.    moveto record nrecords(tblname)
  138. endif
  139.  
  140. if retval = "Del" ; this is the guard in form mode to do what PDX does not
  141.  then             ; ask if you really want to del record and usr often does
  142.   ? "Are you sure you wish to Delete Record(Y or N): "
  143.   Accept "A1" Default "N" to reply
  144.   value = recno()
  145.   if reply = "Y"  ; does not see the record get delete to fast typing, etc..
  146.    then
  147.     Del
  148.     message "Record ",value," deleted"
  149.     sleep 250
  150.   endif
  151. endif
  152.  
  153. if retval = "F6" ; copies current record in to a newly inserted one record after
  154.  then            ; the current file pointer
  155.   value = recno()
  156.   copytoarray b
  157.   CtrlHome
  158.   Down
  159.   Ins
  160.   copyfromarray b
  161.   message "Record ",value," copied into new record ",value+1
  162.   sleep 350
  163. endif
  164.  
  165. If retval = "F5"   ; allows user to edit text field like a word processor
  166.  then
  167.   FieldView
  168.   Wait Field
  169.    message " Press F2 when done with field "
  170.   Until "F2"
  171. endif
  172.  
  173. if keystrk > 20  ; autosave is set at twenty times through loop, you may
  174.  then            ; set it at any value you wish, but this seems to work well
  175.   Do_It!
  176.   keystrk=1
  177.  else
  178.   keystrk = keystrk + 1
  179. endif
  180.  
  181. Endwhile
  182.  
  183. ENDPROC
  184.  
  185. ; end of generic file edit proc
  186.  
  187. ClearAll
  188. CLEAR
  189. ;@2,2 ?? "Do you wish to empty previous po's(Y/N):"
  190. ;accept "A1" to getposready
  191. ;if ((getposready="y") or (getposready="Y"))
  192. ; then
  193. ;  Clear
  194. ;  Message "POS now being cleared - in new data entry mode"
  195. ;  Empty "POS"
  196. ;endif
  197. ;fancedit("c:\\programs\\paradox\\pos\\pos")
  198.  
  199. ; above is example of a hardwired script for editing, this editor is small enough
  200. ; including its support scripts repeat, search, help can be in every directory
  201. ; for each application - most people put each application in one directory  -
  202. ; purchase orders, AR, etc....
  203. ; if you wish to have this editor work for all tables I have included the
  204. ; code for this, so the first try can be editing tables which are in the
  205. ; current directory or others.
  206.  
  207.  
  208. Clear
  209. @1,1 ?? "Editor!               Pernell J Dykes            Micro-consulting"
  210. @24,1 ?? "A contribution is greatly appreciated, see the help menu!"
  211. @22,1 ?? "When in editor F1 is the help key!!!"
  212. @15,5 ??"Example of file entry for current directory is 'database' with no"
  213. @16,5 ??"other extension. If wish to edit another directory use double slashes"
  214. @18,5 ??"    For Example : 'c:\\paradox\\acctrecv\\database'               "
  215. @6,2 ?? "Enter file to edit, if in this directory erase default and put table:"
  216. @7,2 ?? ">"
  217. Accept "A50" Default "c:\\paradox\\" to direcpath
  218.  
  219. if istable(direcpath)
  220.  then
  221.   fancedit(direcpath)
  222.  else
  223.   Clear
  224.   @2,2 ?? "Table does not exist, or directory is incorrect, rerun script."
  225.   sleep 8000
  226. Clear
  227. endif
  228.  
  229. Return
  230.