There definitely seems to be a limit of 32 as you say. Summing into an array as per below works for > 32 fields but I don't know if that would help.
#DEFINE _fields 35 #DEFINE _rows 100 Clear =RAND(-1) CREATE CURSOR crsTest (id i) cCalcCmd = [CALCULATE ] cCalcCmd2 = [ SUM ] cCalcCmd3 = "" cTemp = "" cInsertFields = [] cInsertValues = [] cVariables = [] FOR x = 1 TO _fields cField = "Field"+TRANSFORM(x) ALTER table crsTest ADD COLUMN (cField) I cCalcCmd = cCalcCmd + "SUM("+cField+")," cCalcCmd2 = cCalcCmd2 + cField + "," cTemp = cTemp + cField + "," cInsertFields = cInsertFields + ","+cField cInsertValues = cInsertValues + ","+TRANS(INT(RAND()*100)) cVariables = cVariables + "lc"+cField+"," NEXT cInsertCmd = [INSERT INTO crsTest (ID ] + cInsertFields +[) VALUES (0]+cInsertValues+')' FOR X = 1 TO _rows &cInsertCmd Next lcVars = Left(cVariables,Len(cVariables)-1) cCalcCmd = Left(cCalcCmd,Len(cCalcCmd)-1) + " To " + Left(cVariables,Len(cVariables)-1) &&+ "AVG(Field1)" cCalcCmd2 = Left(cCalcCmd2,Len(cCalcCmd2)-1) + " To " + Left(cVariables,Len(cVariables)-1) cTemp = Left(cTemp,Len(cTemp)-1) *? cCalcCmd *? cCalcCmd2 ? cTemp ? lcVars =StrToFile(cCalcCmd + Chr(13) + Chr(13) + cCalcCmd2, "c:\temp\cmd.txt") ? Len(cCalcCmd2) *&cCalcCmd *&cCalcCmd2 Sum &cTemp to array laTots List Memory like laTots Return -- Alan Bourke alanpbourke (at) fastmail (dot) fm On Fri, 22 Nov 2019, at 12:59 PM, Paul Newton wrote: > No Alan - the following code (adapted from Eric) demonstrates exactly > what I am doing: > > #DEFINE _fields 35 > #DEFINE _rows 100 > =RAND(-1) > CREATE CURSOR crsTest (id i) > cCalcCmd = [CALCULATE ] > cInsertFields = [] > cInsertValues = [] > cVariables = [] > FOR x = 1 TO _fields > cField = "Field"+TRANSFORM(x) > ALTER table crsTest ADD COLUMN (cField) I > cCalcCmd = cCalcCmd + "SUM("+cField+")," > cInsertFields = cInsertFields + ","+cField > cInsertValues = cInsertValues + ","+TRANS(INT(RAND()*100)) > cVariables = cVariables + "lc"+cField+"," > NEXT > cInsertCmd = [INSERT INTO crsTest (ID ] + cInsertFields +[) VALUES > (0]+cInsertValues+')' > FOR X = 1 TO _rows > &cInsertCmd > NEXT > cCalcCmd = Left(cCalcCmd,Len(cCalcCmd)-1) + " To " + > Left(cVariables,Len(cVariables)-1) &&+ "AVG(Field1)" > ? cCalcCmd > &cCalcCmd > Return > > Paul > > -----Original Message----- > From: ProfoxTech <profoxtech-boun...@leafe.com> On Behalf Of Alan Bourke > Sent: 22 November 2019 12:55 > To: profoxt...@leafe.com > Subject: Re: Fatal error issuing CALCULATE command > > Sent by an external sender > ------------------------------ > > Paul > > Do you mean you are doing this? > > calculate sum(field1 + field2 + ... + field32) to lnTotal > > > > -- > Alan Bourke > alanpbourke (at) fastmail (dot) fm > [excessive quoting removed by server] _______________________________________________ Post Messages to: ProFox@leafe.com Subscription Maintenance: https://mail.leafe.com/mailman/listinfo/profox OT-free version of this list: https://mail.leafe.com/mailman/listinfo/profoxtech Searchable Archive: https://leafe.com/archives This message: https://leafe.com/archives/byMID/e8f58ea6-4439-4b7a-b523-1a8674dc3...@www.fastmail.com ** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.