Microsoft KB Archive/126621

{| = PRB: "Command line too long" with BROWSE FIELDS =
 * width="100%"|

ID: Q126621

2.5x 2.60 2.60a | 2.5x 2.60 2.60a | 2.5x 2.60a | 2.60

WINDOWS        | MS-DOS          | MACINTOSH  | UNIX kbprb The information in this article applies to:
 * Microsoft FoxPro for Windows, versions 2.5, 2.5a, 2.5b, 2.6, 2.6a
 * Microsoft FoxPro for MS-DOS, versions 2.5, 2.5a, 2.5b, 2.6, 2.6a
 * Microsoft FoxPro for Macintosh, versions 2.5b, 2.5c, 2.6a

SYMPTOMS
The error "Command line too long" occurs when a BROWSE FIELDS command has a large number of fields, long field names, field headers, and other options.

CAUSE
By adding a large number of fields, long field names, field headers, and other options, you may easily reach the maximum command line length, the maximum compiled line length, or both.

WORKAROUND
By using named expressions stored in an array created for this purpose, you may be able to have 15 to 20 percent more fields listed in the BROWSE command in the same amount of space.

STATUS
This behavior is by design.

MORE INFORMATION
The following code automatically creates a program file that stores field names to an array and references that array in a BROWSE FIELDS command based on the currently selected database. This may help to create a BROWSE command that is short enough to compile.


 * BEGIN CODE * Create a BROWSE command referencing array elements instead of * actual field names to shorten the BROWSE command line. * Can be used on databases with parent->child->grandchild * relationships or parent to multiple child with no grandchild. outfile=FCREATE("big_brow.prg") IF outfile > 0

fname="" new_way="" sofar=0 bigdata="" DO recurs * Write the command line to dimension the 'MYFIELDS' array * to the output file. FPUTS always adds CR/LF. a0=FPUTS(outfile,[Dime mf(]+ALLTRIM(STR(sofar))+[,2)]) * Populate the array. CR/LF already in data. a0=a0+FWRITE(outfile,bigdata) * The fname variable contains the string you would * use if you issued a standard BROWSE FIELDS command * with field names, column headings, and so on. * It is created solely for the purpose of comparing * size. a1=LEN([BROWSE FIELDS ]+fname) * Write the actual string composing the new BROWSE * FIELDS statement. The third parameter to FWRITE is  * the number of bytes to write; as the last character * in the string is a comma, you don't want it at the end * of the BROWSE command, so write 1 character less. a2=FWRITE(outfile,"BROWSE FIELDS " + new_way, ;     LEN("BROWSE FIELDS " + new_way)-1) * However, you do want a CR/LF at the end: a0=a0+FWRITE(outfile,CHR(13)+CHR(10)) * Done with the file. =FCLOSE(outfile) * Display the file. MODIFY COMM big_brow.prg NOWA WAIT WINDOW [New way (]+ALLTRIM(STR(a2))+[ chars) is ] + ; ALLTRIM(STR(INT((a2/a1)*100))) + ; [% of the old way (]+ALLTRIM(STR(a1))+[ chars).]+CHR(13) + ; [The commands to browse the current table]+CHR(13) + ; [and any related tables are stored to BIG_BROW.PRG]+CHR(13) + ; [PRESS ANY KEY TO CONTINUE] ENDIF PROCEDURE recurs

DO myloop  && process fields in this database x=1 DO WHILE LEN(TARGET(x)) > 0 x=x+1 ENDDO DO WHILE x > 0 IF LEN(TARGET(x)) > 0 WAIT WINDOW [Now looking in ]+TARGET(x) TIMEOUT 2 * go to the target wasat=SELECT SELECT (TARGET(x)) IF LEN(TARGET(x)) > 0 DO recurs ELSE DO myloop  && process fields in current database ENDIF SELECT (wasat) ENDIF x=x-1 ENDDO PROCEDURE myloop FOR fnum=1 TO FCOUNT

fname = fname + ALIAS+[.]+FIELD(fnum)+[:H=']+FIELD(fnum)+[':9,] my_fld_name = FIELD(fnum) my_fld_type = TYPE(my_fld_name) DO CASE CASE INLIST(my_fld_type,"G","M","L") my_fld_contents = " " my_fld_len     = 5   && arbitrary value CASE my_fld_type=="D" my_fld_contents = DTOC(EVALUATE(my_fld_name)) my_fld_len     = 8   && arbitrary value CASE my_fld_type=="N" my_fld_contents = ALLTRIM(STR(EVALUATE(my_fld_name),12,2)) my_fld_len     = 7   && arbitrary value CASE my_fld_type=="C" *  OTHERWISE my_fld_contents = EVALUATE(my_fld_name) my_fld_len     = IIF(LEN(my_fld_contents)<10,LEN(my_fld_contents),9) ENDCASE new_way=new_way+[(mf(]+ALLTRIM(STR(fnum+sofar))+[,1)):H=mf(]+ ;     ALLTRIM(STR(fnum+sofar))+[,2):]+ ; ALLTRIM(STR(my_fld_len)) + [,] STORE bigdata+[store "]+ALIAS+[.]+FIELD(fnum)+[" to mf(]+;     ALLTRIM(STR(fnum+sofar))+[,1)]+CHR(13)+CHR(10) TO bigdata STORE bigdata+[store "]+FIELD(fnum)+[" to mf(]+;     ALLTRIM(STR(fnum+sofar))+[,2)]+CHR(13)+CHR(10) TO bigdata ENDFOR sofar=sofar+FCOUNT
 * END CODE

Additional reference words: FoxWin FoxDos FoxMac 2.50 2.50a 2.50b 2.50c 2.60 2.60a errmsg err msg

KBCategory:  kbprb KBSubcategory: FxprgBrowse Keywords         : kbcode kberrmsg FxprgBrowse Version          : 2.5x 2.60 2.60a | 2.5x 2.60 2.60 Platform         : MACINTOSH MS-DOS UNIX WINDOWS
 * }