Bob_Hansen wrote on May 12
th, 2010 at 4:03pm:
Why does @LoadExportSpec("COPY TO Q&A") not load when a Result Set exists? I don't think a form needs to be opened for that, it is not a SpecCommand
SpecCommand is a replacement for all the individual commands that operate on different kinds of specs. Specs are always attached to Forms, not to ResultSets. Specs are client-side tools and need a Form.
Quote:If I need to export from a ResultSet you are saying I must do something like Open a File Handle, Start the loop, and for each record, Write the value of 25+ fields, one programming line for each field, one at a time to the file with delimiters, then close the file?
Yes. You probably already have a number of examples of this, since you are likely doing something similar when you automate mailmerges and suchlike.
Quote:I cannot use a Saved Export Spec? If I want to Add/Delete a field value, I need to change the hard code vs. changing the content of a Saved Export Spec? That does not sound correct.
No, you just can't use a saved export spec to operate on an XResultSet in code. Specs operate on Forms.
Quote:Please tell me I am missing something.
OK, you're missing something.
Quote:There must be a way to loop through the 25+ fields of the ExportSpec, in the Spec order, to write them out so I do not need to hard code the field names to write them out. I seem to recall a command that detailed some specs, but I can't seem to locate it.
@SpecCommand can do this with the SPEC_OPERATION_VIEW operation.
Quote:A sample would be appreciated.
OK. I went into Customers, chose Set All on the Export Spec, saved it as EMF Test, and ran the following Mass Update to get the list of fields.
#include "sbasic_include.sbas"
var vSpec as String
vSpec = @SpecCommand(SPEC_OPERATION_VIEW, SPEC_TYPE_EXPORT, "EMF Test")
vSpec = @Replace(vSpec, "=Open0", "")
WriteLn(vSpec)
The following appeared in the WriteLn window:
KEY;Active;First;MI;Last;Company;Add1;Add2;City;State;ZIP;Phone;Email;Position;Interests;Numerical;Credit_Limit;Date_Entered;Time_Field
Edited: Also: Be aware that your Export Spec uses element names and the XResultSet uses field names. Using the Export Spec this way won't work as is if they don't match. You'd have to add another loop that translates the element names to their bound field names.