It's doable, but very likely isn't the best approach here. Can you spell out what you are trying to do in much more detail?
I have a file called BillTrans and I want to append all the records to a file called YTDBillTrans.
The files contain identical fieldnames, regular, calculated and summary fields. The YTDBillTrans has an extra ID field.
On a button click I want to append the BillTrans records to the YTDBillTrans file and then delete them from the BillTrans file.
Why? (What problem are you solving by having two tables like this instead of keeping everything in the same file?)
The billtrans file produces a bill report. It uses complicated calculations in many fields. There is up to a couple of thousand tranctions a month on the bill for one company and, over time, the file could hold hundreds of companies. The speed of the report was my reason for having a file with one months transactions only.
If speed is not an issue then I don't have a problem with this instance.
I would, however, like to know how to run through a record and copy each field to another file. It was quite simple in other languages. A field list was basically all you needed.
It was hard for me (in fm) to discover how, with a field name I could go to a file and get the fields contents, since the "go to field" command only allows you to choose a field name, not supply one. You mentioned it was doable, how is it done?
In general, are there any snippets of script around in the community where you can look for this kind of thing?
You should be able to do this with import records. If your field names in both tables are identical, you can use the matching names option to avoid a known issue that can make imports dangerous when the field names don't match. (Adding a new field to a source table, adds it to your scripted import order in an arbitrary fashion.)
Field by field can be done. The details depend on your relationships. If you've linked the two tables by a unique ID and allow creation of related records for this relationship, you can simply use set field or even set field by name to move data from one table to another. If there is no relation defined, you have to move the data to variables and then move them from variables to the fields in the other table--which is a lot more scripting.
If you have the relationship, an outline of your script would look like this:
Go to a layout where you've placed every field from which you want to move data (needed for the fieldnames function)
Find all the records from which you want to move data
Go to the first record
Use set variable and the FieldNames function to load a variable with a list of all your field names
Initialize loop variable
Step through the field names in the list and use Set Field by name and getField to correctly reference the matching fields in each table.
Exit loop after the last field has been referenced
go to next record, exit after last
I appreciate your time. Having someone to ask when the options peter out is so valuable.