This command is used to move data from one field to another without regard to the type of the data, array elements, etc. This is a quick and easy way to move large array fields to holders or back.
XFER
FROM fn/v | Required - The From field. This can be any field or pointer, including array element specifier. |
TO fn/v | Required - The To field. This can be any field or pointer, including array element specifier. |
NCHR f/c/e | Required - The number of characters/bytes to move. |
REC_BUFF | If you specify this option the command will use the FROM value as the from file handle and the TO value as the to file handle. You don't need to specify the NCHR value since the program will check the size of the record and use that automatically. NOTE: This only works with CodeBase records. |
COMMENTS
This is a very powerful command that will allow you to move large array fields or group of fields with a single command. However, it's your responsibility to make sure that the number of characters/bytes moved does not extend past the from or to fields.
VERY IMPORTANT: The data structure of a Btrieve record is siginificantly different than that of a CodeBase record. If you are used to programming with Btrieve files it is recommended that you DO NOT use this command when moving a large group of data from/to a CodeBase file field, or group of fields. The field sizes and the way they are stored, may be completely different than that in a Btrieve file. You are better off using a different method when dealing with CodeBase file fields. You can, however, use the REC_BUFF option to move the entire record from one CodeBase file to another when they both have the same FD. It's up to you to make sure this is true. The command will not check.
Example Using xfr in codebase where we have two files sharing same schema and rec_buf
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 // This has to be on the loop
xfer from file1_hndl to file2_hndl Rec_Buff
save @file2_hndl nocnf //save the history
ends
EXAMPLE
(*
The following code is used in the WTASDMGR. It is used
when the key information is loaded from the disk and
prepared to be displayed in the appropriate grid.
The first part of the source shows the records being
read and moved from individual array elements and
moved to a holder than can handle all the segments
for a single key.
*)
for(cntr;1;24;1)
fexit_if Key_name[cntr]=''
if Key_name[cntr]<>akey_name[dict_key_actv] then AddKey = True
if AddKey
if dict_key_actv<>0
//we need to move the individual segments into the holder
xfer from seg_fld_name[1] to seg_fld_hldr[dict_key_actv] nchr 360
updta seg_fld_name clr
endif
inc dict_key_actv
akey_name[dict_key_actv] = Key_name[cntr]
akey_order[dict_key_actv] = iif(Key_order[cntr]='A','Ascending','Descending')
akey_dups[dict_key_actv] = Key_dups[cntr]
akey_mods[dict_key_actv] = Key_modifiable[cntr]
key_cntr=1
endif
AddKey = False
seg_fld_name[key_cntr]=Key_field[cntr]
inc key_cntr
next
//setup the field names for key 1
if dict_key_actv<>0 then
xfer from seg_fld_name[1] to seg_fld_hldr[dict_key_actv] nchr 360
(*
The second part moves the key segments from the holder back into
the appropriate array when it's needed.
*)
dgKeySpec.Move:
if GridsActive then wlistm 'dgKeySegment' close
dict_knum_actv=0
updta seg_fld_name clr
xfer from seg_fld_hldr[key_grid_cntr] to seg_fld_name[1] nchr 360
for(cntr;1;24;1)
fexit_if seg_fld_name[cntr]=''
inc dict_knum_actv
next
wlistm 'dgKeySegment' active_elements dict_knum_actv max_elements 24 \
counter_fld knum_grid_cntr setup
ret
Page url: http://www.cassoftware.com/tas/manual/movedata.htm