* start of SQLUDF.PRG * * This program selects records from the input table and calculates a * running total + 0 in the output table by using a UDF. CLEAR CREATE CURSOR SQLUDF ( nField1 N(10,0) ) INSERT INTO SQLUDF VALUES ( 10 ) nRunningTot = 0 && initialize running total to 0 nIterations = 0 && initialize iteration counter to 0 SELECT *, Add_Em(nField1)+ 0 as nRunTotal FROM SQLUDF INTO CURSOR temp BROWSE NOWAIT PROCEDURE Add_Em PARAMETERS tnFld1 nIterations = nIterations + 1 && Increment iteration counter ? "Record Number: "+ALLTRIM(STR(RECNO())) + ; CHR(13)+ "Number of Iterations: "+ALLTRIM(STR(nIterations)) nRunningTot=nRunningTot + tnFld1 && Calculate running total RETURN nRunningTot END PROCEDURE *End of SQLUDF.PRG