You can use this command to delete all or a group of records from a TAS Professional file.
DALL file_num | Required - The number/handle of the file to be used. If you do not include this option, the program will look for a default search file set in the SRCH (Search File) command. If that hasn't been previously set, the program will report an error and the command will be skipped. This entry will override any default value set in the SRCH command. |
NOTE: You must enter something here as a place marker, so put '' (double single quotes) for this option if you want to use the SRCH file.
KEY key_expr | Set this to the appropriate value to delete the records in the file in the correct order. If you do not include this option, the program will look for a default key set in the SRCH command. If a default key hasn't been previously set the program will report an error and the command will be skipped. This entry will override any default value set in the SRCH command. |
START f/c/e1,f/c/e2,...,f/c/ex The value to use as the beginning record. This is similar to doing a FINDV (Find Record) before the command. If the index you're searching on has multiple segments you may list the proper value for each segment, separating them with commas. This will allow you to specify the exact type for each of the segments. For example, suppose you're searching on an index that has two segments: a 5 character alpha and an I type field. Each record you want has the same alpha but the I field will change, and is in order. In the first record the I type field has a value of 0. The following would find the first record for that group, if it exists:
start 'ABCDE',0!
Notice that we separate the values with a comma. The only requirement is that the values be of the same type (and size) as the segments in the key. In this case we put the I type constant specifier (!) after the 0 to make sure that it is passed as an I type field.
SCOPE
scope - This option may help determine how many records are deleted. The options are: A (All), F (First), N (Next) and R (Rest). For more information about the scope specifier please see the general information at the beginning of this chapter.
f/c/e - If scope is set to N or F this is the number of records to delete.
An example of this would be:
... SCOPE A... //all records in the file. This is the default scope value.
... SCOPE N 20 ... //the next 20 records in the file
FOR lexpr | You would use this option to restrict the records deleted in this command. If the expression did not resolve to .TRUE. the record would not be deleted. In this option, the search continues until the program reaches the end of file and then will quit. Any legal expression that resolves to .TRUE. or .FALSE. can be used. |
An example of this would be:
... FOR (x=100) .and. (y=200) ...
WHILE lexpr | This option also restricts the records deleted. However, the first time the expression resolves to .FALSE., the program stops deleting records and continues to the next command. Here's the benefit of this option: if the program is deleting records in a certain order (by a specific key) and the expression returns .FALSE. then the program knows that all the appropriate records have been deleted and there is no need to continue. For example: You want to delete all the invoice records for a specific customer. The first record for that customer is found in the invoice file either by using the start_value option within this command, or through the FINDV (Find Record) command before executing this command. Then the WHILE expression would be: |
INV_CUST_CODE = CUSTOMER_CODE
(This assumes that there is a field called INV_CUST_CODE in the invoice file and a like field in the customer file called CUSTOMER_CODE. The KEY option must be set to the proper value so that the records are deleted in CUSTOMER_CODE order, or you must have set the SRCH command previous to this command.) When the first invoice record for the next customer is read the program will stop deleting records.
NOTE: If there is no START value you must set the scope value to R or N xxx. If you do not do this, the program will find the first record in the file and the WHILE expression will probably fail the first time. However, if the START option is used you can ignore this requirement.
CNTR fn/v | This is an I type field that will be used for passing the number of records deleted. |
DISP | Each time a record is read the program will redisplay the screen fields, if you specify this option. This will slow down the operation of this command, depending on how many fields are displayed on the screen. |
COMMENTS
If the WHILE option is used you must watch out for the proper setting of the SCOPE, and/or START options also. If everything is supposedly set properly and yet no records are being deleted, make sure that the proper first record is in memory prior to the execution of this command or that correct use has been made of the START option. If a record is not active when this command is executed nothing will be deleted. You can use the START option instead of a FINDV (Find Record) to make sure that a record is active.
NOTE: You can delete records from a Pervasive (Btrieve) or CodeBase file only. NON TAS data is not allowed.
EXAMPLE
DALL @bkarcust_hndl key @0 for ChkFilter()
// The above will delete all records from the bkarcust_hndl where the bkar.custcode is blank
// or nul in Natural Order. The chk filter also updates the progress bar on my screen.
func ChkFilter
'@pbRecCount.Position' = RecCntr // This updates my progress bar
if bkar.custcode = ''
RET .t.
else
RET .f.
SEE ALSO
Page url: http://www.cassoftware.com/tas/manual/deleteallrecords.htm