Hello MVP's Carolx seeking you assistance.
I have been trying to create a cursor dynamically using field values from a single column table without success.
Please see example coding below.
*> Field values in table empfld for this example are Casual, Holiday, Temporary, Permanent
LOCAL aFldnam(1)
nType = RECCOUNT('empfld')
DIMENSION aFldnam(nType+1)
aFldnam(1) = 'Month'
SELECT empfld
GO TOP
FOR cnt = 2 TO nType+1
aFldnam(cnt) = TRIM(desc)
SKIP
ENDFOR
CREATE CURSOR emp FROM ARRAY aFldnam && syntax error here
DISPLAY MEMORY LIKE aFldnam
ALTERNATIVE:
SET TEXTMERGE ON
nType = RECCOUNT('empfld')
cCommand = 'CREATE CURSOR'
cAlias = 'emp'
cString = '<<cCommand>> <<cAlias>>('
SELECT empfld
GO TOP
FOR cnt = 1 TO nType
cField = TRIM(desc)
cString = cString + '<<cField>> c(25))',
SKIP
ENDFOR
cString = SUBSTR(cString,1,LEN(cString)-1)
cExecute = TEXTMERGE(cString)
&cExecute && syntax error here - the columns all have the last field value as heading
*> It works if there is only one value in the table.
I have been trying to create a cursor dynamically using field values from a single column table without success.
Please see example coding below.
*> Field values in table empfld for this example are Casual, Holiday, Temporary, Permanent
LOCAL aFldnam(1)
nType = RECCOUNT('empfld')
DIMENSION aFldnam(nType+1)
aFldnam(1) = 'Month'
SELECT empfld
GO TOP
FOR cnt = 2 TO nType+1
aFldnam(cnt) = TRIM(desc)
SKIP
ENDFOR
CREATE CURSOR emp FROM ARRAY aFldnam && syntax error here
DISPLAY MEMORY LIKE aFldnam
ALTERNATIVE:
SET TEXTMERGE ON
nType = RECCOUNT('empfld')
cCommand = 'CREATE CURSOR'
cAlias = 'emp'
cString = '<<cCommand>> <<cAlias>>('
SELECT empfld
GO TOP
FOR cnt = 1 TO nType
cField = TRIM(desc)
cString = cString + '<<cField>> c(25))',
SKIP
ENDFOR
cString = SUBSTR(cString,1,LEN(cString)-1)
cExecute = TEXTMERGE(cString)
&cExecute && syntax error here - the columns all have the last field value as heading
*> It works if there is only one value in the table.