home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a009 / 6.ddi / SAMPLE.LIF / DOT.PRG < prev    next >
Encoding:
Text File  |  1991-04-14  |  110.4 KB  |  5,362 lines

  1. ***
  2. * Dot.prg
  3. * Dot-prompt interpreter written in Clipper.
  4. * Copyright (c) 1986-1990 Nantucket Corp.  All rights reserved.
  5. * Kevin J. Shepherd
  6. * NOTE
  7. * ----
  8. * DOT is offered as an example of Clipper capabilities.  It does
  9. * not constitute a working dBASE interpreter.
  10. *
  11. *
  12. * PROGRAM OVERVIEW
  13. * ----------------
  14. * DOT is an interpreter for some of the commands in the Clipper command
  15. * set.  DOT consists of a stack, a parser to fill it, procedure driven
  16. * stack analyzers, list and expression building functions, command line
  17. * execution procedures, etc.
  18. *
  19. * After a command has been entered the verb analyzer checks the stack
  20. * for an equal sign after the first identifier.  If an assignment is
  21. * found, the analyzer procedure macro is set to "ASSIGN".  If not, the
  22. * analyzer searches the verb list for the existence of the first stack
  23. * item.  If a match is found, it is checked for correct abbreviation.
  24. * If it is correct, the analysis procedure macro is initialized to the
  25. * procedure name found in the analyzer procedure list.  If the item
  26. * was not found or failed the abbreviation test, the analyzer macro is
  27. * set to "UNKNOWN".  The analyzer procedure is used to set the Class
  28. * Execution procedure macro, execution flags and Command Line
  29. * Substitution macros.  If an assignment or a variable is to be
  30. * created or deleted, it is done next, in the top most level of DOT.
  31. * One of six Class Execution procedures is called next, based on what
  32. * was found on the stack.  The called procedure contains Clipper
  33. * command strings with substitution macros used in the variable
  34. * portion of the line.  The command is selected with the execution
  35. * flag set in the analyzer.  After the command has been executed, it
  36. * is placed into the History array.  The control variables and command
  37. * line macros are reset, and the loop returns to the top, ready for
  38. * another command.
  39. * What ever you want to do, DOT can be tailored to your needs by
  40. * adding PROCEDUREs and FUNCTIONs to form new commands.  A command can
  41. * be appended to DOT by adding the verb and the matching analysis
  42. * procedure name to the verb and analyzer lists. Next, decide on the
  43. * Class Execution procedure you want to execute your command in, and
  44. * add another DO CASE switch variable to the PUBLIC switch list at the
  45. * beginning of the DOT procedure.  The analysis procedure can be added
  46. * after you have selected the PROCEDURE and switch names.  These
  47. * procedures and/or functions that you define can be made up of any
  48. * combination of Clipper, "C", or ASSEMBLY routines. They, in turn,
  49. * are interfaced to DOT by using Clipper's EXTEND system and EXTERNAL
  50. * references. The EXTERNALs can either by added directly to DOT, your
  51. * .PRG file, or compiled as a seperate file and included in the link
  52. * line as an object module.
  53. *
  54.  
  55. clear
  56.  
  57. ** set CALLS class flags public **
  58. public CALLS1, CALLS2, CALLS3, CALLS4, CALLS5, CALLS6, CALLS7
  59.  
  60. ** set DBF_NTX class flags public **
  61. public DBF_NTX1, DBF_NTX2, DBF_NTX3, DBF_NTX4, DBF_NTX5, DBF_NTX6
  62. public DBF_NTX7, DBF_NTX8, DBF_NTX9, DBF_NTX10, DBF_NTX11, DBF_NTX12
  63. public DBF_NTX13, DBF_NTX14, DBF_NTX15, DBF_NTX16, DBF_NTX17, DBF_NTX18
  64. public DBF_NTX19, DBF_NTX20, DBF_NTX21, DBF_NTX22, DBF_NTX23, DBF_NTX24
  65. public DBF_NTX25, DBF_NTX26, DBF_NTX27, DBF_NTX28, DBF_NTX29, DBF_NTX30
  66. public DBF_NTX31, DBF_NTX32, DBF_NTX33, DBF_NTX34, DBF_NTX35, DBF_NTX36
  67.  
  68. ** set ERRS class flags public **
  69. public ERRS1, ERRS2, ERRS3, ERRS4, ERRS5, ERRS6, ERRS7, ERRS8, ERRS9
  70. public ERRS10, ERRS11, ERRS12, ERRS13, ERRS14, ERRS15
  71.  
  72. ** set SCRN class flags public **
  73. public SCRN1, SCRN2, SCRN3, SCRN4, SCRN5, SCRN6, SCRN7, SCRN8, SCRN9
  74. public SCRN10, SCRN11, SCRN12, SCRN13, SCRN14, SCRN15, SCRN16, SCRN17
  75. public SCRN18, SCRN19, SCRN20, SCRN21, SCRN22, SCRN23, SCRN24, SCRN25
  76. public SCRN26, SCRN27, SCRN28
  77.  
  78. ** set SETS class flags public **
  79. public SETS1, SETS2, SETS3, SETS4, SETS5, SETS6, SETS7, SETS8, SETS9
  80. public SETS10, SETS11, SETS12, SETS13, SETS14, SETS15, SETS16, SETS17
  81. public SETS18, SETS19, SETS20, SETS21, SETS22
  82.  
  83. ** set VARS class flags public **
  84. public VARS1, VARS2, VARS3, VARS4, VARS5, VARS6, VARS7, VARS8, VARS9
  85. public VARS10, VARS11, VARS12
  86.  
  87. ** set data and index file status flags public **
  88. public DBF_OPEN, NTX_OPEN
  89.  
  90. ** set command line execution macro variables public **
  91. public box_exp, coord1, coord2, coord3, coord4, dbf_file, dest, exp1
  92. public exp2, exp3, get_exp, get_pict, list0, list1, list2, list3, list4
  93. public list5, list6, list7, list8, list9, ntx_file, rng_exp1, rng_exp2
  94. public say_exp, say_pict, source, var1
  95.  
  96. ** set non-releasable macro variables **
  97. public alias, filter, range1, range2, relation, valid_exp
  98.  
  99. ** initialize non-releasable macro variables **
  100. store "" to alias, filter, range1, range2, relation, valid_exp
  101.  
  102. ** set conditional and scoping system variables public **
  103. public condition, rewind_dbf, scope
  104.  
  105. ** set internal status flags public **
  106. public color_stat, confr_stat, delim_stat, exact_stat, inten_stat
  107.  
  108. ** initialize internal status flags **
  109. color_stat = "7/0"
  110. confr_stat = "OFF"
  111. delim_stat = "OFF"
  112. exact_stat = "OFF"
  113. inten_stat = "ON"
  114.  
  115. ** set internal control variables public **
  116. public bottom_on, cmd_line, error_on, executor, hist_max, lex_proc
  117. public lex_list, max_hist, save_col, save_row, set_list, set_proc
  118. public stack_size, verb_list, dot_vers
  119.  
  120. ** initialize internal search list variables **
  121. do fill_lists
  122.  
  123. ** initialize internal control variables **
  124. bottom_on = .T.
  125. cmd_line = replicate("°", 80)
  126. error_on = .T.
  127. save_col = 0
  128. save_row = 0
  129. stack_size = 30
  130.  
  131. ** initialize the history variables **
  132. hist_max = 0
  133. max_hist = 20
  134. declare history[max_hist]
  135. dot_vers = "10/27/86"
  136.  
  137.  
  138. ** 5.0 error handler (see end of source file) **
  139. public SysErrorBlock := ErrorBlock( {|e| DotError(e)} )
  140.  
  141.  
  142. quit_now = .F.
  143.  
  144. do while !quit_now
  145.  
  146.     ** reset command line execution macro variables **
  147.     store "" to box_exp, coord1, coord2, coord3, coord4
  148.     store "" to dbf_file, dest, exp1, exp2, exp3
  149.     store "" to get_exp, get_pict, ntx_file, rng_exp1, rng_exp2
  150.     store "" to say_exp, say_pict, source, var1
  151.     store "" to list0, list1, list2, list3, list4
  152.     store "" to list5, list6, list7, list8, list9
  153.  
  154.  
  155.     begin sequence
  156.  
  157.         declare stack[stack_size]        && initialize STACK.
  158.         stack_ptr = 0                    && initialize stack element pointer.
  159.         max_ptr = 0                      && initialize stack element counter.
  160.  
  161.         lex_proc = ""                    && initialize analyzer macro.
  162.         executor = ""                    && initialize "class" executor macro.
  163.  
  164.         ** set PROMPT environment quantity **
  165.         set color to
  166.         set delimiters OFF
  167.         set confirm OFF
  168.         set exact OFF
  169.  
  170.         if bottom_on
  171.             do input_ln with "B"         && prompt at bottom of screen.
  172.         endif
  173.  
  174.         ** set HELP and HISTORY call keys **
  175.         set key 28 to help
  176.         set key 5 to history
  177.  
  178.         accept ". " to command           && get input from keyboard.
  179.  
  180.         do hist_put                      && place command into HISTORY array.
  181.  
  182.         command = "&command"             && expand all macros in string
  183.  
  184.         set key 5 to                     && turn OFF HISTORY mode.
  185.  
  186.         if bottom_on
  187.             do input_ln with "A"         && cursor to last display position.
  188.         endif
  189.  
  190.         do parse                         && call "stack" population routine.
  191.         max_ptr = stack_ptr              && assign maximum stack elements.
  192.  
  193.         if max_ptr > 0                   && stack elements exist.
  194.             if !err()                    && NO errors occurred in parser.
  195.                 do set_lex               && do analyzer macro set procedure.
  196.                 do &lex_proc             && do the analyze procedure macro.
  197.  
  198.                 if CALLS7
  199.                     quit_now = .t.
  200.                     break
  201.                 endif
  202.  
  203.                 if executor = "VARS"
  204.                     ** check for variable creation or release activity. **
  205.                     do case
  206.                         case VARS9
  207.                             ** if a variable is to be created **
  208.                             &var1 = &exp2
  209.                             VARS9 = .F.
  210.  
  211.                         case VARS10
  212.                             ** if an array is to be created **
  213.                             declare &var1[&exp1]
  214.                             VARS10 = .F.
  215.  
  216.                         case VARS11
  217.                             ** if a variable is to be released **
  218.                             release &var1
  219.                             VARS11 = .F.
  220.  
  221.                         case VARS12
  222.                             ** if an array is assigned a value **
  223.                             &var1[&exp1] = &exp2
  224.                             VARS12 = .F.
  225.                     endcase
  226.                 endif
  227.             endif
  228.  
  229.             if err()
  230.                 executor = "ERRS"        && set error executor procedure.
  231.             endif
  232.  
  233.  
  234.             ** set EXECUTION environment **
  235.             set color to &color_stat
  236.             set delimiters &delim_stat
  237.             set confirm &confr_stat
  238.             set exact &exact_stat
  239.  
  240.             do &executor                 && do execution procedure.
  241.  
  242.  
  243.         endif
  244.  
  245.     recover
  246.         ** this is just here to reset the parser **
  247.         command := '? ""'
  248.         do parse
  249.  
  250.     end
  251.  
  252. enddo
  253.  
  254. *
  255. ** eoproc dot.prg
  256.  
  257.  
  258. *******************
  259. * Dot procedures. *
  260. *******************
  261.  
  262.  
  263. ***
  264. * Procedure ACCEPT
  265. * kjs, 04/29/86, 10/08/86
  266. * Evaluates stack for ACCEPT verb.
  267. * Sets execution class macro, class execution flag(s) and command line
  268. * substitution macros.
  269. *
  270.  
  271. procedure accept
  272.  
  273. private stack_ptr, stack_item, item_ok, string, to, dest, active, error
  274.  
  275. stack_ptr = 2
  276. store .F. to string, to, dest, item_ok
  277. active = 1        && 0 = done, 1 = string, 2 = TO token, 3 = expression.
  278. error = 0
  279.  
  280. do while stack_ptr <= max_ptr .and. error = 0
  281.  
  282.     stack_item = ""
  283.     item_ok = get_stack("stack_item")
  284.  
  285.     do case 
  286.         case active = 0 .or. !item_ok
  287.             error = 2
  288.  
  289.         case active = 1
  290.             if !(upper(stack_item) == "TO")
  291.                 exp1 = stack_item
  292.                 string = .T.
  293.                 active = 2
  294.             else
  295.                 to = .T.    
  296.                 active = 3
  297.             endif
  298.  
  299.         case active = 2
  300.             if upper(stack_item) == "TO"
  301.                 to = .T.
  302.                 active = 3
  303.             else
  304.                 error = 15
  305.             endif
  306.  
  307.         case active = 3    
  308.             var1 = stack_item
  309.             dest = .T.
  310.             active = 0
  311.     endcase
  312. enddo
  313.  
  314. do case
  315.     case error = 2 .or. active <> 0
  316.         ERRS2 = .T.
  317.  
  318.     case error = 15
  319.         ERRS15 = .T.
  320.  
  321.     case to .and. dest .and. !string
  322.         executor = "VARS"
  323.         VARS1 = .T.
  324.         VARS9 = .T.
  325.  
  326.     case to .and. dest .and. string
  327.         executor = "VARS"
  328.         VARS2 = .T.
  329.         VARS9 = .T.
  330. endcase
  331.  
  332. return
  333.  
  334. *
  335. ** eoproc accept
  336.  
  337.  
  338. ***
  339. * Procedure APPEND
  340. * kjs, 05/01/86, 10/08/86
  341. * Evaluates stack for APPEND verb.
  342. * Sets execution class macro, class execution flag(s) and command line
  343. * substitution macros.
  344. *
  345.  
  346. procedure append
  347.  
  348. private stack_ptr, stack_item, item_ok, blank, file, from, active, error
  349.  
  350. stack_ptr = 2
  351. store .F. to blank, file, from, item_ok
  352. active = 0        && 0 = done, 1 = BLANK or FROM toke, 2 = source.
  353. error = 0
  354.  
  355. if error_on .and. !dbf_open
  356.     error = 5
  357. else
  358.     active = 1
  359. endif
  360.  
  361. do while stack_ptr <= max_ptr .and. error = 0
  362.  
  363.     stack_item = ""
  364.     item_ok = get_stack("stack_item")
  365.  
  366.     do case
  367.         case active = 0
  368.             error = 2
  369.  
  370.         case active = 1
  371.             do case
  372.                 case cmd_abbr(upper(stack_item), "BLANK")
  373.                     blank = .T.
  374.                     active = 0
  375.  
  376.                 case upper(stack_item) == "FROM"
  377.                     from = .T.
  378.                     active = 2
  379.  
  380.                 otherwise
  381.                     error = 2    
  382.             endcase
  383.  
  384.         case active = 2
  385.             exp1 = stack_item
  386.             if error_on
  387.                 if if("."$exp1, file(exp1), file("&exp1..dbf"))
  388.                     file = .T.
  389.                 else
  390.                     error = 13
  391.                 endif
  392.             else
  393.                 file = .T.
  394.             endif
  395.             active = 0
  396.     endcase
  397. enddo
  398.  
  399. do case
  400.     case error = 2 .or. active <> 0
  401.         ERRS2 = .T.
  402.  
  403.     case error = 5
  404.         ERRS5 = .T.
  405.  
  406.     case error = 13
  407.         ERRS13 = .T.
  408.  
  409.     case blank
  410.         executor = "DBF_NTX"
  411.         DBF_NTX18 = .T.
  412.  
  413.     case from .and. file
  414.         executor = "DBF_NTX"
  415.         DBF_NTX31 = .T.
  416. endcase
  417.  
  418. return
  419.  
  420. *
  421. ** eoproc append
  422.  
  423.  
  424. **
  425. * Procedure ASSIGN
  426. * kjs, 04/22/86
  427. * Evaluates stack for assignment operator "=".
  428. * Sets execution class macro, class execution flag(s) and command line
  429. * substitution macros.
  430. *
  431.  
  432. procedure assign
  433.  
  434. private stack_ptr, equal, exp, array
  435.  
  436. stack_ptr = 1
  437. store .F. to equal, exp, array
  438.  
  439. do while stack_ptr <= max_ptr
  440.     do case
  441.         case stack_ptr = 1
  442.             var1 = stack[stack_ptr]
  443.             stack_ptr = stack_ptr + 1
  444.             if stack_ptr <= max_ptr
  445.                 if "["$stack[stack_ptr]
  446.                     var1 = var1 + stack[stack_ptr]
  447.                     stack_ptr = stack_ptr + 1
  448.                 endif
  449.             endif
  450.             if "["$var1
  451.                 string = var1
  452.                 var1 = ""
  453.                 open_ptr = at("[",string)
  454.                 close_ptr = at("]",string)
  455.                 var1 = substr(string, 1, (open_ptr - 1))
  456.                 exp1 = substr(string,(open_ptr+1),(close_ptr-open_ptr-1))
  457.                 array = .T.
  458.             endif
  459.  
  460.         case stack[stack_ptr] = "="
  461.             equal = .T.
  462.             exp = get_expr1("exp2")
  463.     endcase
  464. enddo
  465.  
  466. if equal
  467.     if exp
  468.         executor = "VARS"
  469.         if array
  470.             VARS12 = .T.
  471.         else
  472.             VARS9 = .T.
  473.         endif
  474.     else
  475.        ERRS2 = .F.
  476.     endif
  477. else
  478.     ERRS1 = .T.
  479. endif
  480.  
  481. return
  482.  
  483. *
  484. ** eoproc assign
  485.  
  486.  
  487. ***
  488. * Procedure AT
  489. * kjs, 04/22/86
  490. * Evaluates stack for @ token.
  491. * Sets execution class macro, class execution flag(s) and command line
  492. * substitution macros.
  493. *
  494.  
  495. procedure at
  496.  
  497. set exact on
  498.  
  499. private at, clear, box, say, say_part, get, get_part, pic1, pic2, range,;
  500.     valid, xy, tlbr, co_num, stack_ptr, stack_item, active, null
  501.  
  502. store .F. to at, clear, box, say, say_part, get, get_part, pic1, pic2,;
  503.     range, valid, xy, tlbr
  504.  
  505. co_num = "1"
  506. stack_ptr = 1
  507. active = 1        && 0 = done, 1 = processing say, 2 = processing get.
  508.  
  509. do while stack_ptr <= max_ptr .and. !err()
  510.  
  511.     stack_item = upper(stack[stack_ptr])
  512.  
  513.     do case
  514.         case stack_item = "@"
  515.             null = get_expr1("coord&co_num")
  516.             co_num = str(val(co_num)+1,1)
  517.  
  518.         case stack_item = ","
  519.             null = get_expr1("coord&co_num")
  520.             co_num = str(val(co_num)+1,1)
  521.  
  522.         case stack_item = "BOX"
  523.             box = .T.
  524.             null = get_expr1("box_exp")
  525.  
  526.         case stack_item = "SAY"
  527.             active = 1
  528.             say = .T.
  529.             say_part = get_expr1("say_exp")
  530.  
  531.         case stack_item = "GET"
  532.             active = 2
  533.             get = .T.
  534.             get_part = get_expr1("get_exp")
  535.  
  536.         case cmd_abbr(stack_item, "PICTURE")
  537.             do case
  538.                 case say .and. !get
  539.                     pic1 = .T.
  540.                     null = get_expr1("say_pict")
  541.  
  542.                 case get .and. !say
  543.                     pic2 = .T.
  544.                     null = get_expr1("get_pict")
  545.  
  546.                 case say .and. get
  547.                     if active = 1        && if processing a say.
  548.                         pic1 = get_expr1("say_pict")
  549.                     else                 && if processing a get.
  550.                         pic2 = get_expr1("get_pict")
  551.                     endif
  552.  
  553.                 otherwise
  554.                     ERRS2 = .T.
  555.             endcase
  556.  
  557.         case cmd_abbr(stack_item, "CLEAR")
  558.             clear = .T.
  559.             stack_ptr = stack_ptr + 1
  560.  
  561.         case cmd_abbr(stack_item, "RANGE")
  562.             range = .T.
  563.             null = get_expr1("rng_exp1")
  564.             null = get_expr1("rng_exp2")
  565.  
  566.         case cmd_abbr(stack_item, "VALID")
  567.             valid = .T.
  568.             null = get_expr1("valid_exp")
  569.  
  570.         otherwise
  571.             ERRS2 = .T.
  572.     endcase
  573. enddo
  574.  
  575. set exact &exact_stat
  576.  
  577. if !err()
  578.  
  579.     if !empty(coord1) .and. !empty(coord2)
  580.         if !empty(coord3) .and. !empty(coord4)
  581.             tlbr = .T.
  582.         else
  583.             xy = .T.
  584.         endif
  585.     else
  586.         ERRS2 = .T.
  587.     endif
  588.  
  589.     do case
  590.         case xy .and. !say .and. !get .and. !clear .and. !box
  591.             executor = "SCRN"
  592.             SCRN1 = .T.
  593.     
  594.         case xy .and. clear .and. !say .and. !get .and. !box
  595.             executor = "SCRN"
  596.             SCRN2 = .T.
  597.  
  598.         case xy .and. say .and. !get
  599.             do case
  600.                 case !say_part
  601.                     ERRS2 = .T.
  602.  
  603.                 case !pic1 .and. !clear .and. !range .and. !valid
  604.                     executor = "SCRN"
  605.                     SCRN3 = .T.
  606.  
  607.                 case pic1 .and. !clear .and. !range .and. !valid
  608.                     executor = "SCRN"
  609.                     SCRN4 = .T.
  610.  
  611.                 otherwise
  612.                     ERRS1 = .T.
  613.             endcase
  614.  
  615.         case xy .and. get .and. !say
  616.             do case
  617.                 case !get_part
  618.                     ERRS2 = .T.
  619.  
  620.                 case !pic2 .and. !range .and. !valid
  621.                     executor = "SCRN"
  622.                     SCRN5 = .T.
  623.  
  624.                 case pic2 .and. !range .and. !valid
  625.                     executor = "SCRN"
  626.                     SCRN6 = .T.
  627.  
  628.                 case !pic2 .and. range .and. !valid
  629.                     executor = "SCRN"
  630.                     SCRN7 = .T.
  631.  
  632.                 case !pic2 .and. !range .and. valid
  633.                     executor = "SCRN"
  634.                     SCRN8 = .T.
  635.  
  636.                 case pic2 .and. !range .and. valid
  637.                     executor = "SCRN"
  638.                     SCRN10 = .T.
  639.  
  640.                 case pic2 .and. range .and. !valid
  641.                     executor = "SCRN"
  642.                     SCRN11 = .T.
  643.  
  644.                 otherwise
  645.                     ERRS2 = .T.
  646.             endcase
  647.  
  648.         case xy .and. say .and. get
  649.             do case
  650.                 case !say_part .or. !get_part
  651.                     ERRS2 = .T.
  652.  
  653.                 case !pic1 .and. !pic2 .and. !range .and. !valid
  654.                     executor = "SCRN"
  655.                     SCRN13 = .T.
  656.  
  657.                 case pic1 .and. !pic2 .and. !range .and. !valid
  658.                     executor = "SCRN"
  659.                     SCRN14 = .T.
  660.  
  661.                 case pic1 .and. pic2 .and. !range .and. !valid
  662.                     executor = "SCRN"
  663.                     SCRN15 = .T.
  664.  
  665.                 case pic1 .and. pic2 .and. range .and. !valid
  666.                     executor = "SCRN"
  667.                     SCRN16 = .T.
  668.  
  669.                 case pic1 .and. pic2 .and. !range .and. valid
  670.                     executor = "SCRN"
  671.                     SCRN17 = .T.
  672.  
  673.                 case !pic1 .and. pic2 .and. !range .and. !valid
  674.                     executor = "SCRN"
  675.                     SCRN19 = .T.
  676.  
  677.                 case !pic1 .and. pic2 .and. range .and. !valid
  678.                     executor = "SCRN"
  679.                     SCRN20 = .T.
  680.  
  681.                 case !pic1 .and. pic2 .and. !range .and. valid
  682.                     executor = "SCRN"
  683.                     SCRN21 = .T.
  684.  
  685.                 otherwise
  686.                     ERRS2 = .T.
  687.             endcase
  688.  
  689.         case tlbr .and. box
  690.             executor = "SCRN"
  691.             SCRN22 = .T.
  692.  
  693.         otherwise
  694.             ERRS1 = .T.
  695.     endcase
  696. endif
  697.  
  698. return
  699.  
  700. *
  701. ** eoproc at
  702.  
  703.  
  704. ***
  705. * Procedure CALL
  706. * kjs, 05/28/86, 10/08/86
  707. * Evaluates stack for CALL verb.
  708. * Sets execution class macro, class execution flag(s) and command line
  709. * substitution macros.
  710. *
  711.  
  712. procedure call
  713.  
  714. private stack_ptr, stack_item, xproc, with, params, active, error,;
  715.   item_ok
  716.  
  717. stack_ptr = 2
  718. store .F. to xproc, with, params, item_ok
  719. active = 1       && 0 = done, 1 = procedure, 2 = WITH toke and params.
  720. error = 0
  721.  
  722. do while stack_ptr <= max_ptr .and. error = 0
  723.  
  724.     stack_item = ""
  725.     stack_item = stack[stack_ptr]
  726.  
  727.     do case
  728.         case active = 0
  729.             error = 2
  730.  
  731.         case active = 1
  732.             exp1 = stack_item
  733.             xproc = .T.
  734.             stack_ptr = stack_ptr + 1
  735.             if stack_ptr > max_ptr
  736.                 active = 0
  737.             else
  738.                 active = 2
  739.             endif
  740.  
  741.         case active = 2
  742.             if upper(stack_item) = "WITH"
  743.                 with = .T.
  744.                 params = get_list("E")
  745.                 if params
  746.                     active = 0
  747.                 else
  748.                     error = 2
  749.                 endif
  750.             else
  751.                 error = 2
  752.             endif
  753.     endcase
  754. enddo
  755.  
  756. do case
  757.     case error = 2 .or. active <> 0
  758.         ERRS2 = .T.
  759.  
  760.     case xproc .and. !with .and. !params
  761.         executor = "CALLS"
  762.         CALLS4 = .T.
  763.  
  764.     case xproc .and. with .and. params
  765.         executor = "CALLS"
  766.         CALLS5 = .T.
  767. endcase
  768.  
  769. return
  770.  
  771. *
  772. ** eoproc call
  773.  
  774.  
  775. ***    
  776. * Procedure CLEAR
  777. * kjs, 04/22/86
  778. * Evaluates stack for CLEAR verb.
  779. * Sets execution class macro, class execution flag(s) and command line
  780. * substitution macros.
  781. *
  782.  
  783. procedure clear
  784.  
  785. if stack_ptr = 1
  786.     executor = "SCRN"
  787.     SCRN23 = .T.
  788. else
  789.     ERRS2 = .T.
  790. endif
  791.  
  792. return
  793.  
  794. *
  795. ** eoproc clear
  796.  
  797.  
  798. ***
  799. * Procedure COLOR
  800. * kjs, 05/02/86
  801. * Evaluates stack for SET COLOR command, called from SET procedure.
  802. * Sets execution class macro, class execution flag(s) and command line
  803. * substitution macros.
  804. *
  805.  
  806. procedure color
  807.  
  808. private stack_ptr, to
  809.  
  810. stack_ptr = 3
  811. to = .F.
  812.  
  813. if stack_ptr <= max_ptr
  814.     if upper(stack[stack_ptr]) = "TO"
  815.         to = .T.
  816.         stack_ptr = stack_ptr + 1
  817.         do while stack_ptr <= max_ptr         && build up color string.
  818.             exp1 = exp1 + stack[stack_ptr]
  819.             stack_ptr = stack_ptr + 1
  820.         enddo
  821.     endif
  822. endif
  823.  
  824. if to
  825.     executor = "SETS"
  826.     SETS1 = .T.
  827. else
  828.     ERRS2 = .T.
  829. endif
  830.  
  831. return
  832.  
  833. *
  834. ** eoproc color
  835.  
  836.  
  837. ***
  838. * Procedure COPY
  839. * kjs, 09/16/86
  840. * Evaluates stack for COPY verb.
  841. * Simple non-conditional and non-scoped syntax.
  842. * Sets execution class macro, class execution flag(s) and command line
  843. * substitution macros.
  844. *
  845.  
  846. procedure copy
  847.  
  848. private stack_ptr, stack_item, item_ok, struc, to, target, active, error
  849.  
  850. stack_ptr = 2
  851. store .F. to struc, to, target, item_ok
  852. active = 0            && 0 = done, 1 = STRU or TO toke, 2 = target.
  853. error = 0
  854.  
  855. if error_on .and. !DBF_OPEN
  856.     error = 5
  857. else
  858.     active = 1
  859. endif
  860.  
  861. do while stack_ptr <= max_ptr .and. error = 0
  862.  
  863.     stack_item = ""
  864.     item_ok = get_stack("stack_item")
  865.  
  866.     do case
  867.         case active = 0
  868.             error = 2
  869.  
  870.         case active = 1
  871.             do case 
  872.                 case cmd_abbr(upper(stack_item), "STRUCTURE") .and. !struc
  873.                     struc = .T.
  874.                     active = 1
  875.  
  876.                 case upper(stack_item) == "TO"
  877.                     to = .T.
  878.                     active = 2
  879.  
  880.                 otherwise
  881.                     error = 2
  882.             endcase
  883.  
  884.         case active = 2
  885.             exp1 = stack_item
  886.             target = .T.
  887.             active = 0
  888.     endcase
  889. enddo
  890.  
  891. do case
  892.     case error = 2 .or. active <> 0
  893.         ERRS2 = .T.
  894.  
  895.     case error = 5
  896.         ERRS5 = .T.
  897.  
  898.     case !struc .and. to .and. target
  899.         executor = "DBF_NTX"
  900.         DBF_NTX28 = .T.
  901.  
  902.     case struc .and. to .and. target
  903.         executor = "DBF_NTX"
  904.         DBF_NTX29 = .T.
  905.  
  906.     otherwise
  907.         ERRS2 = .T.
  908. endcase
  909.  
  910. return
  911.  
  912. *
  913. ** eoproc copy
  914.  
  915.  
  916. ***
  917. * Procedure CONFIRM
  918. * kjs, 04/28/86, 10/08/86
  919. * Evaluates stack for SET CONFIRM command.  Called procedure SET.
  920. * Sets execution class macro, class execution flag(s) and command line
  921. * substitution macros.
  922. *
  923.  
  924. procedure confirm
  925.  
  926. private stack_ptr, stack_item, item_ok, toggle
  927.  
  928. stack_ptr = 3
  929. stack_item = ""
  930. store .F. to item_ok, toggle
  931.  
  932. item_ok = get_stack("stack_item")
  933.  
  934. if item_ok .and. upper(stack_item)$"ON^OFF"
  935.     toggle = .T.
  936. else
  937.     error = 2
  938. endif
  939.  
  940. if toggle
  941.     executor = "SETS"
  942.     SETS2 = .T.
  943. else
  944.     ERRS2 = .T.
  945. endif
  946.  
  947. return
  948.  
  949. *
  950. ** eoproc confirm
  951.  
  952.  
  953. ***
  954. * Procedure calls
  955. * kjs, 06/12/86
  956. * Executor for CALLS class of commands.
  957. *
  958.  
  959. procedure calls
  960.  
  961. private i, qqq
  962.  
  963. do case
  964.     case CALLS1
  965.         do &exp1
  966.         CALLS1 = .F.
  967.  
  968.     case CALLS2
  969.         for i = 0 to 9
  970.             qqq = "list"+str(i,1)
  971.             if (empty(&qqq))
  972.                 &qqq = "[]"
  973.             end
  974.         next
  975.  
  976.         do &exp1 with &list0, &list1, &list2, &list3, &list4, &list5, &list6,;
  977.             &list7, &list8, &list9
  978.         CALLS2 = .F.
  979.  
  980.     case CALLS3
  981.         run &exp1
  982.         ?
  983.         CALLS3 = .F.
  984.  
  985.     case CALLS4
  986.         call &exp1
  987.         CALLS4 = .F.
  988.  
  989.     case CALLS5
  990.         for i = 0 to 9
  991.             qqq = "list"+str(i,1)
  992.             if (empty(&qqq))
  993.                 &qqq = "[]"
  994.             end
  995.         next
  996.  
  997.         call &exp1 with &list0, &list1, &list2, &list3, &list4, &list5, &list6
  998.         CALLS5 = .F.
  999.  
  1000.     case CALLS6
  1001.         quit
  1002.         CALLS6 = .F.
  1003.  
  1004.     case CALLS7
  1005.         ** RETURN is not executed at this level **
  1006.  
  1007. endcase
  1008.  
  1009. return
  1010.  
  1011. *
  1012. ** eoproc calls
  1013.  
  1014.  
  1015. ***
  1016. * Procedure dbf_ntx
  1017. * kjs, 06/12/86
  1018. * Executor for DBF_NTX class of commands.
  1019. *
  1020.  
  1021. procedure dbf_ntx
  1022.  
  1023. private more, disp_row, i, qqq
  1024.  
  1025. do case
  1026.     case DBF_NTX1 
  1027.         use
  1028.         DBF_NTX1 = .F.
  1029.         DBF_OPEN = .F.
  1030.         NTX_OPEN = .F.
  1031.  
  1032.     case DBF_NTX2
  1033.         use &dbf_file
  1034.         DBF_NTX2 = .F.
  1035.         DBF_OPEN = .T.
  1036.         NTX_OPEN = .F.
  1037.  
  1038.     case DBF_NTX3
  1039.         use &dbf_file index &list0, &list1, &list2, &list3, &list4, &list5,;
  1040.             &list6, &list7, &list8, &list9
  1041.         DBF_NTX3 = .F.
  1042.         DBF_OPEN = .T.
  1043.         NTX_OPEN = .T.
  1044.  
  1045.     case DBF_NTX4
  1046.         use &dbf_file alias &exp2
  1047.         DBF_NTX4 = .F.
  1048.         DBF_OPEN = .T.
  1049.         NTX_OPEN = .F.
  1050.  
  1051.     case DBF_NTX5
  1052.         use &dbf_file index &list0, &list1, &list2, &list3, &list4, &list5,;
  1053.             &list6, &list7, &list8, &list9 alias &exp2
  1054.         DBF_NTX5 = .F.
  1055.         DBF_OPEN = .T.
  1056.         NTX_OPEN = .T.
  1057.  
  1058.     case DBF_NTX32
  1059.         use &dbf_file exclusive
  1060.         DBF_NTX32 = .F.
  1061.         DBF_OPEN = .T.
  1062.         NTX_OPEN = .F.
  1063.  
  1064.     case DBF_NTX33
  1065.         use &dbf_file index &list0, &list1, &list2, &list3, &list4, &list5,;
  1066.             &list6, &list7, &list8, &list9 exclusive
  1067.         DBF_NTX33 = .F.
  1068.         DBF_OPEN = .T.
  1069.         NTX_OPEN = .T.
  1070.  
  1071.     case DBF_NTX34
  1072.         use &dbf_file alias &exp2 exclusive
  1073.         DBF_NTX34 = .F.
  1074.         DBF_OPEN = .T.
  1075.         NTX_OPEN = .F.
  1076.  
  1077.     case DBF_NTX35
  1078.         use &dbf_file index &list0, &list1, &list2, &list3, &list4, &list5,;
  1079.             &list6, &list7, &list8, &list9 alias &exp2 exclusive
  1080.         DBF_NTX35 = .F.
  1081.         DBF_OPEN = .T.
  1082.         NTX_OPEN = .T.
  1083.  
  1084.     case DBF_NTX6
  1085.         ? "Indexing file on " + upper(exp1) + " to " + upper(ntx_file)
  1086.         index on &exp1 to &ntx_file
  1087.         ? "Index file creation complete"
  1088.         NTX_OPEN = .T.
  1089.         DBF_NTX6 = .F.
  1090.  
  1091.     case DBF_NTX7
  1092.         goto &exp1
  1093.         DBF_NTX7 = .F.
  1094.  
  1095.     case DBF_NTX8
  1096.         goto top
  1097.         DBF_NTX8 = .F.
  1098.  
  1099.     case DBF_NTX9
  1100.         goto bottom
  1101.         DBF_NTX9 = .F.
  1102.  
  1103.     case DBF_NTX10
  1104.         skip
  1105.         if EOF()
  1106.             ? "End of file encountered"
  1107.         endif
  1108.         if BOF()
  1109.             ? "Beginning of file encountered"
  1110.         endif
  1111.         DBF_NTX10 = .F.
  1112.  
  1113.     case DBF_NTX11
  1114.         skip &exp1
  1115.         if EOF()
  1116.             ? "End of file encountered"
  1117.         endif
  1118.         if BOF()
  1119.             ? "Beginning of file encountered"
  1120.         endif
  1121.         DBF_NTX11 = .F.
  1122.  
  1123.     case DBF_NTX12
  1124.         go top
  1125.         do list_do with .T., .F.
  1126.         DBF_NTX12 = .F.
  1127.  
  1128.     case DBF_NTX13
  1129.         go top
  1130.         for i = 0 to 9
  1131.             qqq = "list"+str(i,1)
  1132.             if (empty(&qqq))
  1133.                 &qqq = "[]"
  1134.             end
  1135.         next
  1136.  
  1137.         list &list0, &list1, &list2, &list3, &list4, &list5, &list6, &list7,;
  1138.             &list8, &list9 while inkey() <> 27
  1139.         DBF_NTX13 = .F.
  1140.  
  1141.     case DBF_NTX14
  1142.         do list_do with .T., .T.
  1143.         DBF_NTX14 = .F.
  1144.  
  1145.     case DBF_NTX15
  1146.         for i = 0 to 9
  1147.             qqq = "list"+str(i,1)
  1148.             if (empty(&qqq))
  1149.                 &qqq = "[]"
  1150.             end
  1151.         next
  1152.  
  1153.         display &list0, &list1, &list2, &list3, &list4, &list5, &list6,;
  1154.             &list7, &list8, &list9
  1155.         DBF_NTX15 = .F.
  1156.  
  1157.     case DBF_NTX16
  1158.         select &exp1
  1159.         DBF_NTX16 = .F.
  1160.  
  1161.     case DBF_NTX17
  1162.         seek &exp1
  1163.         if eof()
  1164.             ? "NOT Found"
  1165.         else
  1166.             ? "Found"
  1167.         endif
  1168.         DBF_NTX17 = .F.
  1169.  
  1170.     case DBF_NTX18
  1171.         append blank
  1172.         DBF_NTX18 = .F.
  1173.  
  1174.     case DBF_NTX19
  1175.         do do_cnd_scp with "delete_it"  && calls condition/scope logic.
  1176.         DBF_NTX19 = .F.
  1177.  
  1178.     case DBF_NTX22
  1179.         dir &exp1
  1180.         DBF_NTX22 = .F.
  1181.  
  1182.     case DBF_NTX20
  1183.         do do_cnd_scp with "recall_it"  && calls condition/scope logic.
  1184.         DBF_NTX20 = .F.
  1185.  
  1186.     case DBF_NTX21
  1187.         pack
  1188.         DBF_NTX21 = .F.
  1189.  
  1190.     case DBF_NTX23
  1191.         type &exp1
  1192.         DBF_NTX23 = .F.
  1193.  
  1194.     case DBF_NTX24
  1195.         unlock
  1196.         DBF_NTX24 = .F.
  1197.  
  1198.     case DBF_NTX25
  1199.         unlock all
  1200.         DBF_NTX25 = .F.
  1201.  
  1202.     case DBF_NTX26
  1203.         replace &var1 with &exp1
  1204.         DBF_NTX26 = .F.
  1205.  
  1206.     case DBF_NTX27
  1207.         replace all &var1 with &exp1
  1208.         DBF_NTX27 = .F.
  1209.  
  1210.     case DBF_NTX28
  1211.         copy to &exp1
  1212.         DBF_NTX28 = .F.
  1213.  
  1214.     case DBF_NTX29
  1215.         copy structure to &exp1
  1216.         DBF_NTX29 = .F.
  1217.  
  1218.     case DBF_NTX30
  1219.         erase &exp1
  1220.         DBF_NTX30 = .F.
  1221.  
  1222.     case DBF_NTX31
  1223.         append from &exp1
  1224.         DBF_NTX31 = .F.
  1225.  
  1226.   case DBF_NTX36
  1227.      ? "Are you sure? (Y/N)" 
  1228.      more = .T.
  1229.      disp_row = row()
  1230.  
  1231.      do while more
  1232.         more = !(ltrim(str(inkey(0),3))$"13^27^78^89^110^121")
  1233.         if lastkey() > 31 .and. lastkey() < 127
  1234.            @ disp_row, 21 say chr(lastkey()) 
  1235.         endif
  1236.      enddo
  1237.  
  1238.      if upper(chr(lastkey())) = "Y"
  1239.         zap
  1240.      endif
  1241.  
  1242.      DBF_NTX36 = .F.
  1243.  
  1244. endcase
  1245.  
  1246. return
  1247.  
  1248. *
  1249. ** eoproc dbf_ntx
  1250.  
  1251.  
  1252. ***
  1253. * Procedure DECIMAL
  1254. * kjs, 04/28/86, 10/08/86
  1255. * Evaluates the stack for the SET DECIMALS command.  Called SET procedure.
  1256. * Sets execution class macro, class execution flag(s) and command line
  1257. * substitution macros.
  1258. *
  1259.  
  1260. procedure decimal
  1261.  
  1262. private stack_ptr, to, null
  1263.  
  1264. stack_ptr = 3
  1265. to = .F.
  1266.  
  1267. if stack_ptr <= max_ptr
  1268.     if upper(stack[stack_ptr]) = "TO"
  1269.         to = .T.
  1270.         null = get_expr1("exp1")
  1271.     endif
  1272. endif
  1273.  
  1274. if to
  1275.     executor = "SETS"
  1276.     SETS3 = .T.
  1277. else
  1278.     ERRS2 = .T.
  1279. endif
  1280.  
  1281. return
  1282.  
  1283. *
  1284. ** eoproc decimal
  1285.  
  1286.  
  1287. ***
  1288. * Procedure DECLARE
  1289. * kjs, 04/22/86, 10/08/86
  1290. * Evaluates the stack for the DECLARE verb.
  1291. * Sets execution class macro, class execution flag(s) and command line
  1292. * substitution macros.
  1293. *
  1294.  
  1295. procedure declare
  1296.  
  1297. private stack_ptr, string
  1298.  
  1299. stack_ptr = 2
  1300. string = ""
  1301.  
  1302. if get_stack("string")
  1303.     open_ptr = at("[",string)
  1304.     close_ptr = at("]",string)
  1305.     var1 = substr(string, 1, (open_ptr - 1))
  1306.     exp1 = substr(string,(open_ptr+1),(close_ptr-open_ptr-1))
  1307.     executor = "VARS"
  1308.     VARS10 = .T.
  1309. else
  1310.     ERRS2 = .T.
  1311. endif
  1312.  
  1313. return
  1314.  
  1315. *
  1316. ** eoproc declare
  1317.  
  1318.  
  1319. ***
  1320. * Procedure DEFAULT
  1321. * kjs, 05/08/86
  1322. * Evaluates the stack for the SET DEFAULT command.  Called by SET procedure.
  1323. * Sets execution class macro, class execution flag(s) and command line
  1324. * substitution macros.
  1325. *
  1326.  
  1327. procedure default
  1328.  
  1329. private stack_ptr, to
  1330.  
  1331. stack_ptr = 3
  1332. store .F. to to, drive
  1333.  
  1334. if stack_ptr <= max_ptr
  1335.     if upper(stack[stack_ptr]) = "TO"
  1336.         to = .T.
  1337.         drive = get_expr1("exp1")
  1338.     endif
  1339. endif
  1340.  
  1341. if to .and. drive
  1342.     executor = "SETS"
  1343.     SETS4 = .T.
  1344. else
  1345.     ERRS2 = .T.
  1346. endif
  1347.  
  1348. return
  1349.  
  1350. *
  1351. ** eoproc default
  1352.  
  1353.  
  1354. ***
  1355. * Procedure DELETE
  1356. * kjs, 05/14/86
  1357. * Analyze the stack for the DELETE verb.
  1358. * Sets execution class macro, class execution flag(s) and command line
  1359. * substitution macros.
  1360. * UDF CND_SCP() used to set condition and scope control variables.
  1361. *
  1362.  
  1363. procedure delete
  1364.  
  1365. private stack_ptr, for, while, next, record, all, stack_item
  1366.  
  1367. stack_ptr = 2
  1368. store .F. to for, while, next, record, all, condition
  1369. scope = 0
  1370.  
  1371. if cnd_scp()       && no errors during condition and scope analysis.
  1372.  
  1373.     do case
  1374.         case for .or. while .or. all .or. next .or. record
  1375.             ** w/ w/o scope and/or condition. **
  1376.             if DBF_OPEN .or. !error_on
  1377.                 executor = "DBF_NTX"
  1378.                 DBF_NTX19 = .T.
  1379.             else    
  1380.                 ERRS5 = .T.
  1381.             endif
  1382.  
  1383.         case !for .and. !while .and. !all .and. !next .and. !record;
  1384.             .and. max_ptr = 1
  1385.             ** w/o scope or conditional **
  1386.             if DBF_OPEN .or. !error_on
  1387.                 executor = "DBF_NTX"
  1388.                 DBF_NTX19 = .T.
  1389.                 scope = 1     && use RECORD (scope = 1) for single delete.
  1390.                 exp3 = str(recno())
  1391.  
  1392.                 if &exp3 > lastrec()
  1393.                     ERRS6 = .T.
  1394.                     DBF_NTX19 = .F.
  1395.                 else
  1396.                     exp3 = "recno() = &exp3"
  1397.                 endif
  1398.             else
  1399.                 ERRS5 = .T.
  1400.             endif
  1401.  
  1402.         otherwise        
  1403.             ERRS2 = .T.
  1404.     endcase        
  1405.  
  1406. endif
  1407.  
  1408. return
  1409.  
  1410. *
  1411. ** eoproc delete
  1412.  
  1413.  
  1414. ***
  1415. * Procedure delete_it
  1416. * kjs, 05/14/86
  1417. * Executes a record delete.  Called by procedure DO_CND_SCP.
  1418. *
  1419.  
  1420. procedure delete_it
  1421.  
  1422. delete
  1423.  
  1424. return
  1425.  
  1426. *
  1427. ** eoproc delete_it
  1428.  
  1429.  
  1430. ***
  1431. * Procedure DELIM
  1432. * kjs, 05/07/86
  1433. * Evaluates stack for SET DELIMITERS command.  Called by procedure
  1434. * SET.
  1435. * Sets execution class macro, class execution flag(s) and command line
  1436. * substitution macros.
  1437. *
  1438.  
  1439. procedure delim
  1440.  
  1441. private stack_ptr, stack_item, to, switch, string, error, active, null
  1442.  
  1443. stack_ptr = 3
  1444. store .F. to to, switch, string, null
  1445. active = 1   && 0 = done, 1 = TO token or toggle, 2 = string/DEFAULT token.
  1446. error = 0
  1447.  
  1448. do while stack_ptr <= max_ptr .and. error = 0
  1449.  
  1450.     stack_item = ""
  1451.     null = get_stack("stack_item")
  1452.  
  1453.     do case
  1454.         case active = 0
  1455.             error = 2
  1456.  
  1457.         case active = 1
  1458.             do case 
  1459.                 case upper(stack_item) == "TO"
  1460.                     to = .T.
  1461.                     active = 2
  1462.  
  1463.                 case upper(stack_item)$"ON^OFF"
  1464.                     exp1 = stack_item
  1465.                     switch = .T.
  1466.                     active = 0
  1467.  
  1468.                 otherwise
  1469.                     error = 2
  1470.             endcase
  1471.  
  1472.         case active = 2
  1473.             exp1 = stack_item
  1474.             string = .T.
  1475.             active = 0
  1476.     endcase
  1477. enddo
  1478.  
  1479. do case
  1480.     case error = 2 .or. active <> 0
  1481.         ERRS2 = .T.
  1482.  
  1483.     case to .and. string
  1484.         executor = "SETS"
  1485.         SETS6 = .T.
  1486.  
  1487.     case switch
  1488.         executor = "SETS"
  1489.         SETS5 = .T.
  1490. endcase
  1491.  
  1492. return
  1493.  
  1494. *
  1495. ** eoproc delim
  1496.  
  1497.  
  1498. ***
  1499. * Procedure DIR
  1500. * kjs, 04/22/86
  1501. * Sets execution class macro, class execution flag(s) and command line
  1502. * substitution macros from the command line not the stack.
  1503. *
  1504.  
  1505. procedure dir
  1506.  
  1507. exp1 = substr(command, len(stack[1]) + 1)
  1508.  
  1509. executor = "DBF_NTX"
  1510. DBF_NTX22 = .T.
  1511.  
  1512. *
  1513. ** eoproc dir
  1514.  
  1515.  
  1516. ***
  1517. * Procedure DISPLAY
  1518. * kjs, 04/22/86
  1519. * Evaluates the stack for the DISPLAY verb.
  1520. * Sets execution class macro, class execution flag(s) and command line
  1521. * substitution macros.
  1522. *
  1523.  
  1524. procedure display
  1525.  
  1526. private stack_ptr
  1527.  
  1528. stack_ptr = 1
  1529.  
  1530. if DBF_OPEN .or. !error_on
  1531.     if max_ptr = 1
  1532.         executor = "DBF_NTX"
  1533.         DBF_NTX14 = .T.
  1534.     else
  1535.         if get_list("E")
  1536.             executor = "DBF_NTX"
  1537.             DBF_NTX15 = .T.
  1538.         else
  1539.             ERRS2 = .T.
  1540.         endif
  1541.     endif
  1542. else
  1543.     ERRS5 = .T.
  1544. endif
  1545.  
  1546. return
  1547.  
  1548. *
  1549. ** eoproc display
  1550.  
  1551.  
  1552. ***
  1553. * Procedure DO
  1554. * kjs, 05/28/86, 10/08/86
  1555. * Evaluates the stack for the DO verb.
  1556. * Sets execution class macro, class execution flag(s) and command line
  1557. * substitution macros.
  1558. *
  1559.  
  1560. procedure do
  1561.  
  1562. private stack_ptr, stack_item, item_ok, xproc, with, params, active, error
  1563.  
  1564. stack_ptr = 2
  1565. store .F. to xproc, with, params, item_ok
  1566. active = 1            && 0 = done, 1 = procedure, 2 = WITH toke and params.
  1567. error = 0
  1568.  
  1569. do while stack_ptr <= max_ptr .and. error = 0
  1570.  
  1571.     stack_item = ""
  1572.     stack_item = stack[stack_ptr]
  1573.  
  1574.     do case
  1575.         case active = 0
  1576.             error = 2
  1577.  
  1578.         case active = 1
  1579.             exp1 = stack_item
  1580.             xproc = .T.
  1581.             stack_ptr = stack_ptr + 1
  1582.             if stack_ptr > max_ptr
  1583.                 active = 0
  1584.             else
  1585.                 active = 2
  1586.             endif
  1587.  
  1588.         case active = 2
  1589.             if upper(stack_item) = "WITH"
  1590.                 with = .T.
  1591.                 params = get_list("E")
  1592.                 if params
  1593.                     active = 0
  1594.                 else
  1595.                     error = 2
  1596.                 endif
  1597.             else
  1598.                 error = 2
  1599.             endif
  1600.     endcase
  1601. enddo
  1602.  
  1603. do case
  1604.     case error = 2 .or. active <> 0
  1605.         ERRS2 = .T.
  1606.  
  1607.     case xproc .and. !with .and. !params
  1608.         executor = "CALLS"
  1609.         CALLS1 = .T.
  1610.  
  1611.     case xproc .and. with .and. params
  1612.         executor = "CALLS"
  1613.         CALLS2 = .T.
  1614. endcase
  1615.  
  1616. return
  1617.  
  1618. *
  1619. ** eoproc do
  1620.  
  1621.  
  1622. ***
  1623. * Procedure do_cnd_scp
  1624. * kjs, 05/09/86
  1625. * Executes logic for conditional and scoped commands.  Called by executor
  1626. * procedures.  Calls to procedures containing single iterations of command
  1627. * being executed.
  1628. *
  1629.  
  1630. procedure do_cnd_scp
  1631.  
  1632. parameters action_proc
  1633.  
  1634. private more, count, do_it
  1635. more = .T.
  1636. count = 0
  1637.  
  1638. if rewind_dbf
  1639.     go top
  1640. endif
  1641.  
  1642. do while more .and. !EOF()
  1643.     do_it = .F.
  1644.      
  1645.     if scope > 0                    && handles scoping stuff.
  1646.         do case
  1647.             case scope = 1          && record.
  1648.                 if &exp3
  1649.                     do_it = .T.
  1650.                     more = .F.
  1651.                 endif
  1652.  
  1653.             case scope = 2          && all.
  1654.                 do_it = .T.
  1655.  
  1656.             case scope = 3          && next.
  1657.                 count = count + 1
  1658.                 if count <= &exp3
  1659.                     do_it = .T.
  1660.                 else
  1661.                     do_it = .F.
  1662.                     more = .F.
  1663.                 endif
  1664.  
  1665.         endcase
  1666.     endif
  1667.  
  1668.     if condition                    && handles conditional stuff.
  1669.  
  1670.         if "" <> exp1
  1671.             if &exp1                && FOR condition.
  1672.                 do_it = .T.
  1673.             else
  1674.                 do_it = .F.
  1675.             endif
  1676.         endif
  1677.  
  1678.         if "" <> exp2
  1679.             if &exp2                && WHILE condition.
  1680.                 do_it = .T.
  1681.             else
  1682.                 do_it = .F.
  1683.                 more = .F.
  1684.             endif
  1685.         endif
  1686.     endif
  1687.  
  1688.     if do_it
  1689.         do &action_proc             && call single iteration of command.
  1690.     endif
  1691.  
  1692.     if more
  1693.         skip
  1694.     endif
  1695.  
  1696. enddo
  1697.  
  1698. return
  1699.  
  1700. *
  1701. ** eoproc do_cnd_scp
  1702.  
  1703.  
  1704. ***
  1705. * Procedure ERASE
  1706. * kjs, 09/23/86
  1707. * Sets execution class macro, class execution flag(s) and command line
  1708. * substitution macros from the command line.
  1709. *
  1710.  
  1711. procedure erase
  1712.  
  1713. private error
  1714.  
  1715. error = 0
  1716.  
  1717. exp1 = substr(command, len(stack[1]) + 1)
  1718.  
  1719. if !empty(exp1)
  1720.     if file(stack_item) .or. !error_on
  1721.         exp1 = stack_item
  1722.     else
  1723.         error = 13
  1724.     endif
  1725. endif
  1726.  
  1727. if error = 13
  1728.     ERRS13 = .T.
  1729. else
  1730.     executor = "DBF_NTX"
  1731.     DBF_NTX30 = .T.
  1732. endif
  1733.  
  1734. return
  1735.  
  1736. *
  1737. ** eoproc erase
  1738.  
  1739.  
  1740. ***
  1741. * Procedure errs
  1742. * kjs, 06/12/86
  1743. * Executor for the ERRS class of commands, the DOT error message system.
  1744. *
  1745.  
  1746. procedure errs
  1747.  
  1748. do case
  1749.     case ERRS1
  1750.         ? "Unrecognized command, F1 for Help."
  1751.         ERRS1 = .F.
  1752.  
  1753.     case ERRS2
  1754.         ? "Syntax error, F1 for Help."
  1755.         ERRS2 = .F.
  1756.  
  1757.     case ERRS3
  1758.         ? "Undefined expression."
  1759.         ERRS3 = .F.
  1760.  
  1761.     case ERRS4
  1762.         ? "Undefined variable : "+"&exp1"
  1763.         ERRS4 = .F.
  1764.  
  1765.     case ERRS5
  1766.         ? "Database NOT in use."
  1767.         ERRS5 = .F.
  1768.  
  1769.     case ERRS6
  1770.         ? "Record out of range."
  1771.         ERRS6 = .F.
  1772.  
  1773.     case ERRS7
  1774.         ? "Data file NOT found."
  1775.         ERRS7 = .F.
  1776.  
  1777.     case ERRS8
  1778.         ? "Unbalanced delimiters."
  1779.         ERRS8 = .F.
  1780.  
  1781.     case ERRS9
  1782.         ? "Index file NOT in use"
  1783.         ERRS9 = .F.
  1784.  
  1785.     case ERRS10
  1786.         ? "Not implemented"
  1787.         ERRS10 = .F.
  1788.  
  1789.     case ERRS11
  1790.         ? "Index file NOT found"
  1791.         ERRS11 = .F.
  1792.  
  1793.     case ERRS12
  1794.         ? "Illegal goto value"
  1795.         ERRS12 = .F.
  1796.  
  1797.     case ERRS13
  1798.         ? "File NOT found"
  1799.         ERRS13 = .F.
  1800.  
  1801.     case ERRS14
  1802.         ? "Invalid function key number, 2 - 40"
  1803.         ERRS14 = .F.
  1804.  
  1805.     case ERRS15
  1806.         ? "Missing key word"
  1807.         ERRS15 = .F.
  1808. endcase
  1809.  
  1810. return
  1811.  
  1812. *
  1813. ** eoproc errs
  1814.  
  1815.  
  1816. ***
  1817. * Procedure ESCAPE
  1818. * kjs, 05/24/86
  1819. * Evaluates stack for the SET ESCAPE command. Called by SET procedure.
  1820. * Sets execution class macro, class execution flag(s) and command line
  1821. * substitution macros.
  1822. *
  1823.  
  1824. procedure escape
  1825.  
  1826. stack_ptr = 3
  1827.  
  1828. if stack_ptr <= max_ptr
  1829.     exp1 = upper(stack[stack_ptr])
  1830.     if "&exp1"$"ON^OFF"
  1831.         executor = "SETS"
  1832.         SETS7 = .T.
  1833.     else
  1834.         ERRS2 = .T.
  1835.     endif
  1836. else
  1837.     ERRS2 = .T.
  1838. endif
  1839.  
  1840. return
  1841.  
  1842. *
  1843. ** eoproc escape
  1844.  
  1845.  
  1846. ***
  1847. * Procedure EXACT
  1848. * kjs, 05/24/86
  1849. * Evaluates the stack for SET EXACT command.  Called by SET procedure.
  1850. * Sets execution class macro, class execution flag(s) and command line
  1851. * substitution macros.
  1852. *
  1853.  
  1854. procedure exact
  1855.  
  1856. stack_ptr = 3
  1857.  
  1858. if stack_ptr <= max_ptr
  1859.     exp1 = upper(stack[stack_ptr])
  1860.     if "&exp1"$"ON^OFF"
  1861.         executor = "SETS"
  1862.         SETS20 = .T.
  1863.     else 
  1864.         ERRS2 = .T.
  1865.     endif
  1866. else
  1867.     ERRS2 = .T.
  1868. endif
  1869.  
  1870. return
  1871.  
  1872. *
  1873. ** eoproc exact
  1874.  
  1875.  
  1876. ***
  1877. * Procedure EXCLUSIVE
  1878. * kjs, 07/28/86
  1879. * Evaluates the stack for the SET EXCLUSIVE command.  Called from
  1880. * procedure SET.
  1881. * Sets execution class macro, class execution flag(s) and command
  1882. * line substitution macros.
  1883. *
  1884.  
  1885. procedure exclusive
  1886.  
  1887. stack_ptr = 3
  1888.  
  1889. if stack_ptr <= max_ptr
  1890.     exp1 = upper(stack[stack_ptr])
  1891.     if "&exp1"$"ON^OFF"
  1892.         executor = "SETS"
  1893.         SETS19 = .T.
  1894.     else
  1895.         ERRS2 = .T.
  1896.     endif
  1897. else
  1898.     ERRS2 = .T.
  1899. endif
  1900.  
  1901. return
  1902.  
  1903. *
  1904. ** eoproc exclusive
  1905.  
  1906.  
  1907. ***
  1908. * Procedure fill_lists
  1909. * kjs, 05/06/86
  1910. * Called from procedure DOT.  Fills the verb_list, lex_list, set_list and
  1911. * set_proc search strings.
  1912. *
  1913.  
  1914. procedure fill_lists
  1915.  
  1916. verb_list =    "         .!        .?        .??       .@        .ACCEPT   "+;
  1917.     ".APPEND   .CLEAR    .CLS      .DECLARE  .DELETE   .DIRECTORY.DISPLAY  "+;
  1918.     ".DO       .EXIT     .GO       .GOTO     .INDEX    .INPUT    .LIST     "+;
  1919.     ".PACK     .QUIT     .READ     .RECALL   .RELEASE  .RETURN   .RUN      "+;
  1920.     ".SEEK     .SELECT   .SET      .SKIP     .TYPE     .USE      .WAIT     "+;
  1921.     ".CALL     .UNLOCK   .REPLACE  .COPY     .ERASE    .ZAP      "
  1922.  
  1923. lex_list =     "         RUN       QUES1     QUES2     AT        ACCEPT    "+;
  1924.     "APPEND    CLEAR     CLEAR     DECLARE   DELETE    DIR       DISPLAY   "+;
  1925.     "DO        QUIT      GOTO      GOTO      INDEX     INPUT     LIST      "+;
  1926.     "PACK      QUIT      RREAD     RECALL    RELEASE   QUIT      RUN       "+;
  1927.     "SEEK      SELECT    SSET      SKIP      TYPE      USE       WWAIT     "+;
  1928.     "CALL      UNLOCK    REPLACE   COPY      ERASE     ZAP       "
  1929.  
  1930. set_list =      "          .COLOR     .CONFIRM   .DECIMALS  .DEFAULT   "+;
  1931.     ".DELIMITERS.EXACT     .ESCAPE    .EXCLUSIVE .FILTER    .FIXED     "+;
  1932.     ".FUNCTION  .INDEX     .INTENSITY .KEY       .ORDER     .PATH      "+;
  1933.     ".RELATION  .UNIQUE    "
  1934.  
  1935. set_proc =      "          COLOR      CONFIRM    DECIMAL    DEFAULT    "+;
  1936.     "DELIM      EXACT      ESCAPE     EXCLUSIVE  FILTER     FIXED      "+;
  1937.     "FUNC_SET   INDEX_SET  INTENSITY  KEY        ORDER      PATH       "+;
  1938.     "RELATE     UNIQUE     "    
  1939.  
  1940. return
  1941.  
  1942. *
  1943. ** eoproc fill_lists
  1944.  
  1945.  
  1946. ***
  1947. * Procedure FILTER
  1948. * kjs, 05/07/86
  1949. * Evaluates the stack for the SET FILTER command.  Called by procedure SET.
  1950. * Sets execution class macro, class execution flag(s) and command line
  1951. * substitution macros.
  1952. *
  1953.  
  1954. procedure filter
  1955.  
  1956. private stack_ptr, stack_item, to, filter, error
  1957.  
  1958. stack_ptr = 3
  1959. stack_item = ""
  1960. error = 0
  1961. store .F. to to, filter
  1962.  
  1963. if DBF_OPEN .or. if(error_on, DBF_OPEN, .T.)
  1964.     if get_stack("stack_item")
  1965.         to = (upper(stack_item) = "TO")
  1966.         filter = get_stack("exp1")
  1967.     else
  1968.         error = 2
  1969.     endif
  1970. else
  1971.     error = 5
  1972. endif
  1973.  
  1974. do case
  1975.     case error = 5
  1976.         ERRS5 = .T.
  1977.  
  1978.     case error = 2 .or. !to .and. !filter
  1979.         ERRS2 = .T.
  1980.  
  1981.     case to .and. filter
  1982.         executor = "SETS"
  1983.         SETS17 = .T.
  1984.  
  1985.     case to .and. !filter
  1986.         executor = "SETS"
  1987.         SETS18 = .T.
  1988. endcase
  1989.  
  1990. return
  1991.  
  1992. *
  1993. ** eoproc filter
  1994.  
  1995.  
  1996. ***
  1997. * Procedure FIXED
  1998. * kjs, 04/28/86
  1999. * Evaluates the stack for the SET FIXED command, called by procedure SET.
  2000. * Sets execution class macro, class execution flag(s) and command line
  2001. * substitution macros.
  2002. *
  2003.  
  2004. procedure fixed
  2005.  
  2006. stack_ptr = 3
  2007.  
  2008. if stack_ptr <= max_ptr
  2009.     exp1 = upper(stack[stack_ptr])
  2010.     if "&exp1"$"ON^OFF"
  2011.         executor = "SETS"
  2012.         SETS8 = .T.
  2013.     else
  2014.         ERRS2 = .T.
  2015.     endif
  2016. else
  2017.     ERRS2 = .T.
  2018. endif
  2019.  
  2020. return
  2021.  
  2022. *
  2023. ** eoproc fixed
  2024.  
  2025.  
  2026. ***
  2027. * Procedure FUNC
  2028. * kjs, 05/07/86
  2029. * Evaluates the stack for the SET FUNCTION command, called by procedure SET.
  2030. * Sets execution class macro, class execution flag(s) and command line
  2031. * substitution macros.
  2032. *
  2033.  
  2034. procedure func_set
  2035.  
  2036. private stack_ptr, stack_item, string, to, key, error, active, null
  2037.  
  2038. stack_ptr = 3
  2039. store .F. to key, to, string, null
  2040. error = 0
  2041. active = 1  && 0 = error, 1 = function number, 2 = TO token, 3 = string.
  2042.  
  2043. do while stack_ptr <= max_ptr
  2044.  
  2045.     stack_item = ""
  2046.     null = get_stack("stack_item")
  2047.  
  2048.     if upper(stack_item) = "TO"
  2049.         if active = 2    && expected TO token.
  2050.             to = .T.
  2051.             active = 3
  2052.         else
  2053.             error = 2
  2054.         endif
  2055.     else
  2056.         do case
  2057.             case active = 0                && unexpected something.
  2058.                 error = 2
  2059.  
  2060.             case active = 1                && expecting key number.
  2061.                 exp1 = stack_item
  2062.                 if val(exp1) > 1 .and. val(exp1) < 41
  2063.                     key = .T.
  2064.                 else
  2065.                     error = 14
  2066.                 endif
  2067.                 active = 2
  2068.  
  2069.             case active = 3                && expecting string.
  2070.                 exp2 = stack_item
  2071.                 string = .T.
  2072.                 active = 0
  2073.         endcase
  2074.     endif
  2075. enddo
  2076.  
  2077. do case
  2078.     case error = 2
  2079.         ERRS2 = .T.
  2080.  
  2081.     case error = 14
  2082.         ERRS14 = .T.
  2083.  
  2084.     case key .and. to .and. string
  2085.         executor = "SETS"
  2086.         SETS9 = .T.
  2087.  
  2088.     otherwise
  2089.         ERRS2 = .T.
  2090. endcase
  2091.  
  2092. return
  2093.  
  2094. *
  2095. ** eoproc func
  2096.  
  2097.  
  2098. ***
  2099. * Procedure GOTO
  2100. * kjs, 04/22/86
  2101. * Evaluates the stack for the GO or GOTO verb.
  2102. * Sets execution class macro, class execution flag(s) and command line
  2103. * substitution macros.
  2104. *
  2105.  
  2106. procedure goto
  2107.  
  2108. private stack_ptr, stack_item, bottom, top, error
  2109.  
  2110. stack_ptr = 2
  2111. stack_item = ""
  2112. store .F. to bottom, top
  2113. error = 0
  2114.  
  2115. if DBF_OPEN .or. if(error_on, DBF_OPEN, .T.)  && check for open data file.
  2116.     if get_stack("stack_item")                && stack item exists.
  2117.  
  2118.         top = (upper(stack_item) == "TOP")
  2119.         bottom = cmd_abbr(upper(stack_item), "BOTTOM")
  2120.  
  2121.         if !top .and. !bottom
  2122.  
  2123.             exp1 = stack_item
  2124.  
  2125.             if error_on                       && check legal goto value.
  2126.                 do case
  2127.                     case &exp1 > lastrec()    && too big.
  2128.                         error = 6
  2129.                         
  2130.                     case &exp1 < 0            && too small.
  2131.                         error = 12
  2132.                 endcase
  2133.             endif
  2134.         endif
  2135.     else
  2136.         error = 2
  2137.     endif
  2138. else
  2139.     error = 5
  2140. endif
  2141.  
  2142. do case
  2143.     case error = 2
  2144.         ERRS2 = .T.
  2145.  
  2146.     case error = 5
  2147.         ERRS5 = .T.
  2148.  
  2149.     case error = 6
  2150.         ERRS6 = .T.
  2151.  
  2152.     case error = 12
  2153.         ERRS12 = .T.
  2154.  
  2155.     case !top .and. !bottom
  2156.         executor = "DBF_NTX"
  2157.         DBF_NTX7 = .T.
  2158.  
  2159.     case top
  2160.         executor = "DBF_NTX"
  2161.         DBF_NTX8 = .T.
  2162.  
  2163.     case bottom
  2164.         executor = "DBF_NTX"
  2165.         DBF_NTX9 = .T.
  2166. endcase
  2167.  
  2168. return
  2169.  
  2170. *
  2171. ** eoproc goto
  2172.  
  2173.  
  2174. ***
  2175. * Procedure help
  2176. * kjs, 11/10/85
  2177. * Help for DOT.
  2178. *
  2179.  
  2180. procedure help
  2181.  
  2182. parameters call_proc, line_num, call_var
  2183.  
  2184. set key 5 to
  2185.  
  2186. if call_proc = "HELP"
  2187.     return
  2188. endif
  2189.  
  2190. row = row()
  2191. col = col()
  2192.  
  2193. save screen
  2194. clear
  2195.  
  2196. text
  2197.                           Commands supported by DOT
  2198.  
  2199.   <F1> - Help
  2200.   <>  - History mode.  Up to [max_hist] commands are saved.  After
  2201.          [max_hist] commands have been saved, each new command is added
  2202.          to the end of the history array and the top command is thrown
  2203.          away.
  2204.  
  2205.          <>     - move backward through commands.
  2206.          <>     - move forward through commands.
  2207.          <ESC>   - returns without selecting a command.
  2208.          <─┘>   - executes the selection.
  2209.  
  2210.   @ <row>,<col> 
  2211.      [say <exp> [picture <clause>]]
  2212.      [get <exp> [picture <clause>] 
  2213.      [range <exp, exp>] [valid <exp>]]
  2214.      [clear]
  2215.   @ t, l, b, r BOX <string>
  2216.   ! or RUN <DOS command or file>
  2217.   ?  [<exp>]
  2218.   ?? [<exp>]
  2219.   <var> = <exp>              
  2220.  
  2221. endtext
  2222.  
  2223. wait "Strike any key for more help, <ESC> to return"
  2224.  
  2225. if lastkey() = 27
  2226.     set key 5 to history
  2227.     clear
  2228.     restore screen
  2229.     return
  2230. endif
  2231.  
  2232. clear
  2233.  
  2234. text
  2235.                           More commands supported by DOT
  2236.  
  2237.   accept [<string>] to <memvar>
  2238.   append blank
  2239.   call <procedure> [with <param1>[,<parameter list>]]
  2240.   clear
  2241.   cls
  2242.   copy [structure] to <filename>
  2243.   dir [<drive>][<path>][<skeleton>]
  2244.   display [<exp>[,<expression list>]]
  2245.   delete [<scope>][FOR/WHILE <expression>].
  2246.   do <procedure> [with <param1>[,<parameter list>]]
  2247.   erase <file name>.<extension>
  2248.   exit
  2249.   go[to] <exp>/TOP/BOTTOM
  2250.   index on <key expression> to <ntxfile>
  2251.   input [<string>] to <var> 
  2252.   list [<exp>[,<expression list>]]
  2253.   pack
  2254.   quit
  2255.   read
  2256.   recall [<scope>] [FOR/WHILE <expression>].
  2257.   release <var>
  2258.  
  2259. endtext
  2260.  
  2261. wait "Strike any key for more help, <ESC> to return"
  2262.  
  2263. if lastkey() = 27
  2264.     set key 5 to history
  2265.     clear
  2266.     restore screen
  2267.     return
  2268. endif
  2269.  
  2270. clear
  2271.  
  2272. text
  2273.                           More commands supported by DOT
  2274.  
  2275.   replace <fieldname> with <expression>
  2276.   return            ** Returns to previous level **
  2277.   seek <exp>
  2278.   select <exp>/<alias>  ** variables not usable **
  2279.   set color to <expression>
  2280.   set decimals to <expression>
  2281.   set default to <drive:>
  2282.   set delimiters <ON/OFF>
  2283.   set delimiters to [<string>]/[DEFAULT]
  2284.   set filter to [<filter expression>]
  2285.   set escape <ON/OFF>
  2286.   set exact <ON/OFF>
  2287.   set exclusive <ON/OFF>
  2288.   set fixed <ON/OFF>
  2289.   set function <function key number> to <string>
  2290.   set intensity <ON/OFF>
  2291.   set index to [<ntxfile>[,<ntxlist>]]]
  2292.   set key <ascii key number> to <string>
  2293.   set path to [<path expression>]
  2294.   set order to [<expN>]
  2295.   set relation to [<key expression> into <alias>]
  2296.  
  2297. endtext
  2298.  
  2299. wait "Strike any key for more help, <ESC> to return"
  2300.  
  2301. if lastkey() = 27
  2302.     set key 5 to history
  2303.     clear
  2304.     restore screen
  2305.     return
  2306. endif
  2307.  
  2308. clear
  2309.  
  2310. text
  2311.                           More commands supported by DOT
  2312.  
  2313.   skip [<exp>]
  2314.   type <file name>.<extension>
  2315.   unlock [ALL]
  2316.   use [<filename> [index <ntxfile>[,<ntxlist>]]][alias <alias name>]
  2317.       exclusive
  2318.   wait [[<string>][to <var>]]
  2319.   zap
  2320.  
  2321.                                    Comments
  2322.  
  2323.   1. Command MUST be entered as shown in HELP or error may be generated.
  2324.   2. Lists can contain up to 10 items. CALL or DO use up to 7 items.
  2325.   3. The SET FUNCTION command does not allow [F1] to be reset.
  2326.      Range [2] to [40]
  2327.   4. The SET KEY command does not allow [28] and [24] keys to be reset.
  2328.      Range [-39] to [387].
  2329.   5. The SET KEY command overrides the SET FUNCTION key.
  2330.   6. SET KEY should ONLY be used with VALID procedure names.
  2331.   7. If a GET is pending, DO NOT use History [] to execute a READ or
  2332.      the GET will be cleared.
  2333.  
  2334. endtext
  2335.  
  2336. wait "Strike any key for more help, <ESC> to return"
  2337.  
  2338. if lastkey() = 27
  2339.     set key 5 to history
  2340.     clear
  2341.     restore screen
  2342.     return
  2343. endif
  2344.  
  2345. clear
  2346.  
  2347. text
  2348.                                    Comments
  2349.  
  2350.   8. FOR and WHILE are NON-exclusive phrases.  WHILE takes precedence.
  2351.   9. When more than one scoping key word is present, control will be
  2352.      given to the last key word in the command line.
  2353.  10. Input and Display sections can use different I/O environments when
  2354.      SETs are issued.  See main DOT procedure.
  2355.  11. SAFETY is NOT on, BE FOREWARNED.
  2356.  12. Macros are expanded before being placed on stack so DOT may behave
  2357.      differently than a Clipper program with macros.
  2358.  
  2359.  
  2360.                               Flow Chart
  2361.  
  2362.   The next page contains a simple flow chart of the internal structure of
  2363.   the DOT test utility.  Upper case words represent the names of
  2364.   PROCEDURES called by the main DOT procedure.  Several macros are used
  2365.   to call procedures that will vary based on the contents of the stack.
  2366.   These cases are noted as such and do not use the upper case convention.
  2367.  
  2368. endtext
  2369.  
  2370. wait "Strike any key for more help, <ESC> to return"
  2371.  
  2372. if lastkey() = 27
  2373.     set key 5 to history
  2374.     clear
  2375.     restore screen
  2376.     return
  2377. endif
  2378.  
  2379. clear
  2380. text
  2381. DOT────>────── (initialize flags, execution and control variables)
  2382.                    
  2383.                FILL_LIST    ** initialize search string variables.
  2384.                    
  2385.   ┌─────>───── (initialize stack array) 
  2386.   │                
  2387.   │             INPUT_LN    ** put cursor at bottom of screen.
  2388.   │                
  2389.   │             (input)     ** accept the command line from the console.
  2390.   │                
  2391.   │             INPUT_LN    ** return to display portion of screen.
  2392.   │                
  2393.                 PARSE      ** place components of command line on stack.
  2394.   │                
  2395.   │             SET_LEX     ** set analysis procedure macro "lex_proc".
  2396.   │                
  2397.   │            (analyze)    ** do analyze procedure macro "lex_proc".
  2398.   │                
  2399.   │             HIST_PUT    ** put command into history array.
  2400.   │                
  2401.   │            (execute)    ** do execution procedure macro "executor".
  2402.   │                
  2403.   └─────<───── (reset command line substitution macro variables)
  2404. endtext
  2405.  
  2406. wait "Strike any key for more help, <ESC> to return"
  2407.  
  2408. if lastkey() = 27
  2409.     set key 5 to history
  2410.     clear
  2411.     restore screen
  2412.     return
  2413. endif
  2414.  
  2415. clear
  2416. text
  2417.                              DOT assistance programs
  2418.  
  2419.   what_key   : Returns the numeric value of a key. <ALT-Q> aborts.
  2420.   hist_purge : Empties the history array.
  2421.   set_sets   : Reset all the SET commands listed to their DEFAULT
  2422.                setting.
  2423.  
  2424.                            Internal Control Variables
  2425.  
  2426.   bottom_on = .T.  -  Places the input window at the bottom of the screen.
  2427.   error_on  = .T.  -  Checks for DBF, NTX ON/OFF or existence.
  2428.   max_hist  = 20   -  Maximum number of history item stored before
  2429.                       overwrites of earlier 'saved' commands starts.
  2430.  
  2431. endtext
  2432.  
  2433. wait "Strike any key to continue."
  2434.  
  2435. clear
  2436.  
  2437. set key 5 to history
  2438. restore screen
  2439. return
  2440.  
  2441. *
  2442. ** eoproc help
  2443.  
  2444.  
  2445. ***
  2446. * Procedure hist_purge
  2447. * kjs, 04/16/86
  2448. * Purges the history array.
  2449. *
  2450.  
  2451. procedure hist_purge
  2452.  
  2453. do while hist_max > 0
  2454.     history[hist_max] = ""
  2455.     hist_max = hist_max - 1
  2456. enddo
  2457. hist_ptr = 0
  2458.  
  2459. return
  2460.  
  2461. *
  2462. ** eoproc hist_purge
  2463.  
  2464.  
  2465. ***
  2466. * Procedure hist_put
  2467. * kjs, 04/15/86
  2468. * Stores command into the history array
  2469. *
  2470.  
  2471. procedure hist_put
  2472.  
  2473. if hist_max < max_hist
  2474.     hist_max = hist_max + 1
  2475. else 
  2476.     for i = 2 to max_hist 
  2477.         history[i-1] = history[i]
  2478.     next
  2479. endif
  2480.  
  2481. history[hist_max] = command
  2482.  
  2483. return
  2484.  
  2485. *
  2486. ** eoproc hist_put
  2487.  
  2488.  
  2489. ***
  2490. * Procedure history
  2491. * kjs, 04/15/86
  2492. * Allows user to select from the list of history'd commands.
  2493. *
  2494.  
  2495. procedure history
  2496.  
  2497. parameters call_proc, call_line, call_var
  2498.  
  2499. private key, hist_ptr, curr_row, curr_col, cmd_line
  2500.  
  2501. if hist_max > 0 .and. call_proc <> "HISTORY"
  2502.  
  2503.     set intensity on
  2504.     clear gets
  2505.  
  2506.     key = 0
  2507.     hist_ptr = hist_max
  2508.     curr_row = row()
  2509.     curr_col = col()
  2510.  
  2511.     set key 5 to stuff_up
  2512.     set key 24 to stuff_dn
  2513.  
  2514.     do while .T.
  2515.         cmd_line = history[hist_ptr] + space(77 - len(history[hist_ptr]))
  2516.         @ curr_row, curr_col get cmd_line
  2517.         read
  2518.  
  2519.         key = lastkey()
  2520.  
  2521.         do case
  2522.             case key = 5
  2523.                 ** up-arrow, backwards **
  2524.                 hist_ptr = hist_ptr - 1
  2525.                 if hist_ptr <= 0
  2526.                     hist_ptr = hist_max
  2527.                 endif
  2528.     
  2529.             case key = 24
  2530.                 ** down-arrow, forward **
  2531.                 hist_ptr = hist_ptr + 1
  2532.                 if hist_ptr > hist_max
  2533.                     hist_ptr = 1
  2534.                 endif
  2535.  
  2536.             case key = 13 .or. key = 27
  2537.                 if key = 13
  2538.                     keyboard trim(cmd_line) + chr(13)
  2539.                 endif
  2540.                 @ curr_row, curr_col
  2541.                 set intensity &inten_stat
  2542.                 set key 5 to history
  2543.                 set key 24 to
  2544.                 return
  2545.         endcase
  2546.     enddo
  2547. endif
  2548.  
  2549. *
  2550. ** eoproc history
  2551.  
  2552.  
  2553. ***
  2554. * Procedure INDEX
  2555. * kjs, 03/21/86
  2556. * Evaluates the stack for the INDEX verb.
  2557. * Sets execution class macro, class execution flag(s) and command line
  2558. * substitution macros.
  2559. *
  2560.  
  2561. procedure index
  2562.  
  2563. private stack_ptr, stack_item, item_ok, on, to, key, file, active, error
  2564.  
  2565. stack_ptr = 2
  2566. store .F. to on, to, key, file
  2567. active = 1    && 0 = error, 1 = key, 2 = file.
  2568. error = 0
  2569.  
  2570. if error_on .and. !DBF_OPEN  && if file checking is on and file is not open.
  2571.     error = 5
  2572. endif
  2573.  
  2574. do while stack_ptr <= max_ptr .and. error = 0
  2575.     stack_item = ""
  2576.     item_ok = get_stack("stack_item")
  2577.  
  2578.     do case
  2579.         case upper(stack_item) = "ON" .and. !on
  2580.             on = .T.
  2581.             active = 1
  2582.  
  2583.         case upper(stack_item) = "TO" .and. !to
  2584.             to = .T.
  2585.             active = 2
  2586.  
  2587.         otherwise
  2588.             do case
  2589.                 case active = 1
  2590.                     key = .T.
  2591.                     exp1 = stack_item
  2592.                     if !file
  2593.                         active = 2
  2594.                     else
  2595.                         active = 0
  2596.                     endif
  2597.  
  2598.                 case active = 2
  2599.                     file = .T.
  2600.                     ntx_file = stack_item
  2601.                     if !key
  2602.                         active = 1
  2603.                     else
  2604.                         active = 0
  2605.                     endif
  2606.  
  2607.                 otherwise
  2608.                     error = 2
  2609.             endcase
  2610.     endcase
  2611. enddo
  2612.  
  2613. do case
  2614.     case error = 2
  2615.         ERRS2 = .T.
  2616.  
  2617.     case error = 5
  2618.         ERRS5 = .T.
  2619.     
  2620.     case on .and. to .and. key .and. file
  2621.         executor = "DBF_NTX"
  2622.         DBF_NTX6 = .T.
  2623.  
  2624.     otherwise
  2625.         ERRS2 = .T.
  2626. endcase
  2627.  
  2628. return
  2629.  
  2630. *
  2631. ** eoproc index
  2632.  
  2633.  
  2634. ***
  2635. * Procedure INDEX_set
  2636. * kjs, 05/01/86
  2637. * Evaluates stack for SET INDEX TO command.  Called by procedure SET.
  2638. * Sets execution class macro, class execution flag(s) and command line
  2639. * substitution macros.
  2640. *
  2641.  
  2642. procedure index_set
  2643.  
  2644. private stack_ptr, stack_item, item_ok, to, file, error
  2645.  
  2646. stack_ptr = 3
  2647. stack_item = ""
  2648. store .F. to item_ok, to, file
  2649. error = 0
  2650.  
  2651. if error_on .and. !DBF_OPEN        && check for open data file.
  2652.     error = 5
  2653. else
  2654.     stack_item = stack[stack_ptr]
  2655.  
  2656.     if (upper(stack_item) == "TO")
  2657.         to = .T.
  2658.         file = get_list("NF")
  2659.  
  2660.         if !file                   && error occurred in building list.
  2661.             if empty(list0)        && list is empty, turn indexes off.
  2662.                 file = .T.
  2663.             else                   && index file not found.
  2664.                 error = 11
  2665.             endif
  2666.         endif
  2667.     else
  2668.         error = 2
  2669.     endif
  2670. endif
  2671.  
  2672. do case
  2673.     case error = 2
  2674.         ERRS2 = .T.
  2675.  
  2676.     case error = 5
  2677.         ERRS5 = .T.
  2678.  
  2679.     case error = 11
  2680.         ERRS11 = .T.
  2681.  
  2682.     case to .and. file
  2683.         executor = "SETS"
  2684.         SETS10 = .T.
  2685. endcase
  2686.  
  2687. return
  2688.  
  2689. *
  2690. ** eoproc index_set
  2691.  
  2692.  
  2693. ***
  2694. * Procedure INPUT
  2695. * kjs, 04/11/86
  2696. * Evaluates stack for INPUT verb.
  2697. * Sets execution class macro, class execution flag(s) and command line
  2698. * substitution macros.
  2699. *
  2700.  
  2701. procedure input
  2702.  
  2703. private stack_ptr, string, to, dest, stack_item
  2704.  
  2705. stack_ptr = 1
  2706. store .F. to string, to, dest
  2707.  
  2708. do while stack_ptr <= max_ptr
  2709.     stack_item = upper(stack[stack_ptr])
  2710.     do case
  2711.         case stack_item = "INPU"
  2712.             string = get_expr1("exp1")
  2713.             if upper(exp1) = "TO"
  2714.                 string = .F.
  2715.                 exp1 = ""
  2716.                 stack_ptr = stack_ptr - 1
  2717.             endif
  2718.  
  2719.         case stack_item = "TO"
  2720.             to = .T.
  2721.             dest = get_expr1("var1")
  2722.         otherwise
  2723.             stack_ptr = stack_ptr + 1
  2724.     endcase
  2725. enddo
  2726.  
  2727. if !err()
  2728.     do case
  2729.         case to .and. dest .and. !string
  2730.             executor = "VARS"
  2731.             VARS3 = .T.
  2732.             VARS9 = .T.
  2733.  
  2734.         case to .and. dest .and. string
  2735.             executor = "VARS"
  2736.             VARS4 = .T.
  2737.             VARS9 = .T.
  2738.  
  2739.         otherwise
  2740.             ERRS2 = .T.
  2741.     endcase
  2742. endif
  2743.  
  2744. return
  2745.  
  2746. *
  2747. ** eoproc input
  2748.  
  2749.  
  2750. ***
  2751. * Procedure input_ln
  2752. * kjs/br, 04/16/86
  2753. * Places the input line on the bottom of screen and manages the
  2754. * placement of the end of output diamond.
  2755. *
  2756.  
  2757. procedure input_ln
  2758.  
  2759. parameters when
  2760.  
  2761. if when = "B"
  2762.     save_row = row()
  2763.     save_col = col()
  2764.  
  2765.     ?? chr(4)                && display cursor position marker.
  2766.  
  2767.     @ MaxRow(), 0 say ""
  2768.  
  2769.     do while (save_row > MaxRow()-2)
  2770.         ?
  2771.         save_row = save_row - 1
  2772.     enddo
  2773.  
  2774.     @ MaxRow()-1, 0 clear
  2775.     @ MaxRow()-1, 0 say cmd_line
  2776.     @ MaxRow()-1, 0 say ""
  2777. else
  2778.     @ MaxRow()-1, 0 clear
  2779.     @ save_row, save_col say " "
  2780.     @ save_row, save_col say ""
  2781. endif
  2782.  
  2783. return
  2784.  
  2785. *
  2786. ** eoproc input_ln
  2787.  
  2788.  
  2789. ***
  2790. * Procedure INTENSITY
  2791. * kjs, 04/28/86
  2792. * Evaluates the stack for the SET INTENSITY command.  Called by the 
  2793. * SET procedure.
  2794. * Sets execution class macro, class execution flag(s) and command line
  2795. * substitution macros.
  2796. *
  2797.  
  2798. procedure intensity
  2799.  
  2800. stack_ptr = 2
  2801.  
  2802. if get_expr1("exp1")
  2803.     if exp1$"ON^OFF"
  2804.         executor = "SETS"
  2805.         SETS11 = .T.
  2806.     else
  2807.         ERRS2 = .T.
  2808.     endif
  2809. else
  2810.     ERRS2 = .T.
  2811. endif
  2812.  
  2813. return
  2814.  
  2815. *
  2816. ** eoproc intensity
  2817.  
  2818.  
  2819. ***
  2820. * Procedure KEY
  2821. * kjs, 05/07/86
  2822. * Evaluates the stack for the SET KEY command.  Called from procedure
  2823. * SET.
  2824. * Sets execution class macro, class execution flag(s) and command line
  2825. * substitution macros.
  2826. * Does not allow [F1] or [] to be reset.
  2827. *
  2828.  
  2829. procedure key
  2830.  
  2831. private stack_ptr, string, to, key, null, stack_item
  2832.  
  2833. stack_ptr = 2
  2834. store .F. to key, to, null
  2835.  
  2836. do while stack_ptr <= max_ptr
  2837.     stack_item = upper(stack[stack_ptr])
  2838.     do case
  2839.         case stack_item = "KEY"
  2840.             key = get_expr1("exp1")
  2841.             if key .and. val(exp1) > -40 .and. val(exp1) < 388;
  2842.                 .and. val(exp1) <> 28 .and. val(exp1) <> 24
  2843.                 key = .T.
  2844.             endif
  2845.  
  2846.         case stack_item = "TO"
  2847.             to = .T.
  2848.             null = get_expr1("exp2")
  2849.  
  2850.         otherwise
  2851.             stack_ptr = stack_ptr + 1
  2852.     endcase
  2853. enddo
  2854.  
  2855. if !err()
  2856.     if key .and. to
  2857.         executor = "SETS"
  2858.         SETS14 = .T.
  2859.     else
  2860.         ERRS2 = .T.
  2861.     endif
  2862. endif
  2863.  
  2864. return
  2865.  
  2866. *
  2867. ** eoproc key
  2868.  
  2869.  
  2870. ***
  2871. * Procedure LIST
  2872. * kjs, 04/22/86
  2873. * Evaluates stack for the LIST verb.
  2874. * Sets execution class macro, class execution flag(s) and command line
  2875. * substitution macros.
  2876. *
  2877.  
  2878. procedure list
  2879.  
  2880. private stack_ptr
  2881.  
  2882. stack_ptr = 1
  2883.  
  2884. if DBF_OPEN .or. !error_on
  2885.     if max_ptr = 1
  2886.         executor = "DBF_NTX"
  2887.         DBF_NTX12 = .T.
  2888.     else
  2889.         if get_list("E")
  2890.             executor = "DBF_NTX"
  2891.             DBF_NTX13 = .T.
  2892.         else
  2893.             ERRS2 = .T.
  2894.         endif
  2895.     endif
  2896. else
  2897.     ERRS5 = .T.
  2898. endif
  2899.  
  2900. return
  2901.  
  2902. *
  2903. ** eoproc list
  2904.  
  2905.  
  2906. ***
  2907. * Procedure list_do
  2908. * kjs, 04/10/86
  2909. * Emulates the LIST/DISPLAY command, called LIST executor.
  2910. *
  2911. * Usage : list_do <logical 1>, <logical 2>
  2912. * Where :    <logical 1> = record number display flag.
  2913. *         :    <logical 2> = LIST/DISPLAY flag. .T. = DISPLAY mode
  2914. *
  2915.  
  2916. procedure list_do
  2917.  
  2918. parameters recno_on, is_display
  2919.  
  2920. private disp_count, count, header, l_part1, l_part2, l_part3, use_part2,;
  2921.     use_part3
  2922.  
  2923. if recno_on
  2924.     header = "[Record#  "
  2925.     l_part1 = "str(recno(),7)+space(2)"
  2926. else
  2927.     header = "["
  2928.     l_part1 = "space(0)"
  2929. endif
  2930.  
  2931. l_part2 = "space(0)"
  2932. l_part3 = "space(0)"
  2933.  
  2934. use_part2 = .F.
  2935. use_part3 = .F.
  2936.  
  2937. count = 1
  2938.  
  2939. do while "" <> fieldname(count)
  2940.     header = header + spacer_h(fieldname(count))
  2941.     if len(l_part1) < 150
  2942.         l_part1 = l_part1 + "+" + fld_form(fieldname(count)) + "+space(" +;
  2943.             spacer_l(fieldname(count)) + ")"
  2944.     else
  2945.         if len(l_part2) < 150
  2946.             l_part2 = l_part2 + "+" + fld_form(fieldname(count)) + "+space(" +;
  2947.                 spacer_l(fieldname(count)) + ")"
  2948.         else
  2949.             l_part3 = l_part3 + "+" + fld_form(fieldname(count)) + "+space(" +;
  2950.                 spacer_l(fieldname(count)) + ")"
  2951.         endif
  2952.     endif
  2953.     count = count + 1
  2954. enddo
  2955.  
  2956. header = header + "]"
  2957.  
  2958. use_part2 = !empty(&l_part2)
  2959. use_part3 = !empty(&l_part3)
  2960.  
  2961. ? &header
  2962.  
  2963. if !eof()
  2964.     for i = 1 to if(!is_display, lastrec(), 1)
  2965.         ? &l_part1
  2966.  
  2967.         if use_part2
  2968.             ?? &l_part2
  2969.             if use_part3
  2970.                 ?? &l_part3
  2971.             endif
  2972.         endif
  2973.  
  2974.         if !is_display
  2975.             skip
  2976.         endif
  2977.  
  2978.         if inkey() = 27
  2979.             return        
  2980.         endif
  2981.     next
  2982. endif
  2983.  
  2984. return
  2985.  
  2986. *
  2987. ** eoproc list_do
  2988.  
  2989.  
  2990. ***
  2991. * Procedure ORDER
  2992. * kjs, 09/30/86
  2993. * Evaluates stack for the SET ORDER command. Called from SET procedure.
  2994. * Sets execution class macro, class execution flag(s) and command line
  2995. * substitution macros.
  2996. *
  2997.  
  2998. procedure order
  2999.  
  3000. private stack_ptr, stack_item, to, exp, null
  3001.  
  3002. stack_ptr = 3
  3003.  
  3004. store .F. to to, exp, null
  3005.  
  3006. do while stack_ptr <= max_ptr
  3007.     stack_item = ""
  3008.     null = get_stack("stack_item")
  3009.  
  3010.     if upper(stack_item) = "TO" .and. !to
  3011.         to = .T.
  3012.     else
  3013.         exp1 = stack_item
  3014.         exp = .T.
  3015.     endif
  3016. enddo
  3017.  
  3018. do case
  3019.     case !(DBF_OPEN) .and. error_on
  3020.         ERRS5 = .T.
  3021.  
  3022.     case !(NTX_OPEN) .and. error_on
  3023.         ERRS9 = .T.
  3024.  
  3025.     case to .and. exp
  3026.         executor = "SETS"
  3027.         SETS21 = .T.
  3028.  
  3029.     case to .and. !exp
  3030.         executor = "SETS"
  3031.         SETS22 = .T.
  3032.     
  3033.     otherwise
  3034.         ERRS2 = .T.
  3035.  
  3036. endcase
  3037.  
  3038. return
  3039.  
  3040. *
  3041. ** eoproc order
  3042.  
  3043.  
  3044. ***
  3045. * Procedure PACK
  3046. * kjs, 05/02/86
  3047. * Evaluates the stack for PACK verb.
  3048. * Sets execution class macro, class execution flag(s) and command line
  3049. * substitution macros.
  3050. *
  3051.  
  3052. procedure pack
  3053.  
  3054. if max_ptr = 1
  3055.     if DBF_OPEN .or. !error_on
  3056.         executor = "DBF_NTX"
  3057.         DBF_NTX21 = .T.
  3058.     else
  3059.         ERRS5 = .T.
  3060.     endif
  3061. else
  3062.     ERRS2 = .T.
  3063. endif
  3064.  
  3065. return
  3066.  
  3067. *
  3068. ** eoproc pack
  3069.  
  3070.  
  3071. ***
  3072. * Procedure parse
  3073. * kjs, 05/20/86
  3074. * breaks command line into tokens and populates stack.
  3075. *
  3076.  
  3077. procedure parse
  3078.  
  3079. parameters stack_max
  3080.  
  3081. private line_len, scan_ptr, parse_more, tokens, collect_it, scan_char,;
  3082.     next_char, inc_before, inc_after, start_char, stop_char, item_count,;
  3083.     more_char
  3084.  
  3085. command = trim(ltrim(command))
  3086.  
  3087. if !empty(command)
  3088.     line_len = len(command)
  3089.     scan_ptr = 1
  3090.     parse_more = .T.
  3091.     tokens = " +-*/%<>#,!@.$^?=[()]'" + ["]
  3092.     stack_ptr = 1
  3093.     stack[1] = ""
  3094.     collect_it = .F.
  3095.     inc_before = .F.
  3096.     inc_after = .F.
  3097. else
  3098.     parse_more = .F.
  3099. endif
  3100.  
  3101. do while parse_more
  3102.  
  3103.     scan_char = substr(command, scan_ptr, 1)
  3104.  
  3105.     do case
  3106.         case !scan_char$tokens .and. "" <> scan_char
  3107.             ** if the scan character is NOT one of the parsed characters **
  3108.             collect_it = .T.
  3109.  
  3110.         case "" = scan_char
  3111.             ** if scan character is NULL, stop the parser. **
  3112.             parse_more = .F.
  3113.  
  3114.         case scan_char = " "
  3115.             ** if the scan character is a blank, check if stack element is **
  3116.             ** empty. If not, set the pre-collection stack increment flag **
  3117.             ** to true.                                                     ** 
  3118.  
  3119.             if "" <> stack[stack_ptr]
  3120.                 inc_before = .T.
  3121.             endif
  3122.  
  3123.         case scan_char$"+-*/%<>#,!@.$^?="
  3124.             ** If the scan character is one of the parsed elements set the **
  3125.             ** collector flag true, initialize the next character variable, **
  3126.             ** and check if either the pre or post collection flags need to **
  3127.             ** be set.                                                        **
  3128.  
  3129.             collect_it = .T.
  3130.  
  3131.             if stack[stack_ptr] <> scan_char
  3132.                 if "" <> stack[stack_ptr]
  3133.                     inc_before = .T.
  3134.                 endif
  3135.             endif
  3136.  
  3137.             next_char = if((scan_ptr+1) <= line_len,;
  3138.                 substr(command, scan_ptr+1, 1), "")
  3139.             if !next_char$tokens .and. "" <> next_char
  3140.                 inc_after = .T.
  3141.             endif
  3142.  
  3143.         case scan_char$"[('" .or. scan_char = ["]
  3144.             ** if the scan character is a string delimiter or a **
  3145.             ** grouping operator, check for any empty stack element **
  3146.             ** then check for balanced delimiters or groupers. **
  3147.  
  3148.             if "" <> stack[stack_ptr]
  3149.                 stack_ptr = stack_ptr + 1
  3150.                 stack[stack_ptr] = ""
  3151.             endif
  3152.  
  3153.             start_char = scan_char
  3154.  
  3155.             if scan_char = "("
  3156.                 stop_char = ")"
  3157.             else
  3158.                 if scan_char = "["
  3159.                     stop_char = "]"
  3160.                 else
  3161.                     stop_char = scan_char
  3162.                 endif
  3163.             endif
  3164.  
  3165.             item_count = 0
  3166.             more_char = .T.
  3167.  
  3168.             do while more_char            
  3169.                 stack[stack_ptr] = stack[stack_ptr] + scan_char
  3170.  
  3171.                 if start_char <> stop_char
  3172.                     if scan_char = start_char
  3173.                         item_count = item_count + 1
  3174.                     else
  3175.                         if scan_char = stop_char
  3176.                             item_count = item_count - 1
  3177.                         endif
  3178.                     endif
  3179.                 else
  3180.                     if item_count > 0
  3181.                         if scan_char = stop_char
  3182.                             item_count = item_count - 1
  3183.                         endif
  3184.                     else
  3185.                         item_count = 1
  3186.                     endif
  3187.                 endif
  3188.  
  3189.                 if item_count = 0 .or. "" = scan_char
  3190.                     more_char = .F.
  3191.                 else
  3192.                     scan_ptr = scan_ptr + 1
  3193.                     scan_char = substr(command, scan_ptr, 1)
  3194.                 endif
  3195.             enddo
  3196.             
  3197.             if scan_ptr > line_len
  3198.                 ERRS8 = .T.
  3199.             else
  3200.                 next_char = substr(command, scan_ptr + 1,1)
  3201.                 if !next_char$tokens .and. "" <> next_char
  3202.                     inc_after = .T.
  3203.                 endif
  3204.             endif
  3205.  
  3206.     endcase
  3207.      
  3208.     if inc_before
  3209.         stack_ptr = stack_ptr + 1
  3210.         stack[stack_ptr] = ""
  3211.         inc_before = .F.
  3212.     endif
  3213.  
  3214.     if collect_it                    && add current char to stack.
  3215.         stack[stack_ptr] = stack[stack_ptr] + scan_char
  3216.         collect_it = .F.
  3217.     endif
  3218.  
  3219.     if inc_after                     && increment after adding char.
  3220.         stack_ptr = stack_ptr + 1
  3221.         stack[stack_ptr] = ""
  3222.         inc_after = .F.
  3223.     endif
  3224.  
  3225.     scan_ptr = scan_ptr + 1
  3226.  
  3227. enddo
  3228.  
  3229. return
  3230.  
  3231. *
  3232. ** eoproc parse
  3233.  
  3234.  
  3235. ***
  3236. * Procedure PATH
  3237. * kjs, 05/07/86
  3238. * Evaluates stack for SET PATH command.  Called from SET procedure.
  3239. * Sets execution class macro, class execution flag(s) and command line
  3240. * substitution macros.
  3241. *
  3242.  
  3243. procedure path
  3244.  
  3245. private stack_ptr, to, null
  3246.  
  3247. stack_ptr = 3
  3248. store .F. to to, null
  3249.  
  3250. if upper(stack[stack_ptr]) = "TO"
  3251.     to = .T.
  3252.     null = get_expr1("exp1")
  3253. endif
  3254.  
  3255. if to
  3256.     executor = "SETS"
  3257.     SETS12 = .T.
  3258. else
  3259.     ERRS2 = .T.
  3260. endif
  3261.  
  3262. return
  3263.  
  3264. *
  3265. ** eoproc path
  3266.  
  3267.  
  3268. ***
  3269. * Procedure ques1
  3270. * kjs, 04/22/86
  3271. * Evaluates stack for single question mark (?).
  3272. * Sets execution class macro, class execution flag(s) and command line
  3273. * substitution macros.
  3274. *
  3275.  
  3276. procedure ques1
  3277.  
  3278. private stack_ptr
  3279.  
  3280. stack_ptr = 2
  3281.  
  3282. if get_stack("exp1")
  3283.     executor = "SCRN"
  3284.     SCRN25 = .T.
  3285. else
  3286.     executor = "SCRN"
  3287.     SCRN24 = .T.
  3288. endif
  3289.  
  3290. return 
  3291.  
  3292. *
  3293. ** eoproc ques1
  3294.     
  3295.  
  3296. ***
  3297. * Procedure ques2
  3298. * kjs, 04/22/86
  3299. * Evaluates stack for double question marks (??).
  3300. * Sets execution class macro, class execution flag(s) and command line
  3301. * substitution macros.
  3302. *
  3303.  
  3304. procedure ques2
  3305.  
  3306. private stack_ptr
  3307.  
  3308. stack_ptr = 1
  3309.  
  3310. if get_expr1("exp1")
  3311.     executor = "SCRN"
  3312.     SCRN27 = .T.
  3313. else
  3314.     executor = "SCRN"
  3315.     SCRN26 = .T.
  3316. endif
  3317.  
  3318. return 
  3319.  
  3320. *
  3321. ** eoproc ques2
  3322.  
  3323.  
  3324. ***
  3325. * Procedure QUIT
  3326. * kjs, 04/22/86
  3327. * called from analyze, analyzes the stack for the QUIT, EXIT or
  3328. * RETURN verb.
  3329. *
  3330.  
  3331. procedure quit
  3332.  
  3333. if max_ptr = 1
  3334.     executor = "CALLS"
  3335.     if stack[1]$"QUIT EXIT"
  3336.         CALLS6 = .T.
  3337.     else
  3338.         CALLS7 = .T.
  3339.     endif
  3340. else
  3341.     ERRS2 = .T.
  3342. endif
  3343.  
  3344. return
  3345.  
  3346. *
  3347. ** eoproc quit
  3348.  
  3349.  
  3350. ***
  3351. * Procedure rREAD
  3352. * kjs, 04/22/86
  3353. * Evaluates stack for READ verb. 
  3354. * Sets execution class macro, class execution flag(s) and command line
  3355. * substitution macros.
  3356. *
  3357.  
  3358. procedure rread
  3359.  
  3360. executor = "SCRN"
  3361. SCRN28 = .T.
  3362.  
  3363. return
  3364.  
  3365. *
  3366. ** eoproc rread
  3367.  
  3368.  
  3369. ***
  3370. * Procedure RECALL
  3371. * kjs, 05/02/86
  3372. * Evaluates the stack for RECALL verb.  Calls the condition and
  3373. * scope analyzer CND_SCP to set condition and scope flags and
  3374. * expressions.
  3375. * Sets execution class macro, class execution flag(s) and command line
  3376. * substitution macros.
  3377. *
  3378.  
  3379. procedure recall
  3380.  
  3381. private stack_ptr, for, while, next, record, all, stack_item
  3382.  
  3383. stack_ptr = 2
  3384. store .F. to for, while, next, record, all, condition
  3385. scope = 0
  3386.  
  3387. if cnd_scp()    && no errors during generic condition and scope analysis.
  3388.     do case 
  3389.         case for .or. while .or. all .or. next .or. record
  3390.             ** w/ w/o scope and/or condition. **
  3391.             if DBF_OPEN .or. !error_on
  3392.                 executor = "DBF_NTX"
  3393.                 DBF_NTX20 = .T.
  3394.             else    
  3395.                 ERRS5 = .T.
  3396.             endif
  3397.  
  3398.         case !for .and. !while .and. !all .and. !next .and. !record;
  3399.             .and. max_ptr = 1
  3400.             ** w/o scope or conditional **
  3401.             if DBF_OPEN .or. !error_on
  3402.                 executor = "DBF_NTX"
  3403.                 DBF_NTX20 = .T.
  3404.                 scope = 1       && use RECORD (scope = 1) for single recall.
  3405.                 exp3 = str(recno())
  3406.  
  3407.                 if &exp3 > lastrec() .and. error_on
  3408.                     ERRS6 = .T.
  3409.                     DBF_NTX20 = .F.
  3410.                 else
  3411.                     exp3 = "recno() = &exp3"
  3412.                 endif
  3413.             else
  3414.                 ERRS5 = .T.
  3415.             endif
  3416.  
  3417.         otherwise        
  3418.             ERRS2 = .T.
  3419.     endcase        
  3420. endif
  3421.  
  3422. return
  3423.  
  3424. *
  3425. ** eoproc recall
  3426.  
  3427.  
  3428. ***
  3429. * Procedure recall_it
  3430. * kjs, 05/14/86
  3431. * Called by do_cnd_scp called from DBF_NTX execution procedure.
  3432. *
  3433.  
  3434. procedure recall_it
  3435.  
  3436. recall
  3437.  
  3438. return
  3439.  
  3440. *
  3441. ** eoproc recall_it
  3442.  
  3443.  
  3444. ***
  3445. * Procedure RELATE
  3446. * kjs, 05\23\86
  3447. * Evaluates stack for SET RELATION command.  Called from SET procedure.
  3448. * Sets execution class macro, class execution flag(s) and command line
  3449. * substitution macros.
  3450. *
  3451.  
  3452. procedure relate
  3453.  
  3454. private stack_ptr, to, exp, alias, stack_item
  3455.  
  3456. stack_ptr = 3
  3457. store .F. to to, exp, alias
  3458.  
  3459. do while stack_ptr <= max_ptr
  3460.     stack_item = upper(stack[stack_ptr])
  3461.     do case
  3462.         case stack_item = "TO"
  3463.             to = .T.
  3464.             exp = get_expr1("exp1")
  3465.  
  3466.         case stack_item = "INTO"
  3467.             alias = get_expr1("exp2")
  3468.  
  3469.         otherwise
  3470.             stack_ptr = stack_ptr + 1
  3471.     endcase
  3472. enddo
  3473.  
  3474. if !err()
  3475.     do case
  3476.         case to .and. exp .and. alias .and. if(error_on, DBF_OPEN, .T.)
  3477.             executor = "SETS"
  3478.             SETS16 = .T.
  3479.  
  3480.         case to .and. !exp .and. !alias .and. if(error_on, DBF_OPEN, .T.)
  3481.             executor = "SETS"
  3482.             SETS15 = .T.
  3483.  
  3484.         case if(error_on, !DBF_OPEN, .F.)
  3485.             ERRS5 = .T.
  3486.  
  3487.         otherwise
  3488.             ERRS2 = .T.
  3489.     endcase
  3490. endif
  3491.  
  3492. return
  3493.  
  3494. *
  3495. ** eoproc relate
  3496.  
  3497.  
  3498. ***
  3499. * Procedure RELEASE
  3500. * kjs, 04/22/86
  3501. * Evaluates stack for the RELEASE verb.
  3502. * Sets execution class macro, class execution flag(s) and command line
  3503. * substitution macros.
  3504. *
  3505.  
  3506. procedure release
  3507.  
  3508. private stack_ptr
  3509.  
  3510. stack_ptr = 2
  3511.  
  3512. if max_ptr = 2
  3513.     var1 = stack[stack_ptr]
  3514.     if type("&var1") <> "U"
  3515.         executor = "VARS"
  3516.         VARS11 = .T.
  3517.     else
  3518.         ERRS3 = .T.
  3519.     endif
  3520. else
  3521.     ERRS2 = .T.
  3522. endif
  3523.  
  3524. return
  3525.  
  3526. *
  3527. ** eoproc release
  3528.  
  3529.  
  3530. ***
  3531. * Procedure REPLACE
  3532. * kjs, 09/16/86
  3533. * Evaluates stack for the REPLACE command.
  3534. * Sets execution class macro, class execution flag(s) and command line
  3535. * substitution macros.
  3536. *
  3537.  
  3538. procedure replace
  3539.  
  3540. private stack_ptr, stack_item, dest, with, source, all, null
  3541.  
  3542. stack_ptr = 2
  3543. store .F. to dest, with, source, all
  3544.  
  3545. do while stack_ptr <= max_ptr
  3546.  
  3547.     stack_item = ""
  3548.     null = get_stack("stack_item")
  3549.  
  3550.     do case
  3551.         case upper(stack_item) = "ALL"
  3552.             all = .T.
  3553.  
  3554.         case upper(stack_item) = "WITH"
  3555.             with = .T.
  3556.  
  3557.         otherwise
  3558.             if "" == var1
  3559.                 var1 = stack_item
  3560.                 dest = .T.
  3561.             else
  3562.                 exp1 = stack_item
  3563.                 source = .T.
  3564.             endif
  3565.     endcase
  3566. enddo
  3567.  
  3568. do case
  3569.     case !DBF_OPEN .and. error_on
  3570.         ERRS5 = .T.
  3571.  
  3572.     case dest .and. with .and. source .and. !all
  3573.         executor = "DBF_NTX"
  3574.         DBF_NTX26 = .T.
  3575.  
  3576.     case dest .and. with .and. source .and. all
  3577.         executor = "DBF_NTX"
  3578.         DBF_NTX27 = .T.
  3579.  
  3580.     otherwise
  3581.         ERRS2 = .T.
  3582. endcase
  3583.  
  3584. return
  3585.  
  3586. *
  3587. ** eoproc replace
  3588.  
  3589.  
  3590. ***
  3591. * Procedure RUN
  3592. * kjs, 04/22/86
  3593. * Evaluates stack for the RUN or ! verb.
  3594. * Sets execution class macro, class execution flag(s) and command line
  3595. * substitution macros.
  3596. *
  3597.  
  3598. procedure run
  3599.  
  3600. exp1 = substr(command, len(stack[1]) + 1)
  3601.  
  3602. if !empty(exp1)
  3603.     executor = "CALLS"
  3604.     CALLS3 = .T.
  3605. else
  3606.     ERRS2 = .T.
  3607. endif
  3608.  
  3609. return
  3610.  
  3611. *
  3612. ** eoproc run
  3613.  
  3614.  
  3615. ***
  3616. * Procedure SEEK
  3617. * kjs, 04/22/86
  3618. * Evaluates stack for the SEEK verb.
  3619. * Sets execution class macro, class execution flag(s) and command line
  3620. * substitution macros.
  3621. *
  3622.  
  3623. procedure seek
  3624.  
  3625. private stack_ptr
  3626.  
  3627. stack_ptr = 1
  3628.  
  3629. if DBF_OPEN .or. !error_on
  3630.     if NTX_OPEN .or. !error_on
  3631.         if get_expr1("exp1")
  3632.             executor = "DBF_NTX"
  3633.             DBF_NTX17 = .T.
  3634.         else
  3635.             ERRS2 = .T.
  3636.         endif
  3637.     else
  3638.         ERRS9 = .T.
  3639.     endif
  3640. else
  3641.     ERRS5 = .T.
  3642. endif
  3643.  
  3644. return
  3645.  
  3646. *
  3647. ** eoproc seek
  3648.  
  3649.  
  3650. ***
  3651. * Procedure SELECT
  3652. * kjs, 04/22/86
  3653. * Evaluates stack for the SELECT verb.
  3654. * Sets execution class macro, class execution flag(s) and command line
  3655. * substitution macros.
  3656. *
  3657.  
  3658. procedure select
  3659.  
  3660. private stack_ptr, select, expr_type
  3661.  
  3662. stack_ptr = 1
  3663. select = .F.
  3664. expr_type = ""
  3665.  
  3666. if get_expr1("exp1")
  3667.     if select(exp1) > 0
  3668.         select = .T.
  3669.     else
  3670.         expr_type = type(exp1)
  3671.  
  3672.         if expr_type = "N"
  3673.             if val(exp1) <= 250 .and. val(exp1) >= 0
  3674.                 select = .T.
  3675.             endif
  3676.         endif
  3677.     endif
  3678. endif
  3679.  
  3680. if select
  3681.     executor = "DBF_NTX"
  3682.     DBF_NTX16 = .T.
  3683. else
  3684.     ERRS2 = .T.
  3685. endif
  3686.  
  3687. return
  3688.  
  3689. *
  3690. ** eoproc select
  3691.  
  3692.  
  3693. ***
  3694. * Procedure SSET
  3695. * kjs, 10/07/86
  3696. * Evaluates the next key word in SET command.  Checks abbreviation of
  3697. * key word.  Key ok, [do_sets] procedure macro is set.  Key fail or not
  3698. * found, set unknown command error flag ERRS1.
  3699. *
  3700.  
  3701. procedure sset
  3702.  
  3703. private stack_ptr, seek_strng, position, do_sets, error
  3704.  
  3705. stack_ptr = 2
  3706. do_sets = ""
  3707. error = 0
  3708.  
  3709. seek_strng = upper(stack[stack_ptr])
  3710. position = at("." + seek_strng, set_list)
  3711.  
  3712. if position > 0
  3713.     if cmd_abbr(seek_strng, trim(substr(set_list, (position + 1), 10)))
  3714.         do_sets = substr(set_proc, position, 10)
  3715.     else
  3716.         error = 1
  3717.     endif
  3718. else
  3719.     error = 1
  3720. endif
  3721.  
  3722. if error = 1
  3723.     ERRS1 = .T.
  3724. else
  3725.     do &do_sets
  3726. endif
  3727.  
  3728. return
  3729.  
  3730. *
  3731. ** eoproc set
  3732.  
  3733.  
  3734. ***
  3735. * Procedure sets
  3736. * kjs, 06/12/86
  3737. * executes the SETS class of commands
  3738. *
  3739.  
  3740. procedure sets
  3741.  
  3742. do case
  3743.     case SETS1
  3744.         set color to &exp1
  3745.         color_stat = exp1
  3746.         SETS1 = .F.
  3747.  
  3748.     case SETS2
  3749.         set confirm &exp1
  3750.         confr_stat = exp1
  3751.         SETS2 = .F.
  3752.  
  3753.     case SETS3
  3754.         set decimal to &exp1
  3755.         SETS3 = .F.
  3756.  
  3757.     case SETS4
  3758.         set default to &exp1
  3759.         SETS4 = .F.
  3760.  
  3761.     case SETS5
  3762.         set delimiters &exp1
  3763.         delim_stat = exp1
  3764.         SETS5 = .F.
  3765.  
  3766.     case SETS6
  3767.         set delimiters to &exp1
  3768.         SETS6 = .F.
  3769.  
  3770.     case SETS7
  3771.         set escape &exp1
  3772.         SETS7 = .F.
  3773.  
  3774.     case SETS8
  3775.         set fixed &exp1
  3776.         SETS8 = .F.
  3777.  
  3778.     case SETS9
  3779.         set function &exp1 to &exp2
  3780.         SETS9 = .F.
  3781.  
  3782.     case SETS10
  3783.         set index to &list0, &list1, &list2, &list3, &list4, &list5,;
  3784.             &list6, &list7, &list8, &list9
  3785.         SETS10 = .F.
  3786.  
  3787.         if empty(list0)
  3788.             NTX_OPEN = .F.
  3789.         else
  3790.             NTX_OPEN = .T.
  3791.         endif
  3792.  
  3793.     case SETS11
  3794.         set intensity &exp1
  3795.         inten_stat = exp1
  3796.         SETS11 = .F.
  3797.  
  3798.     case SETS12
  3799.         set path to &exp1
  3800.         SETS12 = .F.
  3801.  
  3802.     case SETS13
  3803.         set unique &exp1
  3804.         SETS13 = .F.
  3805.  
  3806.     case SETS14
  3807. * CAUTION:  5.0 A31
  3808. *        set key &exp1 to &exp2
  3809.         SETS14 = .F.
  3810.  
  3811.     case SETS15
  3812.         set relation to
  3813.         SETS15 = .F.
  3814.  
  3815.     case SETS16
  3816.         relation = exp1
  3817.         alias = exp2
  3818.         set relation to &relation into &alias
  3819.         SETS16 = .F.
  3820.  
  3821.     case SETS17
  3822.         filter = exp1
  3823.         set filter to &filter
  3824.         SETS17 = .F.
  3825.  
  3826.     case SETS18
  3827.         filter = ""
  3828.         set filter to
  3829.         SETS18 = .F.
  3830.  
  3831.     case SETS19
  3832.         set exclusive &exp1
  3833.         SETS19 = .F.
  3834.  
  3835.     case SETS20
  3836.         set exact &exp1
  3837.         exact_stat = exp1
  3838.         SETS20 = .F.
  3839.  
  3840.     case SETS21
  3841.         set order to &exp1
  3842.         SETS21 = .F.
  3843.  
  3844.     case SETS22
  3845.         set order to
  3846.         SETS22 = .F.
  3847. endcase
  3848.  
  3849. return
  3850.  
  3851. *
  3852. ** eoproc sets
  3853.  
  3854.  
  3855. ***
  3856. * Procedure set_lex
  3857. * kjs, 04/22/86
  3858. * Locates the verb in verb_list string and initializes "lex_proc" macro with 
  3859. * the corresponding procedure name found in the lex_list string.
  3860. * Calls CMD_ABBR().
  3861. *
  3862.  
  3863. procedure set_lex
  3864.  
  3865. private seek_strng, verb_string, position
  3866.  
  3867. if assign_chk()
  3868.     lex_proc = "ASSIGN"
  3869. else
  3870.     seek_strng = upper(stack[1])
  3871.     position = at("." + seek_strng, verb_list)
  3872.     if position > 0
  3873.         verb_string = trim(substr(verb_list, position + 1, 9))
  3874.         if cmd_abbr(seek_strng, verb_string)
  3875.             lex_proc = substr(lex_list, position, 10)
  3876.         else
  3877.             lex_proc = "UNKNOWN"
  3878.         endif
  3879.     else
  3880.         lex_proc = "UNKNOWN"
  3881.     endif
  3882. endif
  3883.  
  3884. return
  3885.  
  3886. *
  3887. ** eoproc set_lex
  3888.  
  3889.  
  3890. ***
  3891. * Procedure set_sets
  3892. * kjs, 05/08/86
  3893. * Called from interactive prompt.  Resets the SET commands to their
  3894. * DEFAULT settings.
  3895. *
  3896.  
  3897. procedure set_sets
  3898.  
  3899. set alternate OFF
  3900. set alternate to
  3901. set bell OFF
  3902. set color to
  3903. set confirm OFF
  3904. set console ON
  3905. set decimal to 2
  3906. set default to
  3907. set deleted OFF
  3908. set delimiters OFF
  3909. set delimiters to
  3910. set device to SCREEN
  3911. set escape ON
  3912. set exact OFF
  3913. set exclusive ON
  3914. set filter to
  3915. set fixed OFF
  3916. set format to
  3917.  
  3918. for i = 2 to 40
  3919.     set function i to ""
  3920. next
  3921.  
  3922. set index to
  3923. set intensity ON
  3924.  
  3925. for i = -39 to 387
  3926. *    set key i to ""
  3927. * CAUTION:  5.0 A31  (this was illegal anyway)
  3928.     set key i to
  3929. next
  3930.  
  3931. set order to 1
  3932. set print OFF
  3933. set path to
  3934. set relation to
  3935. set scoreboard ON
  3936. set unique OFF
  3937.  
  3938. inten_stat = "ON"
  3939. color_stat = "7/0"
  3940. delim_stat = "OFF"
  3941. confr_stat = "OFF"
  3942. exact_stat = "OFF"
  3943.  
  3944. return
  3945.  
  3946. *
  3947. ** eoproc set_sets
  3948.  
  3949.  
  3950. ***
  3951. * Procedure SKIP
  3952. * kjs, 04/22/86
  3953. * Evaluates stack for SKIP verb.
  3954. * Sets execution class macro, class execution flag(s) and command line
  3955. * substitution macros.
  3956. *
  3957.  
  3958. procedure skip
  3959.  
  3960. private stack_ptr
  3961.  
  3962. stack_ptr = 1
  3963.         
  3964. if DBF_OPEN .or. !error_on
  3965.     if get_expr1("exp1")
  3966.         if is_n_expr(&exp1)
  3967.             if if(error_on, &exp1 <= lastrec(), .T.)
  3968.                 executor = "DBF_NTX"
  3969.                 DBF_NTX11 = .T.
  3970.             else
  3971.                 ERRS6 = .T.
  3972.             endif
  3973.         else
  3974.             ERRS3 = .T.
  3975.         endif
  3976.     else
  3977.         executor = "DBF_NTX"
  3978.         DBF_NTX10 = .T.
  3979.     endif
  3980. else
  3981.     ERRS5 = .T.
  3982. endif
  3983.  
  3984. return
  3985.  
  3986. *
  3987. ** eoproc skip
  3988.  
  3989.  
  3990. ***
  3991. * Procedure stuff_up
  3992. * kjs, 04/26/86
  3993. * Clears the get list when an up-arrow is depressed.
  3994. * Called from HISTORY procedure. 
  3995. *
  3996.  
  3997. procedure stuff_up
  3998.  
  3999. parameters call_proc, call_line, call_var
  4000.  
  4001. if call_proc <> "STUFF_UP"
  4002.     clear gets
  4003. endif
  4004.  
  4005. return
  4006.  
  4007. *
  4008. ** eoproc stuff_up
  4009.  
  4010.  
  4011. ***
  4012. * Procedure stuff_dn
  4013. * kjs, 04/26/86
  4014. * Clears the get list when a down-arrow is depressed.
  4015. * Called from HISTORY procedure.
  4016.  
  4017. procedure stuff_dn
  4018.  
  4019. parameters call_proc, call_line, call_var
  4020.  
  4021. if call_proc <> "STUFF_DN"
  4022.     clear gets
  4023. endif
  4024.  
  4025. return
  4026.  
  4027. *
  4028. ** eoproc stuff_dn
  4029.  
  4030.  
  4031. ***
  4032. * Procedure scrn
  4033. * kjs, 06/12/86
  4034. * executes the SCRN class commands
  4035. *
  4036.  
  4037. procedure scrn
  4038.  
  4039. do case
  4040.     case SCRN1
  4041.         @ &coord1, &coord2    
  4042.         SCRN1 = .F.
  4043.  
  4044.     case SCRN2
  4045.         @ &coord1, &coord2 clear
  4046.         SCRN2 = .F.
  4047.  
  4048.     case SCRN3
  4049.         @ &coord1, &coord2 say &say_exp
  4050.         SCRN3 = .F.
  4051.  
  4052.     case SCRN4
  4053.         @ &coord1, &coord2 say &say_exp picture &say_pict
  4054.         SCRN4 = .F.
  4055.  
  4056.     case SCRN5
  4057.         @ &coord1, &coord2 get &get_exp
  4058.         SCRN5 = .F.
  4059.  
  4060.     case SCRN6
  4061.         @ &coord1, &coord2 get &get_exp picture &get_pict
  4062.         SCRN6 = .F.
  4063.  
  4064.     case SCRN7
  4065.         range1 = rng_exp1
  4066.         range2 = rng_exp2
  4067.         @ &coord1, &coord2 get &get_exp range &range1, &range2
  4068.         SCRN7 = .F.
  4069.  
  4070.     case SCRN8
  4071.         @ &coord1, &coord2 get &get_exp valid &valid_exp
  4072.         SCRN8 = .F.
  4073.  
  4074.     case SCRN10
  4075.         @ &coord1, &coord2 get &get_exp picture &get_pict valid &valid_exp
  4076.         SCRN10 = .F.
  4077.  
  4078.     case SCRN11
  4079.         range1 = rng_exp1
  4080.         range2 = rng_exp2
  4081.         @ &coord1, &coord2 get &get_exp picture &get_pict range &range1,;
  4082.             &range2
  4083.         SCRN11 = .F.
  4084.  
  4085.     case SCRN13
  4086.         @ &coord1, &coord2 say &say_exp get &get_exp
  4087.         SCRN13 = .F.
  4088.  
  4089.     case SCRN14
  4090.         @ &coord1, &coord2 say &say_exp picture &say_pict get &get_exp
  4091.         SCRN14 = .F.
  4092.  
  4093.     case SCRN15
  4094.         @ &coord1, &coord2 say &say_exp picture &say_pict get &get_exp;
  4095.             picture &get_pict
  4096.         SCRN15 = .F.
  4097.  
  4098.     case SCRN16
  4099.         range1 = rng_exp1
  4100.         range2 = rng_exp2
  4101.         @ &coord1, &coord2 say &say_exp picture &say_pict get &get_exp;
  4102.             picture &get_pict range &range1, &range2
  4103.         SCRN16 = .F.
  4104.  
  4105.     case SCRN17
  4106.         @ &coord1, &coord2 say &say_exp picture &say_pict get &get_exp;
  4107.             picture &get_pict valid &valid_exp
  4108.         SCRN17 = .F.
  4109.  
  4110.     case SCRN19
  4111.         @ &coord1, &coord2 say &say_exp get &get_exp picture &get_pict
  4112.         SCRN19 = .F.
  4113.  
  4114.     case SCRN20
  4115.         range1 = rng_exp1
  4116.         range2 = rng_exp2
  4117.         @ &coord1, &coord2 say &say_exp get &get_exp picture &get_pict;
  4118.             range &range1, &range2
  4119.         SCRN20 = .F.
  4120.  
  4121.     case SCRN21
  4122.         @ &coord1, &coord2 say &say_exp get &get_exp picture &get_pict;
  4123.             valid &valid_exp
  4124.         SCRN21 = .F.
  4125.  
  4126.     case SCRN22
  4127.         @ &coord1, &coord2, &coord3, &coord4 box &box_exp
  4128.         SCRN22 = .F.
  4129.  
  4130.     case SCRN23
  4131.         clear
  4132.         SCRN23 = .F.
  4133.  
  4134.     case SCRN24
  4135.         ?
  4136.         SCRN24 = .F.
  4137.  
  4138.     case SCRN25
  4139.         ? &exp1
  4140.         SCRN25 = .F.
  4141.  
  4142.     case SCRN26
  4143.         ??
  4144.         SCRN26 = .F.
  4145.  
  4146.     case SCRN27
  4147.         ?? &exp1
  4148.         SCRN27 = .F.
  4149.  
  4150.     case SCRN28
  4151.         cur_row = row()
  4152.         read
  4153.         @ cur_row+1, 1
  4154.         SCRN28 = .F.
  4155. endcase
  4156.  
  4157. return
  4158.  
  4159. *
  4160. ** eoproc scrn
  4161.  
  4162.  
  4163. ***
  4164. * Procedure TYPE
  4165. * kjs, 04/22/86
  4166. * Evaluates stack for TYPE verb.
  4167. * Sets execution class macro, class execution flag(s) and command line
  4168. * substitution macros.
  4169. *
  4170.  
  4171. procedure type
  4172.  
  4173. private stack_ptr
  4174.  
  4175. stack_ptr = 1
  4176.  
  4177. if get_expr1("exp1")
  4178.     executor = "DBF_NTX"
  4179.     DBF_NTX23 = .T.
  4180. else
  4181.     ERRS2 = .T.
  4182. endif
  4183.  
  4184. return
  4185.  
  4186. *
  4187. ** eoproc type
  4188.  
  4189.  
  4190. ***
  4191. * Procedure unknown
  4192. * kjs, 09/23/86
  4193. * If command cannot be found this routine is called to set unknown
  4194. * error flag.
  4195. *
  4196.  
  4197. procedure unknown
  4198.  
  4199. ERRS1 = .T.
  4200.  
  4201. return
  4202.  
  4203. *
  4204. ** eoproc unknown
  4205.  
  4206.  
  4207. ***
  4208. * Procedure UNLOCK
  4209. * kjs, 07/28/86
  4210. * Evaluates stack for UNLOCK verb.
  4211. * Sets execution class macro, class execution flag(s) and command line
  4212. * substitution macros.
  4213. *
  4214.  
  4215. procedure unlock
  4216.  
  4217. private stack_ptr
  4218.  
  4219. stack_ptr = 1
  4220.  
  4221. if max_ptr = 1
  4222.     executor = "DBF_NTX"
  4223.     DBF_NTX24 = .T.
  4224. else
  4225.     if max_ptr = 2 .and. upper(stack[2]) = "ALL"
  4226.         executor = "DBF_NTX"
  4227.         DBF_NTX25 = .T.
  4228.     else
  4229.         ERRS1 = .T.
  4230.     endif
  4231. endif
  4232.  
  4233. return
  4234.  
  4235. *
  4236. ** eoproc unlock
  4237.                       
  4238.  
  4239. ***
  4240. * Procedure USE
  4241. * kjs, 04/22/86
  4242. * Evaluates stack for USE verb.
  4243. * Sets execution class macro, class execution flag(s) and command line
  4244. * substitution macros.
  4245. *
  4246.  
  4247. procedure use 
  4248.  
  4249. private stack_ptr, file, dbf, index, ntx, alias, name, excl,;
  4250.   stack_item
  4251.  
  4252. stack_ptr = 1
  4253. store .F. to file, dbf, index, ntx, alias, name, excl
  4254.  
  4255. do while stack_ptr <= max_ptr .and. !err()
  4256.  
  4257.     stack_item = upper(stack[stack_ptr])
  4258.  
  4259.     do case 
  4260.         case "USE" = stack_item
  4261.             if get_expr1("dbf_file")
  4262.                 file = .T.
  4263.                 dbf = if(error_on, file("&dbf_file..DBF"), .T.)
  4264.             endif
  4265.  
  4266.         case cmd_abbr(stack_item, "INDEX")
  4267.             index = .T.
  4268.             ntx = get_list("NF")
  4269.  
  4270.         case cmd_abbr(stack_item, "ALIAS")
  4271.             alias = .T.
  4272.             name = get_expr1("exp2")
  4273.  
  4274.         case cmd_abbr(stack_item, "EXCLUSIVE")
  4275.             excl = .T.
  4276.             stack_ptr = stack_ptr + 1
  4277.  
  4278.         otherwise
  4279.             ERRS2 = .T.
  4280.     endcase
  4281. enddo
  4282.  
  4283. if !err()
  4284.     do case
  4285.         case !file .and. !dbf .and. !index .and. !ntx .and. !alias;
  4286.             .and. !excl
  4287.             *** Close the current selected data file. ***
  4288.             executor = "DBF_NTX"
  4289.             DBF_NTX1 = .T.
  4290.  
  4291.         case file .and. dbf .and. !index .and. !ntx .and. !alias;
  4292.             .and. !excl
  4293.             executor = "DBF_NTX"
  4294.             DBF_NTX2 = .T.
  4295.  
  4296.         case file .and. dbf .and. index .and. ntx .and. !alias;
  4297.             .and. !excl
  4298.             executor = "DBF_NTX"
  4299.             DBF_NTX3 = .T.
  4300.  
  4301.         case file .and. dbf .and. alias .and. name .and. !index;
  4302.             .and. !ntx .and. !excl
  4303.             executor = "DBF_NTX"
  4304.             DBF_NTX4 = .T.
  4305.  
  4306.         case file .and. dbf .and. index .and. ntx .and. alias;
  4307.             .and. name .and. !excl
  4308.             executor = "DBF_NTX"
  4309.             DBF_NTX5 = .T.
  4310.  
  4311.         case file .and. dbf .and. !index .and. !ntx .and. !alias;
  4312.             .and. excl
  4313.             executor = "DBF_NTX"
  4314.             DBF_NTX32 = .T.
  4315.  
  4316.         case file .and. dbf .and. index .and. ntx .and. !alias;
  4317.             .and. excl
  4318.             executor = "DBF_NTX"
  4319.             DBF_NTX33 = .T.
  4320.  
  4321.         case file .and. dbf .and. alias .and. name .and. !index;
  4322.             .and. !ntx .and. excl
  4323.             executor = "DBF_NTX"
  4324.             DBF_NTX34 = .T.
  4325.  
  4326.         case file .and. dbf .and. index .and. ntx .and. alias;
  4327.             .and. name .and. excl
  4328.             executor = "DBF_NTX"
  4329.             DBF_NTX35 = .T.
  4330.  
  4331.         case file .and. !dbf .and. !index .and. !ntx .and. error_on
  4332.             ERRS7 = .T.
  4333.  
  4334.         case file .and. dbf .and. index .and. !ntx .and. error_on
  4335.             ERRS11 = .T.
  4336.  
  4337.         otherwise
  4338.             ERRS2 = .T.
  4339.     endcase
  4340. endif
  4341. return
  4342.  
  4343. *
  4344. ** eoproc use 
  4345.  
  4346.  
  4347. ***
  4348. * Procedure vars
  4349. * kjs, 06/12/86
  4350. * executes the VARS class of commands
  4351. *
  4352.  
  4353. procedure vars
  4354.  
  4355. do case
  4356.     case VARS1
  4357.         accept to &var1
  4358.         VARS1 = .F.
  4359.  
  4360.     case VARS2
  4361.         accept &exp1 to &var1
  4362.         VARS2 = .F.
  4363.  
  4364.     case VARS3
  4365.         input to &var1
  4366.         VARS3 = .F.
  4367.  
  4368.     case VARS4
  4369.         input &exp1 to &var1
  4370.         VARS4 = .F.
  4371.  
  4372.     case VARS5
  4373.         wait
  4374.         VARS5 = .F.
  4375.  
  4376.     case VARS6
  4377.         wait to &var1
  4378.         VARS6 = .F.
  4379.  
  4380.     case VARS7
  4381.         wait &exp1 to &var1
  4382.         VARS7 = .F.
  4383.  
  4384.     case VARS8
  4385.         wait &exp1
  4386.         VARS8 = .F.
  4387. endcase
  4388.  
  4389. return
  4390.  
  4391. *
  4392. ** eoproc var
  4393.  
  4394.  
  4395. ***
  4396. * Procedure what_key
  4397. * kjs, 04/16/86
  4398. * displays ascii decimal value of a key
  4399. *
  4400.  
  4401. procedure what_key
  4402.  
  4403. private key, trash
  4404.  
  4405. save screen
  4406.  
  4407. clear
  4408. key = 0
  4409.  
  4410. do while key <> 272
  4411.     trash = inkey()
  4412.     key = lastkey()
  4413.     @ 10,10 say str(key,4) + " <ALT-Q> returns (272)."
  4414.     for col = 40 to 60 step 1
  4415.         @ 10, col say ""
  4416.     next
  4417.     for col = 40 to 60 step 2
  4418.         @ 10, col say ""
  4419.     next
  4420. enddo
  4421.  
  4422. restore screen
  4423.  
  4424. return
  4425.  
  4426. *
  4427. ** eoproc what_key
  4428.  
  4429.  
  4430. ***
  4431. * Procedure wWAIT
  4432. * kjs, 04/11/86
  4433. * Evaluates stack for WAIT verb.
  4434. * Sets execution class macro, class execution flag(s) and command line
  4435. * substitution macros.
  4436. *
  4437.  
  4438. procedure wwait
  4439.  
  4440. private stack_ptr, string, to, dest, stack_item
  4441.  
  4442. stack_ptr = 1
  4443. store .F. to string, to, dest
  4444.  
  4445. do while stack_ptr <= max_ptr
  4446.     stack_item = upper(stack[stack_ptr])
  4447.     do case
  4448.         case stack_item = "WAIT"
  4449.             string = get_expr1("exp1")
  4450.             if upper(exp1) = "TO"
  4451.                 string = .F.
  4452.                 exp1 = ""
  4453.                 stack_ptr = stack_ptr - 1
  4454.             endif
  4455.  
  4456.         case stack_item = "TO"
  4457.             to = .T.
  4458.             dest = get_expr1("var1")
  4459.  
  4460.         otherwise
  4461.             stack_ptr = stack_ptr + 1
  4462.     endcase
  4463. enddo
  4464.  
  4465. if !err()
  4466.     do case
  4467.         case !to .and. !dest .and. !string
  4468.             executor = "VARS"
  4469.             VARS5 = .T.
  4470.  
  4471.         case to .and. dest .and. !string
  4472.             executor = "VARS"
  4473.             VARS6 = .T.
  4474.             VARS9 = .T.
  4475.  
  4476.         case to .and. dest .and. string
  4477.             executor = "VARS"
  4478.             VARS7 = .T.
  4479.             VARS9 = .T.
  4480.  
  4481.         case !to .and. !dest .and. string
  4482.             executor = "VARS"
  4483.             VARS8 = .T.
  4484.  
  4485.         otherwise
  4486.             ERRS2 = .T.
  4487.     endcase
  4488. endif
  4489.  
  4490. return
  4491.  
  4492. *
  4493. ** eoproc wwait
  4494.  
  4495.  
  4496. ***
  4497. * Procedure ZAP
  4498. * kjs, 10/24/86
  4499. * Evaluates stack for ZAP verb. 
  4500. * Sets execution class macro, class execution flag.
  4501. *
  4502.  
  4503. procedure zap
  4504.  
  4505. if error_on .and. !DBF_OPEN
  4506.   ERRS5 = .T.
  4507. else
  4508.   if stack_ptr = 1
  4509.      executor = "DBF_NTX"
  4510.      DBF_NTX36 = .T.
  4511.   else
  4512.      ERRS2 = .T.
  4513.   endif
  4514. endif
  4515.  
  4516. return
  4517.  
  4518. *
  4519. ** eoproc ZAP
  4520.  
  4521.  
  4522. *********************************
  4523. * End of procedures for dot.prg *
  4524. *********************************
  4525.  
  4526. *********************
  4527. * Functions for Dot *
  4528. *********************
  4529.  
  4530.  
  4531. ***
  4532. * Function assign_chk
  4533. * kjs, 09/23/86
  4534. * Check command for assignment operator.
  4535. *
  4536. *    Usage :    assign_chk()
  4537. *
  4538. *     Returns:
  4539. *        .T. - assignment operator found after first identifier.
  4540. *        .F. - no operator found.
  4541. *
  4542. * Called from SET_LEX procedure.
  4543. *
  4544.  
  4545. function assign_chk
  4546.  
  4547. private stack_item, status
  4548.  
  4549. stack_item = ""
  4550. status = .F.
  4551.  
  4552. if max_ptr >= 2
  4553.   stack_item = stack[2]
  4554. endif
  4555.  
  4556. if substr(stack[1],1,1)$"_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
  4557.   if stack_item == "="
  4558.         status = .T.
  4559.   else
  4560.      if substr(stack_item,1,1) == "["   && if no close brace error in parser.
  4561.         if max_ptr >= 3
  4562.            if stack[3] == "="
  4563.               status = .T.
  4564.            endif
  4565.         endif 
  4566.      endif
  4567.   endif
  4568. endif
  4569.  
  4570. return (status)
  4571.  
  4572. *
  4573. ** eofunc assign_chk
  4574.  
  4575.  
  4576. ***
  4577. * Function cmd_abbr
  4578. * kjs, 04/17/86
  4579. * Checks verb for correct abbreviation.
  4580. *
  4581. *    Usage   : cmd_abbr(<string1>, <string2>)
  4582. *
  4583. *        <string1> - upper of verb to check.
  4584. *        <string2> - upper full spelling of verb.
  4585. *
  4586. *     Returns :
  4587. *        .T. - s1 ok.
  4588. *        .F. - s1 NOT ok.
  4589. *
  4590. *    Notes      :
  4591. *        1. DIR is an exception to the four char abbreviation definition.        
  4592. *
  4593.  
  4594. function cmd_abbr
  4595.  
  4596. parameters s1, s2
  4597.  
  4598. private status, s1_len, abbr_len
  4599.  
  4600. status = .F.
  4601. s1_len = len(s1)
  4602. abbr_len = len(s2)
  4603.  
  4604. if abbr_len > 4
  4605.     abbr_len = 4
  4606. endif
  4607.  
  4608. s1 = "." + s1
  4609. s2 = "." + s2
  4610.  
  4611. if s1$s2 .and. s1_len >= abbr_len .or. s1 == ".DIR"
  4612.     status = .T.
  4613. endif
  4614.  
  4615. return (status)
  4616.  
  4617. *
  4618. ** eofunc cmd_abbr
  4619.  
  4620.  
  4621. ***
  4622. * Function cnd_scp
  4623. * kjs, 05/01/86
  4624. * Evaluates the stack for condition and scope.  Called from procedures that
  4625. * need to analyze conditions and/or scope key words.
  4626. *
  4627. *    Usage :    cnd_scp()
  4628. *
  4629. *     Returns:
  4630. *        .T. - if no error occurred in analysis.
  4631. *        .F. - error occurred.
  4632. *
  4633. *    Control variables effected:
  4634. *        Strings   -   condition
  4635. *                      scope
  4636. *
  4637. *        Logicals  -   for
  4638. *                      while
  4639. *                      record
  4640. *                      all
  4641. *                      next
  4642. *                      rewind_dbf
  4643. *                      to
  4644. *                      source
  4645. *
  4646. *        Numerics  -   scope
  4647. *
  4648.  
  4649. function cnd_scp
  4650.  
  4651. rewind_dbf = .F.
  4652.  
  4653. do while stack_ptr <= max_ptr .and. !err()
  4654.  
  4655.     stack_item = upper(stack[stack_ptr])
  4656.  
  4657.     do case
  4658.         case stack_item = "FOR"
  4659.             condition = get_expr1("exp1")
  4660.             if condition
  4661.                 for = .T.
  4662.                 rewind_dbf = .T.
  4663.             else
  4664.                 ERRS2 = .T.
  4665.             endif
  4666.  
  4667.         case cmd_abbr(stack_item, "WHILE")
  4668.             condition = get_expr1("exp2")
  4669.             if condition
  4670.                 while = .T.
  4671.                 rewind_dbf = .F.
  4672.             else
  4673.                 ERRS2 = .T.
  4674.             endif
  4675.  
  4676.         case cmd_abbr(stack_item, "RECORD")
  4677.             if get_expr1("exp3") .and. is_num(&exp3)
  4678.                 if &exp3 <= lastrec()
  4679.                     record = .T.
  4680.                     scope = 1
  4681.                     rewind_dbf = .F.
  4682.                     exp3 = "recno() = &exp3"
  4683.                 else
  4684.                     ERRS6 = .T.
  4685.                 endif
  4686.             else
  4687.                 ERRS2 = .T.
  4688.             endif
  4689.  
  4690.         case stack_item = "ALL"
  4691.             all = .T.
  4692.             scope = 2
  4693.             rewind_dbf = .T.
  4694.             stack_ptr = stack_ptr + 1
  4695.  
  4696.         case stack_item = "NEXT"
  4697.             if get_expr1("exp3") .and. is_num(&exp3)
  4698.                 next = .T.
  4699.                 scope = 3
  4700.                 rewind_dbf = .F.
  4701.             else    
  4702.                 ERRS2 = .T.
  4703.             endif
  4704.  
  4705.         case stack_item = "TO"
  4706.             if get_expr1("dest")
  4707.                 to = .T.
  4708.             else
  4709.                 ERRS2 = .T.
  4710.             endif
  4711.  
  4712.         case stack_item = "FROM"
  4713.             if get_expr1("source")
  4714.                 source = .T.
  4715.             else
  4716.                 ERRS2 = .T.
  4717.             endif
  4718.  
  4719.         otherwise
  4720.             stack_ptr = stack_ptr + 1
  4721.     endcase
  4722. enddo
  4723.  
  4724. return (!err())
  4725.  
  4726. *
  4727. ** eoproc cnd_scp
  4728.  
  4729.  
  4730. ***
  4731. * Function err
  4732. * Check for error status flags set.
  4733. *
  4734. *    Usage : err()
  4735. *
  4736. *    Returns:
  4737. *        .T. - if any of the error flags are set.
  4738. *
  4739.  
  4740. function err
  4741.  
  4742. private status
  4743.  
  4744. status = .F.
  4745.  
  4746. if error_on
  4747.     if ERRS1 .or. ERRS2 .or. ERRS3 .or. ERRS4 .or. ERRS5 .or. ERRS6 .or. ERRS7;
  4748.         .or. ERRS8 .or. ERRS9 .or. ERRS10 .or. ERRS11 .or. ERRS12 .or. ERRS13;
  4749.         .or. ERRS14 .or. ERRS15
  4750.         status = .T.
  4751.     endif
  4752. endif
  4753.  
  4754. return (status)
  4755.  
  4756. *
  4757. ** eofunc err
  4758.  
  4759.  
  4760. ***
  4761. * Function fld_form
  4762. * kjs, 04/24/86
  4763. * Provides the correct column formatting for any given field type.
  4764. * Called by the list_do procedure.
  4765. *
  4766. *    Usage     : fld_form(<character expression>)
  4767. *
  4768. *        <character expression> - name of field to provide formatting
  4769. *                                 for.
  4770. *
  4771. *     Returns :
  4772. *        Output format string for fieldname.
  4773. *
  4774.  
  4775. function fld_form
  4776.  
  4777. parameters fld_name
  4778.  
  4779. private type, fld_form
  4780.  
  4781. type = type("&fld_name")
  4782.  
  4783. do case
  4784.     case type = "C"
  4785.         fld_form = fld_name
  4786.  
  4787.     case type = "D"
  4788.         fld_form = "dtoc(&fld_name)"
  4789.  
  4790.     case type = "L"
  4791.         fld_form = [if((&fld_name), ".T.", ".F.")]
  4792.  
  4793.     case type = "M"
  4794.         fld_form = ["Memo      "]
  4795.  
  4796.     case type = "N"
  4797.         fld_form = "str(&fld_name)"
  4798. endcase
  4799.  
  4800. return (fld_form)
  4801.  
  4802. *
  4803. ** eofunc fld_form
  4804.  
  4805.  
  4806. ***
  4807. * Function get_expr1()
  4808. * kjs, 04/09/86
  4809. * Fills the passed variable.
  4810. *
  4811. *    Usage   : get_expr1(<var_name>)
  4812. *
  4813. *        <var_name> -  contains name of target variable.
  4814. *
  4815. *    Returns :
  4816. *        .T. - variable is NOT empty.
  4817. *        .F. - variable is empty.
  4818. *
  4819. *    Notes   :
  4820. *
  4821. *            1. Increments stack pointer before getting stack item.
  4822. *            2. Leaves the stack pointer at the next item on stack.  
  4823. *            
  4824.  
  4825. function get_expr1
  4826.  
  4827. parameters var_name
  4828.  
  4829. private current, next, get_more
  4830.  
  4831. current = ""
  4832. next = ""
  4833. get_more = .F.
  4834. stack_ptr = stack_ptr + 1
  4835.  
  4836. if stack_ptr <= max_ptr
  4837.     &var_name = &var_name + stack[stack_ptr]
  4838.     stack_ptr = stack_ptr + 1
  4839.  
  4840.     if current <> ","
  4841.         if stack_ptr <= max_ptr
  4842.             next = stack[stack_ptr]
  4843.  
  4844.             if &var_name$"+-!.\" .or. substr(next,1,1)$"|+-/%*<>=#.!$^(["
  4845.                 get_more = .T.
  4846.             endif
  4847.  
  4848.         endif
  4849.     endif
  4850. endif
  4851.  
  4852. do while get_more
  4853.  
  4854.     get_more = .F.
  4855.     current = stack[stack_ptr]
  4856.     &var_name = &var_name + current
  4857.     stack_ptr = stack_ptr + 1
  4858.  
  4859.     if stack_ptr <= max_ptr
  4860.         next = stack[stack_ptr]
  4861.         if current$"|+-/%*<>=#.!$^==" .and. next <> "," .or.;
  4862.             substr(next,1,1)$"|+-/%*<>=#.!$^([" .and. current <> ","
  4863.              get_more = .T.
  4864.         endif
  4865.     endif
  4866.  
  4867. enddo
  4868.  
  4869. return ("" <> &var_name)
  4870.  
  4871. *
  4872. ** eofunc get_expr1
  4873.  
  4874.  
  4875. ***
  4876. * Function get_list
  4877. * Gets a list of expression from the stack.  List variables start at 1.
  4878. *
  4879. *    Usage  :  get_list(<control string>)
  4880. *
  4881. *        <control string> - indicates that the list contains....
  4882. *
  4883. *                    "E"     - expressions.
  4884. *                    "NF" - index files.
  4885. *
  4886. *    Returns :
  4887. *        .T. - list filled successfully, or if "NF" and empty.
  4888. *        .F. - list is empty or error occurred.
  4889. *
  4890. *    Notes   :
  4891. *
  4892. *        1. If string = "NF" and error_on = .F. no index file
  4893. *           checking is done.
  4894. *        2. Increments stack pointer before getting something from the
  4895. *           stack.
  4896. *        3. Leaves stack pointer at next item on stack.
  4897. *
  4898.  
  4899. function get_list
  4900.  
  4901. parameters list_type
  4902.  
  4903. private get_more, count, list_ok, stack_item, null
  4904.  
  4905. if stack_ptr <= max_ptr
  4906.     list_ok = .T.
  4907.     get_more = .T.
  4908.     count = "0"
  4909.     stack_item = ""
  4910. else
  4911.     get_more = .F.
  4912.     if list_type = "NF"
  4913.         list_ok = .T.
  4914.     else
  4915.         list_ok = .F.
  4916.     endif
  4917. endif
  4918.  
  4919. do while get_more
  4920.     get_more = .F.
  4921.     stack_item = ""
  4922.  
  4923.     null = get_expr1("stack_item")
  4924.  
  4925.     if stack_item <> ","
  4926.         if list_type = "NF"
  4927.             list_ok = if(error_on, file("&stack_item..NTX"), .T.)
  4928.         endif
  4929.         if list_ok
  4930.             store stack_item to list&count
  4931.             count = str(val(count)+1,1)
  4932.         endif
  4933.     endif
  4934.  
  4935.     if stack_ptr <= max_ptr .and. val(count) < 10 .and. list_ok
  4936.         if stack[stack_ptr] = ","
  4937.             get_more = .T.
  4938.         endif
  4939.     endif
  4940. enddo
  4941.  
  4942. return (list_ok)
  4943.  
  4944. *
  4945. ** eofunc get_list
  4946.  
  4947.  
  4948. ***
  4949. * Function get_stack
  4950. * kjs, 04/09/86
  4951. * Fills the variable passed in var_name.
  4952. *
  4953. *     Usage    : get_stack(<var_name>)
  4954. *
  4955. *        <var_name> - literal name of variable to store expression to.
  4956. *
  4957. *    Returns:
  4958. *        .T. - if NOT null
  4959. *        .F. - if null.
  4960. *
  4961. *    Notes:
  4962. *
  4963. *        1. Does NOT increment the stack pointer before getting 
  4964. *           something from the stack.
  4965. *         2. Leaves the stack pointer at the next item on the stack.  
  4966. *
  4967.  
  4968. function get_stack
  4969.  
  4970. parameters var_name
  4971.  
  4972. private current, next, get_more
  4973.  
  4974. current = ""
  4975. next = ""
  4976. get_more = .F.
  4977.  
  4978. if stack_ptr <= max_ptr
  4979.  
  4980.     &var_name = stack[stack_ptr]
  4981.     current = &var_name
  4982.     stack_ptr = stack_ptr + 1
  4983.  
  4984.     if stack_ptr <= max_ptr
  4985.         next = upper(stack[stack_ptr])
  4986.     endif
  4987.  
  4988.     if current <> ","
  4989.         if current$"+-!\*.?" .or. substr(next,1,1)$"|+-/%*<>=#!$^([?*."
  4990.             get_more = .T.
  4991.         endif
  4992.     endif
  4993. endif
  4994.  
  4995. do while get_more
  4996.  
  4997.     get_more = .F.
  4998.     current = stack[stack_ptr]
  4999.     &var_name = &var_name + current
  5000.     stack_ptr = stack_ptr + 1
  5001.  
  5002.     if stack_ptr <= max_ptr
  5003.         next = stack[stack_ptr]
  5004.         if substr(current,1,1)$"|+-/%*<>=#.!$^=?" .and. next <> "," .or.;
  5005.             substr(next,1,1)$"|+-/%*<>=#.!$^([?" .and. current <> ","
  5006.              get_more = .T.
  5007.         endif
  5008.     endif
  5009.  
  5010. enddo
  5011.  
  5012. return (!(&var_name == ""))
  5013.  
  5014. *
  5015. ** eofunc get_stack
  5016.  
  5017.  
  5018. ***
  5019. * Function is_n_expr
  5020. * kjs, 04/09/85
  5021. * Checks the contents of eval_item for numeric type.
  5022. *
  5023. *     Usage     : is_n_expr(<eval_item>)
  5024. *
  5025. *         <eval_item> - macro expanded string.
  5026. *
  5027. *    Returns : 
  5028. *        .T. - item is numeric.
  5029. *        .F. - item is NOT numeric.
  5030. *
  5031.  
  5032. function is_n_expr
  5033.  
  5034. parameters eval_item
  5035.  
  5036. return (type("eval_item")$"N")
  5037.  
  5038. *
  5039. ** eofunc is_n_expr
  5040.  
  5041.  
  5042. ***
  5043. * Function is_num
  5044. * kjs, 04/11/86
  5045. * checks if a string contains only numbers.
  5046. *
  5047. *     Usage     : is_num(<eval_item>)
  5048. *
  5049. *         <eval_item> - macro expanded string.
  5050. *
  5051. *    Returns : 
  5052. *        .T. - item is string of numbers.
  5053. *        .F. - item is NOT a string of numbers.
  5054. *
  5055. *
  5056.  
  5057. function is_num
  5058.  
  5059. parameters string
  5060.  
  5061. private status, len, counter
  5062.  
  5063. if type("string")$"NC"
  5064.     if type("string") = "N"
  5065.         string = str(string)
  5066.     endif
  5067.  
  5068.     string = ltrim(string)
  5069.     status = .T.
  5070.     len = len(string)
  5071.     counter = 1
  5072.  
  5073.     do while counter <= len .and. status
  5074.         if !substr(string,counter,1)$"0123456789"
  5075.             status = .F.
  5076.         endif
  5077.         counter = counter + 1
  5078.     enddo
  5079. else
  5080.     status = .F.
  5081. endif
  5082.  
  5083. return (status)
  5084.  
  5085. *
  5086. ** eofunc is_num
  5087.  
  5088.  
  5089. ***
  5090. * Function spacer_h
  5091. * kjs, 04/23/86
  5092. * Build a string for a list/display header.
  5093. * Called by the list_do procedure.
  5094. *
  5095. *     Usage     : spacer_h(<field name>)
  5096. *
  5097. *        <field name> - name of the field to format.
  5098. *
  5099. *    Returns :
  5100. *        Character string containing field name plus the number of
  5101. *        blanks to pad the column out.
  5102. *
  5103. *    Notes   :
  5104. *
  5105. *        1. Called from procedure list_do.
  5106. *
  5107.  
  5108. function spacer_h
  5109.  
  5110. parameter fld_name
  5111.  
  5112. private type, string
  5113.  
  5114. type = type("&fld_name")
  5115. string = ""
  5116.  
  5117. do case
  5118.     case type = "C"
  5119.         string = fld_name + space(if(len(fld_name) >= len(&fld_name), 1,;
  5120.             (len(&fld_name) - len(fld_name)) + 1))
  5121.  
  5122.     case type = "D"
  5123.         string = fld_name + space(if((len(fld_name) >= 8), 1,;
  5124.             (8 - len(fld_name)) + 1))
  5125.  
  5126.     case type = "L"
  5127.         string = fld_name + space(if((len(fld_name) >= 3), 1,;
  5128.             (3 - len(fld_name)) + 1))
  5129.  
  5130.     case type = "M"
  5131.         string = fld_name + space(if((len(fld_name) = 10), 1,;
  5132.             (10 - len(fld_name)) + 1))
  5133.  
  5134.     case type = "N"
  5135.         string = space(if((len(fld_name) >= len(str(&fld_name))), 0,;
  5136.             (len(str(&fld_name)) - len(fld_name)))) + fld_name + space(1)
  5137. endcase
  5138.  
  5139. return (string)
  5140.  
  5141. *
  5142. ** eofunc spacer_h
  5143.  
  5144.  
  5145. ***
  5146. * Function spacer_l
  5147. * kjs, 04/23/86
  5148. * Calculate the number of characters to pad a list/display line.
  5149. * Called by the list_do procedure.
  5150. *
  5151. *     Usage     : spacer_h(<field name>)
  5152. *
  5153. *        <field name> - name of the field pad.
  5154. *
  5155. *    Returns :
  5156. *        Number of spaces needed to pad out a column in a screen
  5157. *        output line.
  5158. *
  5159. *    Notes   :
  5160. *
  5161. *        1. Called from procedure list_do.
  5162. *
  5163.  
  5164. function spacer_l
  5165.  
  5166. parameters fld_name
  5167.  
  5168. private type, blanks
  5169.  
  5170. type = type("&fld_name")
  5171. blanks = 0
  5172.  
  5173. do case
  5174.     case type = "C"
  5175.         blanks = if(len(&fld_name) >= len(fld_name), 1,;
  5176.             (len(fld_name) - len(&fld_name)) + 1)
  5177.  
  5178.     case type = "D"
  5179.         blanks = if(8 >= len(fld_name), 1, (len(fld_name) - 8) + 1)
  5180.  
  5181.     case type = "L"
  5182.         blanks = if(3 >= len(fld_name), 1, (len(fld_name) - 3) + 1)
  5183.  
  5184.     case type = "M"
  5185.         blanks = if(10 >= len(fld_name), 1, (len(fld_name) - 10) + 1)
  5186.  
  5187.     case type = "N"
  5188.         blanks = if((len(str(&fld_name)) >= len(fld_name)), 1,;
  5189.             (len(fld_name) - len(str(&fld_name)) + 1))
  5190. endcase
  5191.  
  5192. return (ltrim(str(blanks,2)))
  5193.  
  5194. *
  5195. ** eofunc spacer_l
  5196.  
  5197.  
  5198.  
  5199. ***
  5200. *    5.0 error handler for Dot...
  5201. *
  5202.  
  5203. #include "error.ch"
  5204.  
  5205. #define NTRIM(n)        ( LTrim(Str(n)) )
  5206.  
  5207.  
  5208.  
  5209. ***
  5210. *    DotError()
  5211. *
  5212. static func DotError(e)
  5213.  
  5214.     local i, cMessage, aOptions, nChoice
  5215.     local bSaveErrorBlock
  5216.  
  5217.  
  5218.     // switch to system error handler (in case of error in here)
  5219.     bSaveErrorBlock := ErrorBlock(SysErrorBlock)
  5220.  
  5221.  
  5222.     // for network open error, set NETERR() and alert user
  5223.     if ( e:genCode == EG_OPEN .and. e:osCode == 32 )
  5224.         NetErr(.t.)
  5225.     end
  5226.  
  5227.     // for lock error during APPEND BLANK, set NETERR() and alert user
  5228.     if ( e:genCode == EG_APPENDLOCK .and. e:canDefault )
  5229.         NetErr(.t.)
  5230.     end
  5231.  
  5232.  
  5233.     // build error message
  5234.     cMessage := ErrorMessage(e)
  5235.  
  5236.  
  5237.     // build options array
  5238.     aOptions := {"Break", "Quit"}
  5239.  
  5240.     if (e:canRetry)
  5241.         AAdd(aOptions, "Retry")
  5242.     end
  5243.  
  5244.     if (e:canDefault)
  5245.         AAdd(aOptions, "Default")
  5246.     end
  5247.  
  5248.  
  5249.     // put up alert box
  5250.     nChoice := 0
  5251.     while ( nChoice == 0 )
  5252.  
  5253.         if ( Empty(e:osCode) )
  5254.             nChoice := Alert( cMessage, aOptions )
  5255.  
  5256.         else
  5257.             nChoice := Alert( cMessage + ;
  5258.                             ";(DOS Error " + NTRIM(e:osCode) + ")", ;
  5259.                             aOptions )
  5260.         end
  5261.  
  5262.     end
  5263.  
  5264.  
  5265.     // switch back to our error handler before leaving
  5266.     ErrorBlock(bSaveErrorBlock)
  5267.  
  5268.  
  5269.     // do as instructed
  5270.     if ( !Empty(nChoice) )
  5271.  
  5272.         if ( aOptions[nChoice] == "Break" )
  5273.             Break(e)
  5274.  
  5275.         elseif ( aOptions[nChoice] == "Retry" )
  5276.             return (.t.)
  5277.  
  5278.         elseif ( aOptions[nChoice] == "Default" )
  5279.  
  5280.             // default for division by zero is zero
  5281.             if ( e:genCode == EG_ZERODIV )
  5282.                 return (0)
  5283.  
  5284.             end
  5285.  
  5286.             return (.f.)
  5287.  
  5288.         end
  5289.  
  5290.     end
  5291.  
  5292.  
  5293.     // display message and quit
  5294.     if ( !Empty(e:osCode) )
  5295.         cMessage += " (DOS Error " + NTRIM(e:osCode) + ") "
  5296.     end
  5297.  
  5298.  
  5299.     ? cMessage
  5300.     ErrorLevel(1)
  5301.     QUIT
  5302.  
  5303. return (.f.)
  5304.  
  5305.  
  5306.  
  5307. /***
  5308. *    ErrorMessage()
  5309. */
  5310. static func ErrorMessage(e)
  5311.  
  5312.     local cMessage
  5313.  
  5314.  
  5315.     // start error message
  5316.     cMessage := if( e:severity > ES_WARNING, "Error ", "Warning " )
  5317.  
  5318.  
  5319.     // add subsystem name if available
  5320.     if ( ValType(e:subsystem) == "C" )
  5321.         cMessage += e:subsystem()
  5322.     else
  5323.         cMessage += "???"
  5324.     end
  5325.  
  5326.  
  5327.     // add subsystem's error code if available
  5328.     if ( ValType(e:subCode) == "N" )
  5329.         cMessage += ("/" + NTRIM(e:subCode))
  5330.     else
  5331.         cMessage += "/???"
  5332.     end
  5333.  
  5334.  
  5335.     // add error description if available
  5336.     if ( ValType(e:description) == "C" )
  5337.         cMessage += ("  " + e:description)
  5338.     end
  5339.  
  5340.  
  5341.     // add either filename or operation
  5342.     if ( !Empty(e:filename) )
  5343.         cMessage += (": " + e:filename)
  5344.  
  5345.     elseif ( !Empty(e:operation) )
  5346.         cMessage += (": " + e:operation)
  5347.  
  5348.     end
  5349.  
  5350.  
  5351.     return (cMessage)
  5352.  
  5353. *
  5354. *
  5355. ** eof dot.prg
  5356.  
  5357.