Upgrading to DataFlex 3.2: Difference between revisions

Code
(Indent)
(Code)
Line 402: Line 402:


Creating a new record:
Creating a new record:
<source lang="vdf">
clear NEWFILE
clear NEWFILE
lock
lock
Line 407: Line 409:
     saverecord NEWFILE
     saverecord NEWFILE
unlock
unlock
</source>


Note: In many instances a reread command instead of a lock command will work with a new record. In this case, you MUST use the reread command without any files listed as parameters. If you try to reread a specific file (e.g. reread CUSTOMER) which does not have an active record, you will get an error "status <<25>> record not found". There is a slight penalty (time) for using the reread command without any parameters, which is that all open files with an active record that are not flagged read-only will be reread.
Note: In many instances a reread command instead of a lock command will work with a new record. In this case, you MUST use the reread command without any files listed as parameters. If you try to reread a specific file (e.g. reread CUSTOMER) which does not have an active record, you will get an error "status <<25>> record not found". There is a slight penalty (time) for using the reread command without any parameters, which is that all open files with an active record that are not flagged read-only will be reread.


Editing an existing record:
Editing an existing record:
<source lang="vdf">
reread FILE
reread FILE
     move VAR to FILE.FIELD
     move VAR to FILE.FIELD
     saverecord FILE
     saverecord FILE
unlock
unlock
</source>


Copying data from an existing record in FILE to a new record in NEWFILE:
Copying data from an existing record in FILE to a new record in NEWFILE:
<source lang="vdf">
reread FILE
reread FILE
     move FILE.FIELD to NEWFILE.FIELD
     move FILE.FIELD to NEWFILE.FIELD
     saverecord NEWFILE
     saverecord NEWFILE
unlock
unlock
</source>
Explanation of terms:


* Explanation of terms:
*NEWFILE is a data file where a new record is being created
*FILE is a data file with an existing record
*VAR is a variable in the program code


NEWFILE is a data file where a new record is being created
FILE is a data file with an existing record
VAR is a variable in the program code
Note: There are important differences between the saverecord and save commands. The difference is that the save command attaches related ancestral file (parent, grandparent, etc) information, so that information from the related parent record will overwrite information moved manually into the child record buffer when saving. Saverecord does not do anything at all with related files, it only affects the file(s) listed as parameter(s).
Note: There are important differences between the saverecord and save commands. The difference is that the save command attaches related ancestral file (parent, grandparent, etc) information, so that information from the related parent record will overwrite information moved manually into the child record buffer when saving. Saverecord does not do anything at all with related files, it only affects the file(s) listed as parameter(s).