我有一个循环遍历单个列“contract”的赋值,并且对于每个循环,使用契约中的值调用程序“MyProgram”。最后将结果显示在所有循环的表中。
Indata:
=================
Contracts.dbf
=================
P01
C04
CH45
T31
Result:
===========================
ResultFile.dbf
===========================
P01 C04 CH45 T31
---------------------------
100 11 302 -872
9.63 0 45.2 342
每个合约的价值都是在MyProgram中生成的,它以契约作为参数,并生成一个与title相同的结果列。因此,使用MyProgram进行合同P01给出
======
P01
------
100
9.63
到目前为止,我的程序看起来像是
SELECT distinct contract FROM bs_case
COPY TO contracts.dbf
NbContracts =RECCOUNT()
CLOSE TABLES
counter = 1
DO WHILE counter < NbContracts
&& calling MyProgram ()
counter = counter + 1
ENDDO
我无法从“Contracts.dbf”中提取合约名称,也不知道如何创建最终结果文件“ResultFile.dbf”
答案 0 :(得分:0)
试试这个,它是伪的,但应该有效:
******
SELECT 0
CREATE CURSOR MyResults ( columnName C(10), value1 I, value2 N(8,2) ) &&Result cursor
SELECT contracts
LOCATE &&Go to top of file.
SCAN &&start loop
=MyProgram(FIELD(1), contracts.ColumnName) &&Pass name of column and it's value
ENDSCAN
SELECT MyResults &&View results.
BROWSE LAST NORMAL
PROCEDURE MyProgram(fieldname, value1)
***Do stuff to
***generate calculatedvalue1 and calculatedvalue2
***Insert name of column, value1 and value2
INSERT INTO MyResults (columnName, value1, value2) ;
VALUES(fieldname, calculatedvalue1, calculatedvalue2)
END PROC