home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / lambda / soundpot / a / dbtips.lbr / DBREF.NZE / DBREF.NTE
Encoding:
Text File  |  1993-10-26  |  46.6 KB  |  1,212 lines

  1.  INDEX TO dBASE II USAGE TIPS
  2.  ============================
  3.  Menu
  4.  Choice  Item
  5.  ----------------------------
  6.     1    # function
  7.          $ (substring) function with length of zero
  8.          & (macro) function
  9.          @...GET and function key input
  10.          @...SAY...GET
  11.          @...SAY...GET
  12.          @...SAY...GET
  13.  
  14.    2    Address to load assembly routines
  15.          APPEND FROM ... DELIMITED
  16.          APPEND FROM ... SDF with large records
  17.          APPEND FROM <filename> FOR # > <number>
  18.          APPENDing a text file with Tab characters
  19.          CREATE -- Cannot CREATE or RENAME using reserved device
  20. names
  21.          dGEN - Add Option
  22.          dGEN - Limit 14 Fields
  23.          dGEN - Report Option
  24.          Disabling Page Ejects
  25.          dSORT Patch for some 8-bit Computers
  26.  
  27.    3    EDIT - Entering alternate characters in a datafile
  28.          ESC key on CP/M-86
  29.          Expressions - Nesting limit of 7 parentheses
  30.          FILE IS CURRENTLY OPEN error message
  31.          FOR <numeric> clause
  32.  
  33.    4    FOR and WHILE clauses, using both in same statement
  34.          INDEX - Creating duplicate index entries
  35.          INDEX - General rules
  36.          Index operation
  37.          INDEX, another way to TRIM the key expression
  38.          INDEXing on a field in another SELECTed area
  39.  
  40.    5    INSERT [BEFORE] [BLANK] on an indexed database file
  41.          LIST FILES
  42.          LOCATE
  43.          LOCATE and CONTINUE
  44.          MODIFY COMMAND command line limit
  45.          MODIFY STRUCTURE, Restoring a database file after
  46.  
  47.     6    Numeric precision at 10 digits
  48.          PACK
  49.          QUIT TO considerations
  50.          REPLACE ALL on an indexed database file
  51.          RESET
  52.          SET ALTERNATE TO <file>
  53.          SET COLOR on the TI Professional
  54.          SET DELETED ON/OFF
  55.  
  56.     7    SET FORMAT TO PRINT
  57.          SET LINKAGE ON / OFF
  58.          STORE - Cannot change TYPE of memvars
  59.          TEST() function
  60.          TOTALing on a numeric field ------------------------- {
  61. { {.
  62.  
  63. 1
  64.  
  65.  
  66.  >>> # function.
  67.  The # (current record number) function refers only to the data
  68. file in USE. When using the APPEND FROM command, if the #
  69. function is used in the FOR <exp>, the record number referenced
  70. will be the data file in USE and not the data file being
  71. appended.
  72.  
  73. >>> $ (substring) function with length of zero.
  74.  If you use the $(substring)function with a length parameter of
  75. zero, the $(substring) function will return a logical true (.T.)
  76. value rather than a null string.  For example:
  77.  
  78.      STORE "abc" to string
  79.      ? $( string,1,0 )
  80.      .T.
  81.  
  82. his is true for all versions of dBASE II.
  83.  
  84. >>> & (macro) function.
  85.  The correct syntax when using two macros--one for the drive name
  86. and the other for the filename--is the following:
  87.  
  88.     USE &drive.:&filename
  89.                ^-----------Notice where the period is placed.
  90.  
  91. >>> @...GET and function key input.
  92.  A function key string value may be entered into a memory
  93. variable with the use of the interactive commands, such as ACCEPT
  94. TO memvar and INPUT TO memvar.  For example, with the following
  95. command sequence,
  96.  
  97. SET F1 TO "ABC;" ACCEPT "Enter a value " TO memvar
  98.  
  99. pressing F1 at the ACCEPT prompt will place "ABC" in the memory
  100. variable, memvar.  However, function key string values cannot be
  101. entered in @...GET commands.  The cursor will not respond to any
  102. function key input.
  103.  
  104. >>> @...SAY...GET
  105.  (1) The output of an @...SAY with a $ (substring) function in
  106. its <exp> will not display correctly when the third parameter in
  107. the $ function is a numeric variable.  For example, the following
  108. code will display a "t" on the screen rather than "thi."
  109.  
  110.     STORE "this is a string" TO source
  111.      STORE 3 TO length
  112.      @ row,col SAY $( source, 1, length)
  113.  
  114. The work-around is to STORE the substring to a memory variable
  115. and display the memory variable:
  116.  
  117.     STORE $( source, 3, 8 ) TO workstring
  118.      @ row,col SAY workstring
  119.  
  120. (2) When using an @...SAY...USING statement with an "xxxx" or an
  121. "AAAA" format to display a string variable, the "x"s or "A"s are
  122. displayed instead of the value in the variable.
  123.  The work-around is to use uppercase "X"s instead of "x"s or
  124. "A"s.
  125.  (3) After 64 @...GETs the cursor will jump to an unexpected
  126. location on the screen (usually, to the far right of the screen)
  127. and the system will hang.
  128.  The work-around is to use CLEAR GETS or ERASEbeorethe64t GT to
  129. clear the GET table.
  130.  (4) An @...GET with a PICTURE format beginning with a period
  131. will not work correctly.  For example,
  132.  
  133.     STORE 0.000 TO number
  134.      @ row,col GET number PICTURE ".999"
  135.      READ
  136.  
  137. In the above code, when one enters a value of 123, the number
  138. memvar will receive a value of 123.000 instead of the desired
  139. value of 0.123.
  140.  The work-around is to begin the PICTURE clause with the
  141. character nine:
  142.  
  143.     STORE 0.000 TO number
  144.      @ row,col GET number PICTURE "9.999"
  145.      READ
  146.  
  147. (5) The @...SAY will ignore the TRIM() function and print the
  148. argument of the TRIM() with its trailing blanks.  The following
  149. example will print "hello   " and not the desired "hello":
  150.  
  151.      STORE "hello   " TO source
  152.      @ row,col SAY TRIM( source )
  153.  
  154. The work-around is to STORE the argument of the TRIM() function
  155. to a memvar and display the memvar:
  156.  
  157.      STORE "hello   " TO source
  158.      STORE TRIM( source ) TO workstring
  159.      @ row,col SAY workstring
  160.  
  161. >>> @...SAY...GET
  162.  
  163.  (1) You should verify that the correct function symbols are used
  164. in the PICTURE and USING clauses because dBASE II will not trap
  165. incorrect symbols.
  166.  (2) You may use the "#" and "9" functions in the PICTURE and
  167. USING clauses with numeric and character variables.  However,
  168. @...SAY...USING will only display numeric type variables.
  169. @...GET...PICTURE will only allow entry of numbers whether the
  170. variable is defined as character or numeric.
  171.  (3) You are properly using the "$" and "*" functions in
  172. @...SAY...USING with a numeric variable when replacing blanks. Do
  173. not use these functions in an @...GET...PICTURE.  These functions
  174. should be used together with the "9" or "#" function, otherwise
  175. the number will be truncated from the decimal point to the end.
  176. For example,
  177.  
  178.  
  179.      STORE 3.12 TO num
  180.      @ 2,12 SAY num USING "$$$$"
  181.  
  182.                 $$$3
  183.  
  184.     @ 6,12 SAY num USING "$$9.99"
  185.  
  186.                 $$3.12
  187.  
  188. (4) An @...GET with a PICTURE format beginning with a period will
  189. not work correctly.  For example, in the following code:
  190.  
  191.     STORE 0.000 TO number
  192.      @ row,col GET number PICTURE ".999"
  193.      READ
  194.  
  195. hen you enter a value of 123, number will receive a value of
  196. 123.000 instead of the desired value of 0.123.
  197.  The work-around is to write the PICTURE clause with a leading
  198. nine, such as:
  199.  
  200.     STORE 0.000 TO number
  201.      @ row,col GET number PICTURE "9.999"
  202.      READ
  203.  
  204. (5) You will use the "!" function properly when you use it in an
  205. @...GET...PICTURE command with a character type variable.  Use
  206. this function only with character type strings.
  207.  (6) Always verify that the PICTURE functions and lengths used in
  208. an @...GET...PICTURE clause correspond to the type and length of
  209. the variables used.  If you use an incorrect PICTURE function in
  210. an @...GET with a numeric variable, the number will be
  211. incorrectly displayed and may alter the data in the variable. For
  212. example, on a PICTURE clause that is smaller than the field
  213. length, you will get the following (assuming Number is a numeric
  214. field of width 5 with 2 decimal places):
  215.  
  216.     REPLACE Number WITH  50.00
  217.      ? Number
  218.      50.00
  219.  *
  220.      @ 17,5 GET Number PICTURE "9.99"
  221.  
  222.           :5. 0:
  223.  
  224.      ? Number
  225.        5.00
  226.  
  227. however, LIST will display the correct value of 50.00.
  228.  Another example is if the PICTURE clause contains blanks in an
  229. @...GET...PICTURE, a READ command will drop through the variable
  230. being read. The blank character is not a valid PICTURE function.
  231.  
  232. >>> @...SAY...GET
  233.  (1) The USING clause is used with the SAY command and the
  234. PICTURE clause is used with the GET command.  @...SAY...PICTURE,
  235. which is incorrect, will not result in a syntax error, but
  236. @...GET...USING, which is also incorrect, will state that there
  237. is an error in the field specification.
  238.  (2) When you use a PICTURE or USING clause with lowercase "x"s
  239. (or any other invalid function) for a string variable, the "x"s
  240. are displayed instead of the value in the variable.  This will
  241. also happen if the clause contains "A"s.
  242.  The work-around is to use uppercase "X"s instead of: lowercase
  243. "x"s, "A"s, blanks, or other characters.
  244. 2
  245.  
  246.  
  247.  >>> Address to load assembly routines
  248.  Assembly code subroutines should be loaded above EB00H (60160D)
  249. for 16-bit formats of version 2.41.  The starting address for the
  250. 8-bit formats of this version is B000H (45056D).
  251.  
  252. >>> APPEND FROM ... DELIMITED
  253.  An attempt to use the WITH clause in the APPEND FROM DELIMITED
  254. command will give a syntax error.
  255.  Instead, use the APPEND FROM <filename> DELIMITED command
  256. without the WITH clause.  This defaults to comma delimited fields
  257. with double quotes around string fields.
  258.  
  259. >>> APPEND FROM ... SDF with large records
  260.  One cannot APPEND a text file with 998, 999, or 1000 characters
  261. per record into a corresponding dBASE II file.  Any attempt to do
  262. this will append a blank record between each good record in the
  263. file.  Records of 997 characters will correctly append into a
  264. similarly structured file.
  265.  
  266. >>> APPEND FROM <filename> FOR # > <number>
  267.  No records will be appended when using the following APPEND
  268. command:
  269.  
  270.     USE Dest
  271.      APPEND FROM Source FOR # > 401
  272.  
  273. This is because the # (current record number function) only
  274. returns the record number for the current database file in use.
  275. The work-around is to use the following set of commands:
  276.  
  277.     USE Source
  278.      COPY to Temp FOR # > 401
  279.      USE Dest
  280.      APPEND FROM Temp
  281.  
  282.  >>> APPENDing a text file with Tab characters
  283.  To append an ASCII file that contains Tab characters to a
  284. database file, do the following PIP command at the operating
  285. system level (for CP/M only):
  286.  
  287.     PIP A:ASCII.TXT=A:TABFILE.TXT[T8]
  288.  
  289. This will replace each Tab character with eight blank spaces. You
  290. can put any number following the "T" in the statement. Consult
  291. your CP/M User's Guide for more information.
  292.  Next, determine the proper structure to CREATE the database file
  293. by studying the ASCII.TXT file with DDT or by TYPE-ing the file
  294. in CP/M. Then, in dBASE II, use APPEND with the SDF option to
  295. append the text datafile into the CREATEd dBASE file.
  296.  
  297. >>> CREATE -- Cannot CREATE or RENAME using reserved device names
  298.  You cannot CREATE or RENAME a database file using one of the
  299. reserved device names found on page 6-13 of the IBM DOS 2.00
  300. manual.  Trying to CREATE a file with one of these names results
  301. in one of four conditions.
  302.     I.  Hangs the computer.
  303.           LPT1
  304.           PRN
  305.      II. Garbage to screen.
  306.           CON      <--- Recoverable, but no .DBF is created.
  307.      III."END OF FILE FOUND UNEXPECTEDLY"
  308.           LPT2     <--- The computer will hang.
  309.           LPT3
  310.           NUL
  311.           With printer online to computer
  312.           PRN
  313.           LPT1
  314.      IV."Read fault error reading device" [device name]
  315.             "Abort, Retry, Ignore?"
  316.           AUX
  317.           COM1
  318.           COM2      <--- The computer will hang.
  319.  
  320. >>> dGEN - Add Option
  321.  Early copies of dGEN shipped with dBASE II version 2.43*
  322. generate code that will return the user to the main menu when an
  323. attempt is made to add a new record to the database file.  This
  324. problem only occurs when the database file is indexed on a
  325. numeric field. The problem resides within the add module, option
  326. 2 in the main menu program.  The code looks like this:
  327.  
  328.      DO WHILE addchoice <> 0
  329.         APPEND BLANK
  330.         DO <file>
  331.         CLEAR GETS
  332.         READ
  333.         * ---Code cannot be zero.
  334.         STORE Code TO addchoice
  335.      ENDDO
  336.  
  337. The problem occurs because the command CLEAR GETS precedes the
  338. READ command in the program.  When executing, the GETS defined in
  339. <file> are CLEARed before the READ command has a chance to enter
  340. the full-screen editing mode.  To solve this problem, edit the
  341. file (xx-Main.PRG) so that the READ command precedes the CLEAR
  342. GETS command.
  343.  
  344. >>> dGEN - Limit 14 Fields
  345.  dGEN will generate screen designs for up to 14 fields.  If you
  346. want a custom screen layout that contains more than 14 fields,
  347. the xx-Frame.PRG and xx-Gets.PRG. will have to be changed are to
  348. include more fields.  Xx-Frame.PRG contains the field headings
  349. and xx-Gets.PRG contains the @...GETs.
  350.  
  351. >>> dGEN - Report Option
  352.  
  353.  If you are using the report option of dGEN, and set the left
  354. margin to a value greater than 0, the resulting report run under
  355. the PC/MS-DOS version of 2.43*, will be spaced incorrectly when
  356. output to the printer.  The reason is if the MARGIN is SET to a
  357. value greater than zero, printing multiple @...SAYs to the same
  358. line of the printer will include the margin setting between each
  359. @...SAY.
  360.  
  361. For example:
  362.  
  363.      SET MARGIN TO 10
  364.      SET FORMAT TO PRINT
  365.      @ 2, 5 SAY "This is a"
  366.      @ 2,15 SAY "test"
  367.  
  368. Will result in:
  369.  
  370.  
  371.     This is a           test
  372.                ^---It should be printed here.
  373.  
  374. To work around this problem, edit the report file and change SET
  375. MARGIN to 0. The SET MARGIN TO command line is one of the first
  376. SET commands near the top of the report file.  If a left margin
  377. is desired, the values for the column positions of the @...SAY
  378. commands will have to be increased.
  379.  
  380.  >>> Disabling Page Ejects
  381.  The following are the POKE sequences to disable page ejects in
  382. dBASE II version 2.43*.  This allows duplicate reports to be
  383. printed on one page.  As an example, assume a custom report is
  384. written using the @...SAY command with constants instead of
  385. memory variables for row and column coordinates.  The command
  386. file may like this:
  387.  
  388.     SET FORMAT TO PRINT
  389.      @ 2,20 SAY "Report Heading"
  390.      @ 4, 2 SAY Field1
  391.      @ 5, 2 SAY Field2
  392.      @ 6, 2 SAY Field3
  393.  
  394. If the you try to print this report twice on one page, dBASE II
  395. will eject to a new page before printing the report a second
  396. time.
  397.  There are two conditions that cause dBASE II to send a formfeed
  398. to the printer.
  399.  One, when the EJECT command is used, and two, when the row
  400. coordinate of an @...SAY command being sent to the printer
  401. decreases in value.  In the example above, after the first report
  402. is printed, the line counter is at line 7. Attempting to skip
  403. back to line 2 causes the formfeed.
  404.  Refer to the May 1985 issue of TechNotes, page D2-3 for the POKE
  405. sequences for versions 2.3 through 2.41 of dBASE II and an
  406. explanation of how to control page ejects from within your
  407. programs alleviating the need for the POKE sequences.
  408.  
  409. POKE sequence to disable the sending of the formfeed:
  410.  
  411. POKE 16348,0,0            (version 2.43*, 8-bit)
  412.  POKE 20974,144,144,144    (version 2.43*, PC/MS-DOS)
  413.  
  414.  POKE sequence to restore the sending of the formfeed:
  415.  
  416.  POKE 16348,205,5          (version 2.43*, 8-bit)
  417.  POKE 20974,232,97,177     (version 2.43*, PC/MS-DOS)
  418.  
  419. >>> dSORT Patch for Some 8-bit Computers
  420.  There are two reported problems with dSORT running under CP/M
  421. 2.2.
  422.   1. dSORT gives a "d33 - UNDETERMINED ERROR OCCURRED"
  423.      error message for computers that run ENABLED.
  424.   2. When a database file is sorted onto itself, garbage
  425.      characters are inserted into the database file or added
  426. after
  427.      the last record.
  428.  The following is a patch that corrects these problems on some
  429. computers.  It is not, however, always consistent from one
  430. version of a computer line to another. For example, the patch
  431. works as expected with recent versions of the Kaypro 2 and 4, but
  432. the second problem recurs with the older versions of the Kaypro
  433. 2. The patch also works fine on the double-density Osborne with
  434. the ROM 1.4, but on the Osborne with the ROM 1.43, dSORT gives
  435. the d33 error whenever a sort is attempted.
  436.  To make the patch you will need to use the CP/M 2.2 debugging
  437. utility DDT following the instructions below. Be sure that you
  438. are patching a copy of dSORT and not the original.
  439.  
  440.      (1) Place a copy of DDT into the A: drive.
  441.      (2) Place a copy of dSORT into the B: drive.
  442.      (3) Type the following:
  443.  
  444.          A>DDT B:DSORT.COM
  445.           <header information>
  446.           NEXT PC
  447.           XXYY 0100
  448.           -S0A3C
  449.             0A3C   22    C3 <Return>
  450.             0A3D   C2    75 <Return>
  451.             0A3E   0A    12 <Return>
  452.             0A3F         .  <Return>
  453.  
  454.          -S1275
  455.             1275   00    22 <Return>
  456.             1276   00    C2 <Return>
  457.             1277   00    OA <Return>
  458.             1278   00    F3 <Return>
  459.             1279   00    C3 <Return>
  460.             127A   00    3F <Return>
  461.             127B   00    0A <Return>
  462.             127E         .  <Return>
  463.  
  464.           -S0ABD
  465.             0ABD   2A    C3 <Return>
  466.             0ABE   C8    7C <Return>
  467.             0ABF   0A    12 <Return>
  468.             0AC0         .  <Return>
  469.  
  470.          -S127C
  471.             127C   00    2A <Return>
  472.             127D   00    C8 <Return>
  473.             127E   00    0A <Return>
  474.             127F   00    F9 <Return>
  475.             1280   00    FB <Return>
  476.             1281   00    C9 <Return>
  477.             1282         .  <Return>
  478.  
  479.          -C
  480.  
  481.          A>SAVE 48 B:DSORT.COM
  482.  
  483. you have now successfully patched dSORT.
  484. 3
  485.  
  486.  >>> EDIT - Entering alternate characters in a datafile
  487.  Alt <nnn> can be used in the EDIT and APPEND modes to enter
  488. extended characters into a database field.  For example, holding
  489. down the Alt key and pressing "225" on the numeric keypad will
  490. enter the IBM extended character representation for the Greek
  491. character Beta.
  492.  Additionally, you can use this method to insert extended
  493. characters into a command file that is initially created in
  494. MODIFY COMMAND. However, if you bring the command file into
  495. MODIFY COMMAND a second time, MODIFY COMMAND will strip the high
  496. order bit of the extended characters and leave you with
  497. characters on the lower half of the Extended ASCII Character Set.
  498.  You can also use this method with output going to an Alternate
  499. file.
  500.  
  501.  
  502. >>> ESC key on CP/M-86
  503.  The Esc key must be pressed twice on CP/M-86 machines before it
  504. will take any effect.  This is because CP/M-86 function key
  505. sequences all begin with Esc. When Esc is pressed once, dBASE II
  506. waits for the rest of the sequence before taking any action.
  507. (This is seldom noticed as users frequently hold down the Esc key
  508. when attempting to abort an operation.)
  509.  
  510. >>> Expressions - Nesting limit of 7 parentheses
  511.  There seems to be a limit of seven nested parentheses an
  512. expression can contain.  An expression with eight parentheses
  513. followed by any LIST command will incorrectly bring up part of
  514. the error correction dialogue or reboot the computer.  The
  515. following command sequence will illustrate this.
  516.      STORE "ABCDEF    " to mem1
  517.      STORE STR(((INT(((LEN(TRIM(mem1)))+1)/2))-1),1) to mem2
  518.      LIST STATUS
  519. >>> FILE()
  520.  If the FILE() function is executed and the result is true (.T.),
  521. and then a different disk is inserted into drive B that does not
  522. contain the file last tested for, a second iteration of the
  523. FILE() will erroneously return a true (.T.) value.
  524.  This occurs because the first time the FILE() function is
  525. executed, dBASE II checks the disk directory and loads an image
  526. of the directory into memory.  For subsequent iterations of the
  527. FILE() function, dBASE II first scans the image and then the disk
  528. directory if the file being tested cannot be found in the image.
  529.  If the command RESET B: is issued before the second execution of
  530. the FILE() function, the result will be false (.F.) because the
  531. RESET command forces dBASE II to access the disk when checking
  532. for the existence of a file.
  533.  To ensure that dBASE II version 2.43* always checks the disk
  534. directory for the presence of a file, use the RESET command with
  535. a drive designator between successive executions of the FILE()
  536. function.
  537.  If you are using a version of dBASE II earlier than 2.43*, you
  538. will find that the FILE() function accesses the disk to check the
  539. directory each time the FILE() function is issued.  In this case,
  540. the RESET command is not necessary.
  541.  
  542. >>> FILE IS CURRENTLY OPEN error message
  543.  The error message, "FILE IS CURRENTLY OPEN," will result in the
  544. following three cases.
  545.  CASE (1)
  546.  You have structured your command files in such a way that a sub-
  547. program attempts to run the main program.  For example, the main
  548. program might be:
  549.      * Main.PRG
  550.      ? "Inside main program"
  551.      DO Sub1
  552.      *EOF: Main.PRG
  553.  
  554. and the sub-program might be:
  555.      * Sub1.PRG
  556.      ? "Inside sub-program"
  557.      DO Main             <----  This is incorrect.
  558.      * EOF: Sub1.PRG
  559.  
  560. The "FILE IS CURRENTLY OPEN" error message will display as soon
  561. as dBASE II attempts to execute the "DO Main" command line in
  562. Sub1.PRG. Instead, use the RETURN command in sub-programs to get
  563. back to Main.PRG. CASE (2)
  564.  You have written a command file that attempts to run itself.
  565. For example,
  566.      * Main.PRG
  567.      ? "Inside main program"
  568.      DO Main<--- This is incorrect.
  569.      * EOF: Main.PRG
  570.  CASE (3)
  571.  You are attempting to open the same database file in both the
  572. PRIMARY and SECONDARY work areas.
  573.      SELECT PRIMARY
  574.      USE Names
  575.      SELECT SECONDARY
  576.      USE Names<--- This is incorrect.
  577.  
  578. >>> FOR <numeric> clause
  579.  If you use a numeric expression as the sole argument of a FOR
  580. clause, all non-zero instances of the expression will be
  581. evaluated as true.  For example:
  582.      LIST FOR Number will list all records in which Number is not
  583. a zero.  This will only work if Number is defined as a numeric
  584. field.  However, LIST FOR .NOT. Number will not list records in
  585. which Number is equal to zero.
  586.  This applies for all versions of dBASE II.
  587. 4
  588.  
  589.  
  590.  >>> FOR and WHILE clauses, using both in same statement
  591.  A command that uses both FOR and WHILE in the same command line
  592. is improperly constructed, even though it will not return a
  593. syntax error.  The last clause on the command line is the one
  594. that will be executed.
  595.  
  596. >>> INDEX - Creating duplicate index entries
  597.  The following command sequence will create duplicate key entries
  598. in an index file.  If you do not intend to create duplicate
  599. entries in an index file, this is a programming practice you will
  600. want to avoid:
  601.  
  602.     USE Names INDEX Lname
  603.      FIND Alpha
  604.      STORE # TO recnum
  605.      *---Close the index.
  606.      SET INDEX TO
  607.      *---Change the key field to "Beta" in the EDIT mode.
  608.      EDIT recnum
  609.      SET INDEX TO Lname
  610.      FIND Alpha
  611.      *---Change the key field to "Beta" in the EDIT mode.
  612.      EDIT recnum
  613.      *---Both key fields are now in the index.
  614.      FIND Alpha
  615.      FIND Beta
  616.  
  617. >>> INDEX - General rules
  618.  (1) The index expression or its contents cannot exceed 100
  619. characters.
  620.  (2) dBASE II permits indexing on the concatenation of numeric
  621. fields, but the numeric values will be added when generating the
  622. key.  The fields will have to be converted to STRings when
  623. creating the index.  For example,
  624.  
  625.     INDEX ON STR( part:no, 5 ) + STR( subpart, 3 ) TO Xparts
  626.  
  627.  >>> Index operation
  628.  (1) Neither the index key expression nor its contents can exceed
  629. 100 characters.  This is true even if macro substitution and
  630. substring functions are used in the INDEX ON command line.  An
  631. example of computing the length of the key expression and the
  632. length of its contents is shown with the following INDEX ON
  633. command.
  634.  
  635.     INDEX ON Name + Address TO Myindex
  636.               ^            ^
  637.               |____________|___ This is the key expression.
  638.  
  639.      (a) The length of the key expression is 14.  The plus sign
  640.      and spaces before and after the plus sign are included in
  641.      the count.
  642.  
  643.     (b) Assuming Name is a character field of width 20 and
  644.      Address is a character field of width 30, the length of the
  645.      key contents is 50.
  646.  
  647. (2) dBASE II allows you to create an index on a logical
  648. expression, but the records will not be indexed correctly.  For
  649. example, the following INDEX ON command line is permitted, but
  650. you will find the index file to be useless.
  651.  
  652.     INDEX ON (Name = "Smith") TO Myindex
  653.  
  654. (3) dBASE II allows you to create an index on the concatenation
  655. of numeric fields, but the numeric values will be added (not
  656. concatenated) in the expression evaluation.  With the following
  657. INDEX ON command:
  658.  
  659.     INDEX ON Level + Quantity TO LQindex
  660.     where,
  661.         Level is a numeric field of width 3
  662.         Quantity is a numeric field of width 5
  663.         and RECORD 00001 contains the following:
  664.            Level=3
  665.            Quantity=100
  666.  
  667. he index key value created for RECORD 00001 will have the value
  668. of 103 (that is, 3 + 100 = 103).
  669.  Instead, concatenate the numeric STRing values when creating an
  670. index on numeric fields.  Using the above example, this can be
  671. done in the following manner:
  672.  
  673.      INDEX ON STR( Level,3 ) + STR( Quantity,5 ) TO LQindex
  674.  
  675. >>> INDEX, another way to TRIM the key expression
  676.  dBASE II does not allow the use of the TRIM() function when
  677. creating an index. Quite often you will want an index on the
  678. concatenation of two character fields in which the first field is
  679. TRIMmed. Another way of accomplishing the same result is to use
  680. the minus operator, as in the example below.
  681.  
  682.     . USE Names
  683.      . INDEX ON Fname-Lname TO Namex
  684.      00004 RECORDS INDEXED
  685.      . LIST
  686.      00002 JOE        SMITH
  687.      00003 OPHELIA    UP
  688.      00004 SHECKY     LING
  689.      00001 TOM        RETTIG
  690.      . FIND TOMRETTIG
  691.      . DISPLAY
  692.      00001 TOM        RETTIG
  693.  
  694. The difference between using TRIM() and the minus ("-") operator
  695. is that TRIM() removes the blank spaces and the minus operator
  696. moves them to the end of the string.  Using TRIM() in an INDEX
  697. expression would create variable length keys which dBASE cannot
  698. handle.
  699.  
  700. >>> INDEXing on a field in another SELECTed area
  701.  It is possible to INDEX on a field which is not in the currently
  702. selected work area when two database files are in use.  It makes
  703. no sense to do this and the index file which is created will be
  704. useless, but dBASE II does not trap this as an error.  In the
  705. following example, File1 contains Field1 and File2 contains
  706. Field2.
  707.  
  708.      SELECT PRIMARY
  709.      USE File1
  710.      SELECT SECONDARY
  711.      USE File2
  712.      * --- File2, which contains Field2, is the currently
  713.      * --- selected file.
  714.      INDEX ON Field1 to Ndxfile
  715.      * --- This will return the message that all records have
  716.      * --- been indexed.  The index can be opened with SET
  717.      * --- INDEX TO, but it has no value.  No error message
  718.      * --- appears when this last command is executed.
  719.  
  720. dBASE II will also allow indexing on a memory variable if that
  721. variable is active.  No error message will be given in this
  722. instance either.
  723.  
  724. 5
  725.  
  726.  >>> INSERT [BEFORE] [BLANK] on an indexed database file
  727.  INSERT BLANK on an indexed database file will bring up full-
  728. screen edit.  Also, INSERT and INSERT BEFORE will act as an
  729. APPEND when adding records; it will not insert into the indexed
  730. database file.  These two items are already documented: INSERT
  731. BLANK in the dBASE II version 2.41 Change Summary and INSERT
  732. [BEFORE] in the Reference section of the manual.
  733.  
  734. >>> LIST FILES
  735.  If a file is not a dBASE II database file but happens to have a
  736. 02H as the first byte, a LIST FILES may list the file and give
  737. the error message, "NOT A DBASE II DATABASE."
  738.  
  739. >>> LOCATE
  740.  The LOCATE and CONTINUE commands cannot be used between two data
  741. files.  If the PRIMARY file uses a LOCATE, then the SECONDARY
  742. uses a LOCATE, a CONTINUE back in the PRIMARY will result in a
  743. SKIP to the next record and not a CONTINUE.  The following
  744. program segment illustrates how to LOCATE and CONTINUE between
  745. two data files.
  746.  
  747.     SELECT SECONDARY
  748.      USE Location
  749.      SELECT PRIMARY
  750.      USE Names
  751.      LOCATE FOR Name > "      "
  752.      DO WHILE .NOT. EOF
  753.         ? "Customer Name: ", Name
  754.         SELECT SECONDARY
  755.         LOCATE FOR Code = P.Code
  756.         DO WHILE .NOT. EOF
  757.            ? "    Location: ", Address
  758.            SKIP
  759.            LOCATE NEXT 65535 FOR Code = P.Code
  760.         ENDDO
  761.         SELECT PRIMARY
  762.         SKIP
  763.         LOCATE NEXT 65535 FOR Name > "      "
  764.      ENDDO
  765.  
  766. >>> LOCATE and CONTINUE
  767.  The LOCATE and CONTINUE commands cannot be used on two database
  768. files at the same time.  If the PRIMARY file uses a LOCATE, then
  769. the SECONDARY uses a LOCATE, a CONTINUE back in the PRIMARY will
  770. result in a SKIP to the next record and not a CONTINUE on the
  771. LOCATE expression.  The following program segment illustrates how
  772. to LOCATE and CONTINUE on two database files.
  773.  
  774.  
  775. * ---Open the files. SELECT PRIMARY USE Names
  776.     SELECT SECONDARY
  777.     USE Location
  778.     SELECT PRIMARY * * ---Begin the LOCATE on the PRIMARY file.
  779.     LOCATE FOR Name > "      "
  780.     DO WHILE .NOT. EOF
  781.        ? "Customer Name: ", Name
  782.     *
  783.     * ---Begin the LOCATE on the SECONDARY file.
  784.        SELECT SECONDARY
  785.        LOCATE FOR Code = P.Code
  786.        DO WHILE .NOT. EOF
  787.           ? "    Location: ", Address
  788.           SKIP
  789.     *
  790.     * ---"CONTINUE" the LOCATE on the SECONDARY file.
  791.           LOCATE NEXT 65535 FOR Code = P.Code
  792.        ENDDO
  793.     *
  794.     * ---"CONTINUE" the LOCATE on the PRIMARY file.
  795.        SELECT PRIMARY
  796.        SKIP
  797.  
  798.  
  799.        LOCATE NEXT 65535 FOR Name > "      "
  800.     ENDDO
  801.  
  802. >>> MODIFY COMMAND command line limit
  803.  dBASE II uses a 254 byte buffer to interpret a command line.  If
  804. a command line reaches or exceeds the buffer limit (such as with a
  805. REPLACE command), dBASE II will give unpredictable results.  No
  806. error message is given.
  807.  
  808. >>> MODIFY STRUCTURE, Restoring a database file after
  809.  If you have zeroed out the record count of a database file by
  810. using MODIFY STRUCTURE, you can restore it by using the
  811. FIXHEAD.BAS program found in the February 1985 issue of
  812. TechNotes.  FIXHEAD.BAS will allow you to restore the record
  813. count and remove the end-of-file marker which MODIFY STRUCTURE
  814. places at the end of the header.
  815. 6
  816.  
  817.  >>> Numeric precision at 10 digits
  818.  When performing arithmetic functions with 10 digit numbers, the
  819. number with the fewer digits must appear first in the
  820. multiplication of the two numbers or the last digit of precision
  821. will be lost.  For example,
  822.      . ? 2 * 1234567891
  823.        2461935782
  824.      . ? 1234567891 * 2
  825.        2461935780
  826.  
  827. >>> PACK
  828.  (1) PACK does not release the space made available when removing
  829. deleted records.  The data file will take up the same disk space
  830. as before. This was done for applications which need to
  831. preallocate disk space and still be able to delete records.
  832. COPYing the data file to a new file is the only way to make the
  833. unused space available. The COPY command will not copy deleted
  834. records.
  835.  The old data file can then be erased from the directory or saved
  836. as a backup data file.
  837.  (2) Zeroing-out a data file containing a large number of records
  838. with DELETE ALL and PACK may be a time-consuming process.  A
  839. faster way of zeroing-out a data file with many records is:
  840.  
  841.      USE Origfile
  842.      COPY STRUCTURE TO Temp
  843.      USE
  844.      DELETE FILE Origfile
  845.      RENAME Temp TO Origfile
  846.  
  847.  (3) Since the PACK command alters the database file in USE,
  848. backup procedures should be performed before attempting to PACK
  849. it.  In the event a PACK procedure fails because of a power
  850. glitch or failure, then the backup data file can be reinstated
  851. and the PACK procedure restarted.
  852.  (4) If a PACK procedure has failed due to a power glitch or
  853. failure, an end-of-file mark may have been inserted in the middle
  854. of the data file and the record count (contained in the file's
  855. header) may be incorrect. The records following the inserted EOF
  856. mark are consequently rendered inaccessible (by such commands as
  857. LIST, LOCATE, etc.).  If no backup data file is available then
  858. you will need to:
  859.      a) Change the record count to reflect the number of
  860.      records actually contained by the file (see Technical
  861.      Support Note # 16 for changing the record count).
  862.      b) COPY the top and bottom portions (that is, COPY around
  863.      the embedded end-of-file mark) of the file to two separate
  864.      data files.  (Use the NEXT option of COPY's <scope> clause
  865.      to accomplish this.) Combine the two files using APPEND
  866.      FROM.  For example:
  867.         USE Sickfile
  868.         COPY TO Goodfile   <---Copy to the embedded EOF.
  869.         GOTO # + 2         <---To get around the embedded EOF.
  870.         * ---The record containing the
  871.         * ---embedded EOF will be lost.
  872.         COPY NEXT 65535 TO Temp    <---Copy last portion of file.
  873.         USE Goodfile
  874.         APPEND FROM Temp
  875.         CLEAR
  876.         DELETE FILE Sickfile
  877.         DELETE FILE Temp
  878.  
  879. >>> QUIT TO considerations
  880.  QUIT TO only works under DOS 2.0 or later.  Otherwise, it will
  881. create a file called Dbquitto.BAT and return to the dot prompt.
  882.  Under DOS 2.0, Command.COM must be on the same disk directory as
  883. dBASE II. Otherwise, the error message, "NESTING LIMIT VIOLATION
  884. EXCEEDED," will be displayed when QUIT TO is executed and
  885. Command.COM is missing.
  886.  
  887. >>> REPLACE ALL on an indexed database file
  888.  REPLACE ALL does not replace all records correctly if an index
  889. is in use and the key field is REPLACEd.  Only the first record
  890. and those that logically follow the new value will be REPLACEd.
  891. This occurs because the index is automatically updated (in-place
  892. key updating) when it is edited.  Then the record pointer moves
  893. to the record following the new position, not to the record
  894. following the old position.  This can be illustrated in the
  895. example given below.
  896.  The data file has five records with the field CHARS-C-1, and is
  897. indexed on this field.  The following sequence demonstrates what
  898. occurs.
  899.      . LIST
  900.      Record#  CHARS
  901.            1  a
  902.            2  b
  903.            3  c
  904.            4  i
  905.            5  j
  906.      . REPLACE ALL Chars WITH 'd'
  907.      00003 REPLACEMENT(S)
  908.      . LIST
  909.      Record#  CHARS
  910.            2  b
  911.            3  c
  912.            1  d
  913.            4  d
  914.            5  d
  915.  Page B114 of the manual, paragraph 3, warns against block
  916. replacements to the key field.  The correct procedure would be to
  917. REPLACE with no indexes in use, open the indexes with SET INDEX
  918. TO, and then REINDEX.
  919.  
  920. >>>REPORT FORM
  921.  Reports generated by the REPORT FORM command in dBASE II version
  922. 2.43* now include records marked for deletion when SET DELETED is
  923. OFF and exclude deleted records when SET DELETED is ON.  This
  924. differs from prior versions of dBASE II where the REPORT FORM
  925. excluded records marked for deletion regardless of the status of
  926. SET DELETED.
  927.  Working around this situation for versions prior to 2.43* is
  928. possible, though not always convenient.  To do so,  all records
  929. printed must be active at the time that REPORT FORM is executed.
  930. First MODIFY the STRUCTURE of the database file to include a one-
  931. character status field. At the time the report is to be executed,
  932. use the REPLACE ALL command to replace the status field with an
  933. "N" for all records not marked for deletion.  Then RECALL ALL so
  934. that all records marked for deletion are active and reportable.
  935. Finally, execute the REPORT FORM with a conditional FOR clause
  936. which excludes the records that do not have the value of "N" in
  937. the status field.  The command syntax is:
  938.      * ---Mark all the nondeleted records.
  939.      REPLACE ALL <Status> WITH "N"
  940.      RECALL ALL
  941.      *
  942.      * ---To report on all records.
  943.      REPORT FORM <filename>
  944.      *
  945.      * ---To report on active records only.
  946.      REPORT FORM <filename> FOR Status = "N"
  947.      *
  948.      * ---To report on records marked for deletion only.
  949.      REPORT FORM <filename> FOR Status <> "N"
  950.  Once you have finished REPORTing, issue the DELETE command to
  951. delete all the records which were marked for deletion before the
  952. REPORT FORM was run, and blank out the status field throughout
  953. the entire database file.  The commands are:
  954.      DELETE ALL FOR Status <> "N"
  955.      REPLACE ALL Status WITH " "
  956.  If the edit of the database file is done in a command file, use
  957. the REPLACE command within your program.  For example, before a
  958. record is marked for deletion, REPLACE Status with "D" for that
  959. record.  Please note that if your database file is large,
  960. following these suggestions can be time-consuming.
  961.  
  962. >>> RESET
  963.  When using CP/M at the operating system level, it is necessary
  964. to type Ctrl-C each time a new disk is inserted into a drive.
  965. This resets the CP/M bit map after a disk has been swapped and is
  966. referred to as a warm boot.  If Ctrl-C is not executed between
  967. disk swaps, an I/O errors occur.  In dBASE II, it is also
  968. necessary to reset the system between disk swaps.  The equivalent
  969. to Ctrl-C is the RESET command so that each time a disk is
  970. swapped within a session of dBASE, the RESET command must be
  971. issued.
  972.  The dBASE II documentation manual discusses the RESET command as
  973. it refers to the CP/M versions of dBASE II and not the PC/MS-DOS
  974. versions.  Though PC/MS-DOS does not require the system to be
  975. RESET every time a new disk is inserted, some operations in
  976. version 2.43* require that the RESET command be used.
  977.  For instance, if COPY TO is used to transfer data from one drive
  978. to another, from C: to A: for example, the data transfers
  979. correctly.  However, if after the first COPY TO, the disk in
  980. drive A: is replaced with another disk and COPY TO is issued a
  981. second time using the same target filename, the second disk will
  982. be rendered unusable and may contain lost clusters.  This problem
  983. only occurs if the same target filename is used for both disks.
  984.  
  985. For example:
  986.  
  987.     USE C:Test
  988.      COPY TO A:Temp
  989.      <Disk 2 is inserted into drive A:>
  990.      COPY TO A:Temp
  991.  
  992. <drive> between the two COPY operations prevents this problem.
  993.  When using the RESET command it is necessary to use a drive
  994. designator.  It does not have to refer to a particular drive; any
  995. letter works.  If RESET is not used with the drive designator,
  996. the file is not copied to the second disk, though dBASE still
  997. displays a message indicating that the copy was completed.
  998.  RESET is also necessary when using the FILE() function.  Please
  999. refer to the dBASE II Usage Tips section in the September 1985
  1000. issue of TechNotes for details concerning this function.
  1001.  
  1002. >>> SET ALTERNATE TO <file>
  1003.  When used with a filename, the SET ALTERNATE TO command will
  1004. assign all text (control characters are not allowed) output to a
  1005. disk file.  The SET ALTERNATE TO without a filename will close
  1006. the ALTERNATE file.  This command is used in conjunction with the
  1007. SET ALTERNATE ON/OFF flag.  The SET ALTERNATE ON will begin the
  1008. alternate writing process, and the SET ALTERNATE OFF will turn it
  1009. off.
  1010.  @...SAY commands do not send output to the ALTERNATE file (that
  1011. is, not with the SET ALTERNATE ON command alone).  You will have
  1012. to use the SET FORMAT TO PRINT command in addition to the SET
  1013. ALTERNATE ON, as follows:
  1014.      SET ALTERNATE TO <filename>
  1015.      SET ALTERNATE ON
  1016.      SET FORMAT TO PRINT
  1017.      * ---Disable the printer (limited to CP/M 2.2).
  1018.      POKE PEEK( 2 ) * 256 + 15, 201
  1019.      *
  1020.      *   Statements using the @...SAY commands go here.
  1021.      *
  1022.      * ---Enable the printer (limited to CP/M 2.2).
  1023.      POKE PEEK( 2 ) * 256 + 15, 195
  1024.      SET FORMAT TO SCREEN
  1025.      SET ALTERNATE OFF
  1026.      SET ALTERNATE TO
  1027.  
  1028. >>> SET COLOR on the TI Professional
  1029.  >> Monochrome monitor:
  1030.  The SET COLOR TO <x>,<y> command can be used to change the
  1031. screen attributes of the SAY and GET statements.  The first
  1032. number <x> changes the SAY , and the second number <y> changes
  1033. the GET.  The GET will only be changed with SET INTENSITY ON.
  1034. READ and ERASE will reset the video attributes to normal video.
  1035. The following numbers produce these results forboth <x> and <y>.
  1036. There is a range of seven intensity levels for each video
  1037. attribute.
  1038.     0  Blanks
  1039.     9  Lowest intensity
  1040.    15  Highest intensity
  1041.    25  Lowest intensity reverse video
  1042.    31  Highest intensity reverse video
  1043.    41  Lowest intensity underlined
  1044.    47  Highest intensity underlined
  1045.    73  Lowest intensity flashing
  1046.    79  Highest intensity flashing
  1047.    89  Lowest intensity flashing reverse video
  1048.    95  Highest intensity flashing reverse video
  1049.   105  Lowest intensity flashing underlined
  1050.   111  Highest intensity flashing underlined
  1051.  When dBASE II is loaded, the color setting is SET COLOR TO 12,15
  1052. (where 12 is an intensity shade between 9, Lowest intensity, and
  1053. 15, Highest intensity).
  1054.  >> Color Monitor:
  1055.  With a color monitor the <x> and <y> attributes are the same.
  1056. The only difference is that colors will be produced without the
  1057. range of video intensities.  The following chart gives you the
  1058. numeric values to use.
  1059.  COLOR  NORMAL  REVERSE  UNDER  FLASHING    FLASHING   FLASHING
  1060.                  VIDEO   LINED               REVERSE  UNDERLINED
  1061.  -----------------------------------------------------------------
  1062.  Blue        9    25      41       73          89         105
  1063.  Red        10    26      42       74          90         106
  1064.  Violet     11    27      43       75          91         107
  1065.  Green      12    28      44       76          92        108
  1066.  Light blue 13    29      45       77          93         109
  1067.  Yellow     14    30      46       78          94         110
  1068.  White      15    31      47       79          95         111
  1069.  
  1070. >>> SET DELETED ON / OFF
  1071.  (1) On page B-136 of the dBASE 2.4 and 2.41 manual in the
  1072. paragraph beginning with "19.  DELETED," states that, "records
  1073. marked for deletion cannot be located with the FIND command nor
  1074. processed by any command that allows the NEXT phrase (e.g. LIST,
  1075. LOCATE, COUNT, etc.)" if SET DELETED is ON.  This also applies to
  1076. SKIP, though the syntax for this command does not support a NEXT
  1077. phrase.
  1078.  (2) You cannot COPY, APPEND, REPLACE into, or REPORT deleted
  1079. records whether SET DELETED is ON or OFF.
  1080.  (3) If SET DELETED is ON and the pointer is positioned to a
  1081. record just before a deleted record, SKIP, SKIP+1, and SKIP+2
  1082. each point to the next undeleted record immediately after the
  1083. deleted record.  You might assume that SKIP and SKIP+2 will point
  1084. to two different records, but they point to the same one.
  1085.  (4) SET DELETED ON only works with the currently selected work
  1086. area. For example, if SET LINKAGE and SET DELETED are both ON and
  1087. a LIST command is executed on the PRIMARY file, records marked
  1088. for deletion in the SECONDARY file will be listed (until the
  1089. PRIMARY file reaches the end-of-file marker).
  1090.  
  1091. 7
  1092.  
  1093.  
  1094.  >>> SET FORMAT TO PRINT
  1095.  If you are using @...SAYs to output to the printer with SET
  1096. FORMAT TO PRINT and you press the Esc key, the SET FORMAT TO
  1097. SCREEN command will not get you back to the screen.  The dot
  1098. prompt will appear on the printer and commands can be entered and
  1099. will execute, but these will be echoed to the printer only.  Type
  1100. SET CONSOLE ON and SET PRINT OFF to allow commands to echo back
  1101. to the screen.
  1102.  
  1103. >>> SET LINKAGE ON / OFF
  1104.  SET LINKAGE ON links the file pointers of both PRIMARY and
  1105. SECONDARY data files.  Positioning will be performed on all
  1106. sequential commands that have a <scope> parameter (such commands
  1107. as LIST, REPORT, and LOCATE).  Some known restrictions to the use
  1108. of this flag are listed below.  The most common error message
  1109. reported on this command is the "BDOS ERROR ON [: SELECT".  The
  1110. restrictions are:
  1111.  
  1112.     (1) Both PRIMARY and SECONDARY data files must be
  1113.      indexed or not indexed (that is, both must have an
  1114.      index open or not opened).
  1115.      (2) Both must have the same number of records.  The
  1116.      number of fields does not make a difference.
  1117.  
  1118. >>> STORE - Cannot change TYPE of memvars
  1119.  
  1120.  You cannot change the TYPE of a memory variable and retain the
  1121. memory variable's original value.  For example, the following
  1122. command sequence will leave num with the value of the character
  1123. string "    0" and not " 1234":
  1124.  
  1125.      . STORE 1234 TO num
  1126.      . STORE STR( num, 5 ) TO num
  1127.      . ? num, LEN( num )
  1128.          0    5
  1129.  
  1130.  >>> TEST() function
  1131.  The TEST() function is used to test the parseability of a dBASE
  1132. II expression. The important words to remember are "parseability"
  1133. and "expression". The TEST() function will only test to see if
  1134. the dBASE II interpreter can successfully parse an expression
  1135. (that is, is it syntactically correct) and will not test to see
  1136. whether or not the expression is valid.  For example, if A=1 and
  1137. B=2, and both variables are predefined, then ? TEST(A=B) will be
  1138. evaluated as parseable. The TEST() function will only test an
  1139. expression. The portion of a command that follows the "FOR" is
  1140. the expression.  Consult your dBASE II manual for a further
  1141. definition of an expression.  The TEST() function will return
  1142. different numeric values depending on the expression it has
  1143. parsed:
  1144.  
  1145. TEST() result is:   The expression is:  The expression type is:
  1146.  -----------------   ------------------  -----------------------
  1147.     0                non-parseable       N/A
  1148.    -6                parseable           Numeric
  1149.  positive number     parseable           Character or Logical
  1150.  
  1151. A short program example of how the TEST() function can be used is
  1152. given below:
  1153.  
  1154.     USE Names
  1155.      DO WHILE T
  1156.         ACCEPT ". LIST FOR " TO express
  1157.         IF express = " "
  1158.            RETURN
  1159.         ENDIF
  1160.         IF 0 = TEST(&express)
  1161.            ? "*** BAD EXPRESSION ***"
  1162.         ELSE
  1163.            LIST FOR &express
  1164.         ENDIF
  1165.      ENDDO
  1166.  
  1167.  >>> TOTALing on a numeric field
  1168.  If you TOTAL on a numeric field, it is necessary to use a FIELDS
  1169. phrase that does not include that field name.  The reason for
  1170. this is that dBASE uses the target record and compares its
  1171. contents to the next record in the database file as it is
  1172. totaling.  If you are trying to total the field that you are
  1173. TOTALing ON, the contents in the target record for that field
  1174. changes with each record. Therefore, if the first three records
  1175. in the file have the same key value, the third record in the file
  1176. will not match the target record because it is the sum of the
  1177. first two and TOTAL will not group them together.  A detailed
  1178. example follows.  The file structure of Test.DBF is: Name-C-10,
  1179. Num1-N-5, Num2-N-5. Assuming it is INDEXed on Num1, a LIST would
  1180. display the following:
  1181.  
  1182. NAME   NUM1  NUM2
  1183.  Adam   1000   200
  1184.  Sue    1000   300
  1185.  Mary   1000   200
  1186.  Tom    2000   100
  1187.  Bob    2000   200
  1188.  Ted    4000   100
  1189.  Alice  4000   200
  1190.  
  1191. So you enter TOTAL ON Num1 TO Test2 and...
  1192.  
  1193. WHAT YOU EXPECT IS:            BUT WHAT YOU GET IS:
  1194.  
  1195.  Adam   3000   700              Adam   2000   500
  1196.  Tom    4000   300              Mary   1000   200
  1197.  Ted    8000   300              Tom    8000   400
  1198.                                 Alice  4000   200
  1199. What follows is a table of what is going on internally:
  1200.  
  1201. RECORD   CURRENT RECORD    TARGET RECORD     ACTION TAKEN
  1202.  
  1203.       1   Adam  1000  200   none              write & skip
  1204.       2   Sue   1000  300   Adam  1000  200   add & skip
  1205.       3   Mary  1000  200   Adam  2000  500   write & skip
  1206.       4   Tom   2000  100   Mary  1000  200   write & skip
  1207.       5   Bob   2000  200   Tom   2000  100   add & skip
  1208.       6   Ted   4000  100   Tom   4000  300   add & skip
  1209.       7   Alice 4000  200   Tom   8000  400   write & skip
  1210.     EOF   none              Alice 4000  200   stop
  1211.  
  1212.