* Program...........: GtCreate.prg * Author............: Daniel Gramunt * Created...........: 09.07.2001 17:53:24 * Copyright.........: (c) Nokia, 2001 *) Description.......: Returns a string containing a CREATE CURSOR/TABLE command based *) : on the selected table/cursor. * Calling Samples...: * Parameter List....: * Major change list.: *-------------------------------------------------------------------------------------------------- #DEFINE ccCrLf CHR(13)+CHR(10) #DEFINE ccIndent SPACE(28) IF EMPTY(ALIAS()) WAIT WINDOW NOWAIT "No table open in current workarea." RETURN "" ENDIF LOCAL lnFields, lcRetVal, i, lcFieldName, lcFieldType, lnFieldSize, lnFieldDeci, lcTypeAndLen, lcLineContinuation LOCAL ARRAY laFields[1] lnFields = AFIELDS(laFields) lcRetVal = "CREATE CURSOR <CursorName> (;" + ccCrLf FOR i = 1 TO lnFields lcFieldName = laFields[i, 1] lcFieldType = laFields[i, 2] lnFieldSize = laFields[i, 3] lnFieldDeci = laFields[i, 4] DO CASE CASE lcFieldType $ "DTIYMLG" lcTypeAndLen = lcFieldType CASE lcFieldType = "C" lcTypeAndLen = lcFieldType + "(" + ALLTRIM(STR(lnFieldSize)) + ")" CASE lcFieldType $ "NF" lcTypeAndLen = lcFieldType + "(" + ALLTRIM(STR(lnFieldSize)) + "," + ALLTRIM(STR(lnFieldDeci)) + ")" CASE lcFieldType = "B" lcTypeAndLen = lcFieldType + "(" + ALLTRIM(STR(lnFieldDeci)) + ")" OTHERWISE lcTypeAndLen = "?" ENDCASE lcLineContinuation = IIF(i=lnFields, ";", ",;") lcRetVal = lcRetVal + ccIndent + PADR(lcFieldName, 20) + lcTypeAndLen + PADL(lcLineContinuation , 10-LEN(lcTypeAndLen)) + ccCrLf ENDFOR &&* i = 1 TO lnFields lcRetVal = lcRetVal + ccIndent + ")" RETURN lcRetValHTH