home *** CD-ROM | disk | FTP | other *** search
/ RBBS in a Box Volume 1 #3.1 / RBBSIABOX31.cdr / magn / mac.prg < prev    next >
Text File  |  1984-08-06  |  5KB  |  171 lines

  1. ********************** MAC.PRG *********************************
  2. ****************************************************************
  3. *** COPYRIGHT 1984 Data Based ADVISOR
  4. ***   ALL RIGHTS RESERVED
  5. *** Author: Larry Eitel
  6. ***   Data Based Solutions
  7. ***   1975 Fifth Avenue
  8. ***   San Diego, CA.  92101
  9. *** Date: May 16, 1984
  10. *** Purpose: Remember up to the last 10 commands issued at the dot
  11. *** prompt and have the ability to list them, re-execute them or edit
  12. *** and re-execute them. THIS UTILITY HAS LITTLE ERROR TRAPPING IN
  13. *** ORDER TO LEAVE FLEXIBILITY FOR APPLICATIONS PROGRAMMERS.
  14. ***
  15. *** NOTE: THIS PROGRAM WILL NOT WORK WITH RUNTIME PACKAGES
  16. ***
  17. *** DISCLAIMER: THE AUTOR MAKES NOR IMPLIES NO WARRANTIES
  18. ***   REGARDING THE OPERATION OR USEFULNESS OF THIS PROGRAM. THE
  19. ***   AUTHOR RECOMMENDS BEFORE USING ANY NEW PROGRAM, THE USER
  20. ***   BACKUP ANY PERTINENT FILES.
  21. ***
  22.  
  23. ****************************************************************
  24. * I didn't use a CLEAR as you normally would because you have the
  25. * ability to restart this program and still have access to the
  26. * last 10 commands issued at the dot prompt
  27. ERASE
  28. SET TALK OFF
  29. SET INTENSITY OFF
  30. SET BELL OFF
  31. * If this is being started again, it will remember the last 10
  32. * commands you gave
  33. IF 0=test(last)
  34.  STORE 0 TO com:num
  35.  STORE STR(com:num,1) TO no,last
  36. ELSE
  37.  IF com:num=11
  38.   STORE com:num-1 TO com:num
  39.  ENDIF
  40.  IF com:num<10
  41.   STORE STR(com:num,1) TO no,last
  42.  ELSE
  43.   STORE STR(com:num,2) TO no,last
  44.  ENDIF
  45. ENDIF
  46. STORE '   ' to com&no
  47. * Start main loop
  48. DO WHILE t
  49.  * reset environmental settings
  50.  SET COLON OFF
  51.  SET TALK OFF
  52.  SET INTENSITY OFF
  53.  SET BELL OFF
  54.  ?
  55.  * If you are issuing another command and have already filled
  56.  * the command "BUFFER" with 10 prior commands, it has to
  57.  * re-number the commands
  58.  IF com:num=11
  59.   SET RAW ON
  60.   STORE 1 TO old
  61.   STORE 0 TO new
  62.   DO WHILE new<=10
  63.    IF old<10
  64.     STORE STR(old,1) TO s:old
  65.    ELSE
  66.     STORE STR(old,2) TO s:old
  67.    ENDIF
  68.    IF new<10
  69.     STORE STR(new,1) TO s:new
  70.    ELSE
  71.     STORE STR(new,2) TO s:new
  72.    ENDIF
  73.    STORE com&s:old TO com&s:new
  74.    STORE old+1 TO old
  75.    STORE new+1 to new
  76.    ?? '.'
  77.   ENDDO
  78.   SET RAW OFF
  79.   STORE '10' TO no
  80.   STORE 10 TO com:num
  81.  ENDIF
  82.  * Store a blank to the next command number unless you are editing
  83.  * a command number
  84.  IF !(com&no)='E'
  85.   STORE $(com&no,2,1) TO no
  86.   STORE $(com&no+$(STR(0,239),1,238-LEN(com&no)),1,238) TO com&no
  87.  ELSE
  88.   STORE $(STR(0,239),1,238) TO com&no
  89.   ?
  90.   ?
  91.   @ 24,00 SAY ' '
  92.   ? '(D#)o, (L)ist, (E#)dit & Do, RETURN OR QUIT. '+;
  93.   'To start again type DO MAC <RET>.'
  94.   ?
  95.   ?
  96.   ?
  97.   ?
  98.  ENDIF
  99.  * Display dot prompt and get next command. Remember, you have
  100.  * full editing abilities while entering a command
  101.  CLEAR GETS
  102.  @ 21,00 SAY '. ' GET com&no
  103.  READ
  104.  CLEAR GETS
  105.  * Because dBASE is sometimes inconsistent in the way it executes a
  106.  * macro of a macro, I decided to store the value to X
  107.  STORE TRIM(com&no) TO x,com&no
  108.  DO CASE
  109.   * If you would like to execute one of the last 10 commands
  110.   * again, you can type "D" and the command number e.g. "D2"
  111.   CASE !(x)='D'.AND.LEN(x)=2
  112.    STORE $(com&no,2,1) TO no
  113.    STORE com&no TO x
  114.    &x
  115.    IF last='11'
  116.     STORE '10' TO no,last
  117.    ELSE
  118.     STORE last TO no
  119.    ENDIF
  120.    LOOP
  121.   * If you would like to edit and execute on of the last 10 commands
  122.   * you can type "E" and the command number e.g. "E2"
  123.   CASE !(x)='E'.AND.LEN(TRIM(x))=2
  124.    STORE com:num-1 TO com:num
  125.    LOOP
  126.   * You can list up to 10 of the last 10 commands
  127.   CASE !(x)='L'.AND.LEN(TRIM(x))=1
  128.    ?
  129.    STORE 0 TO com:num
  130.    STORE STR(com:num,1) TO no
  131.    DO WHILE VAL(last)#VAL(no).AND.no#'10'
  132.     ? no+'>',com&no
  133.     STORE com:num+1 TO com:num
  134.     IF com:num<10
  135.      STORE STR(com:num,1) TO no
  136.     ELSE
  137.      STORE STR(com:num,2) TO no
  138.     ENDIF
  139.    ENDDO
  140.   * Otherwise save and execute issued command
  141.   OTHERWISE
  142.    &x
  143.    STORE com:num+1 TO com:num
  144.    IF com:num<10
  145.     STORE STR(com:num,1) TO no,last
  146.    ELSE
  147.     STORE STR(com:num,2) TO no,last
  148.    ENDIF
  149.    STORE '  ' TO com&no
  150.  ENDCASE
  151.  SET COLON ON
  152. ENDDO WHILE t
  153. RETURN
  154. * EOF
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.