Hi Garry
> My problem is that Evaluate() is evaluating the fieldname not the
> contents of the fieldname. Replacing Evaluate( lcField) with &lcField
> does not help either.
>
Rather than executing multiple calculate commands, how about this
approach? It will need tweaking when the command gets lengthy.
LPARAMETERS m.tcTable, m.tcResultsCursor
*GetLengths.Prg
*Mike Yearwood
*Create tcResultsCursor containing maximum
*lengths of all character fields in m.tcTable
*Usage: ?GetLengths("Customers.dbf","c_FieldLengths")
*Now do what you will with the cursor c_FieldLengths
IF PCOUNT() # 2 OR VARTYPE(m.tcTable) # "C" OR
VARTYPE(m.tcResultsCursor) # "C" OR EMPTY(m.tcTable) OR
EMPTY(m.tcResultsCursor)
ERROR 11
ENDIF
LOCAL m.lnSelect, m.lcAlias, m.lnFields, m.lcFields, m.llUsed, m.lcCmd
LOCAL ARRAY laFields[1]
m.lnSelect = SELECT()
USE IN SELECT("tblSource")
SELECT 0
USE (m.tcTable) AGAIN ALIAS tblSource
m.lnFields = AFIELDS(laFields)
m.lcFields = ""
FOR m.lnX = 1 TO m.lnFields
IF laFields[m.lnx,2] = "C"
m.lcFields = m.lcFields + "MAX( LEN( RTRIM( " + laFields[m.lnX,1]
+ "))) as " + laFields[m.lnX,1] + ","
ELSE
LOOP
ENDIF
ENDFOR m.lnX
IF LEN(m.lcFields) = 0
CREATE CURSOR (m.tcResultsCursor) (noresults i)
INSERT INTO (m.tcResultsCursor) (noresults) VALUES (0)
ELSE
SET STEP ON
m.lcFields = LEFT(m.lcFields,LEN(m.lcFields) - 1)
SELECT &lcFields. FROM tblSource into cursor (m.tcResultsCursor)
ENDIF
USE IN tblSource
SELECT (m.lnSelect)
RETURN .T.
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
** 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.