PRB: "Command line too long" with BROWSE FIELDSLast reviewed: April 30, 1996Article ID: Q126621 |
The information in this article applies to:
SYMPTOMSThe 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.
CAUSEBy 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.
WORKAROUNDBy 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.
STATUSThis behavior is by design.
MORE INFORMATIONThe 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=1DO WHILE LEN(TARGET(x)) > 0 x=x+1ENDDO 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-1ENDDO 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 bigdataENDFOR sofar=sofar+FCOUNT() ************END CODE
|
Additional reference words: FoxWin FoxDos FoxMac 2.50 2.50a
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |