"I want to take two columns with data from the same file. Multiply these without overwriting anything and save it. The column names are Sum_psigbf and Sum_psigb3."
Its not hard, but first I need to know where you want the resultant value to go (where to "save it").
Do you want that value put into a Memory variable for subsequent use in an application?
Or do you want that resultant value put into some other field in the table?
Or what?
Regardless, since it looks as though you might want the resultant value in a SQL Query result table, just use very standard SQL Query logic - nothing that is specific to Foxpro.
Maybe something like the following....
Code:
SET SAFETY OFF
CLOSE DATABASES
DELETE FILES *.tmp RECYCLE
SET DEFAULT TO "C:\_moses\Aegon_3097558\MoSes cashflows"
* --- open desired data table ---
USE cf_case ALIAS cf
* --- Run the query on the table ---
* Acquire Field1 (assumption is that this is a Numeric or Integer field)
* Acquire Field2 (assumption is that this is a Numeric or Integer field)
* Acquire Mult result of Field1 * Field2
* ---------------------------------
SELECT Sum_psigbf as psigbf,;
Sum_psigb3 as psigb3,;
(Sum_psigbf * Sum_psigb3) as AM;
FROM cf;
INTO TABLE psigbf.tmp
* -^- Maybe you might want some WHERE selection criteria in the above SQL Query command (or not) -^-
* --- If not you will get ALL records, not just desired one(s) ---
* --- Now select the resultant table (you could have used a memory Cursor instead) ---
SELECT psigbf
* --- Copy it to where you want it ---
COPY TO AM.dbf
* --- Close the resultant table ---
USE
Hopefully that will get you onto the right track.
Alternatively you could have put the result
directly into your COPY table
Code:
SELECT Sum_psigbf as psigbf,;
Sum_psigb3 as psigb3,;
(Sum_psigbf * Sum_psigb3) as AM;
FROM cf;
INTO TABLE AM
I might also recommend that you spend some time going over the free on-line FP/VFP tutorials at:
Free Visual FoxPro Videos
It is targeted for Visual Foxpro (hopefully that's what you are using), but since much of the code is backwards compatible, the ideas will likely apply to whatever you are using.
Good Luck