This command is used to save records to any file, TAS or non-TAS.
SAVE fn/v | Required - This is the file number/handle where the record will be saved. |
NOCNF | The normal process is for the program to confirm with the user that it is okay to save the record. If you do not want the program to confirm first, include this option in the command line. In that case the program will just save the record without any indication to the user. This is useful when you are saving records to multiple files or when you're saving many records to one or more files. You may also want to use your own confirm process instead of the standard one that is a part of the runtime (see example below) |
NOCLR | Normally, after TAS Professional saves a record, it automatically clears the record and record number buffers. This makes sure that everything is ready to create a new record. However, if you include this option in the command line you will leave both the record buffer and number active. If your desire is to use the data already entered as the default for the next record, you can use the CLR (Clear Record Buffer) command (record option). Make whatever changes are necessary to the data, and when the next SAVE command is executed for this particular file, it will save the data as a new record and not just overwrite the last record saved. |
NOTE: If you are running in a multi-user environment the record will continue to be locked after it is saved. If you clear the record buffer (CLR) then the lock will be released without losing the data in the record.
NOTE: If you are adding or changing records in a CodeBase file and you are looping through the file at the same time, such as updating a group of records in the file, one after another, you MUST use the NOCLR option or you will not find the next record properly.
UNLOCK | If you have included the NOCLR option you can include this one to unlock the record. After the save operation if you have NOCLR the record will still be locked. If you use the CLR command (as described above) that will unlock the record also. However, you may want to have the same record in memory (no changes to buffer or record number) but not locked. In that case use this option. |
NOTE: If you unlock the record and, at a later time, try to save the record again without re-finding it first, you may get an error that the record has been changed by another user, or, even worse, you may overwrite changes made by another user. Make sure you use this option only in situations where you are sure you're not going to want to save the record again.
GOTO label | This is the line you want to transfer control to if the user answers No to the confirm question. If you do not specify a label here the program will continue with the line directly after this SAVE command. |
ERR label | If you specify a label here, the program will transfer control to the appropriate line if an error occurs during the command. If you specify NO_ERR as the label name, then no error will be displayed if one occurs. You can still test for an error after the command using the FLERR() function. |
COMMENTS
A major feature of TAS Professional is the ability to treat non-TAS files as though they were TAS files. This is true here also. If a record is not active for a non-TAS file the program will automatically append it to the end of the file. Also, you can use the FINDV (Find Variable) command to get a record, make changes to it, and save it back to the same location within the file. This is always true with Fixed Length Records, however, in other types (non-TAS) if the record length changes you may end up destroying the integrity of the file.
SEE ALSO
Note: If you are saving a record using a file handle using the openv command your save command needs to have an ampersand '@' here is an example.
Examples
SAVE @bkarinvl_hndl
These are example is if your using to files that share the same schema.
Btreive Example
openv 'myfile1' fnum file1_hndl lock N
openv 'myfile2' fnum file2_hndl lock N
scan @File1_hndl key @0 //read all records using natural order
save @file2_hndl nocnf //save the history
ends
Codebase Example
openv 'myfile1' fnum file1_hndl lock N
openv 'myfile2' fnum file2_hndl lock N
scan @File1_hndl key @0 //read all records using natural order
clr @file2_hndl buff // you need to clr the rec_buff
xfer from file1_hndl to file2_hndl Rec_Buff
save @file2_hndl nocnf noclr//save the history
ends
More on codebase
scan @boxcount_hndl key MACHINE_ID
sloop_if OPENED = .t.
EXCEPTION = .t.
if exnote = ''
EXNOTE = exnote_error
OPENDATE = date()
OPENETIME = time()
USR_CODE = user
endif
save @boxcount_hndl nocnf noclr
//in codebase we have to use the noclr in the save in a scan.
// otherwise the scan looses the record to get the next record..
// and we get a codebase error -910
ends
Page url: http://www.cassoftware.com/tas/manual/saverecord.htm