Microsoft KB Archive/137316

= PRB: SET ALTERNATE Adds Extra Spaces to the End of Each Line =

Article ID: 137316

Article Last Modified on 2/12/2000

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition

-



This article was previously published under Q137316



SYMPTOMS
Using the SET ALTERNATE command to output to a text file can produce a result that contains extra spaces on the end of each line.



RESOLUTION
If you don't want to see the information scroll on the screen while the text file is being created, use this command: SET CONSOLE OFF If you want to see the information scroll on the screen, set the _Screen.Fontname property to a non-proportional (mono-spaced) font, such as Courier.

By calling the SET CONSOLE OFF or setting the FontName property to a non- proportional font, you can prevent the extra spaces from appearing in the text file.



STATUS
This behavior is by design.



Steps to Reproduce Behavior
The following example uses the Customer table in the Vfp\Samples\Data directory.

  Create a program containing this code: CLOSE ALL SET SAFETY OFF SET CONSOLE ON  USE C:\VFP\SAMPLES\DATA\customer.dbf SET ALTERNATE TO test SET ALTERNATE ON  GOTO TOP DO WHILE !EOF ? ALLTRIM(cust_id)+" "+ALLTRIM(company)+" "+ALLTRIM(contact) SKIP ENDDO SET ALTERNATE OFF CLOSE ALTERNATE CLOSE DATABASES SET SAFETY ON                         Ensure that the _SCREEN.FontName property is set to Arial (or any other proportional font). This can be done using this command: _SCREEN.FontName="Arial"  Run the program. After running the program, open the Test.txt file and place the insertion point to determine that there are extra spaces added to the end of each line.

Steps to Avoid Behavior
 To resolve the problem and display the text file on the screen as it is created:

  Add the following two lines of code to the top of the program: oldfont=_SCREEN.FontName         && This establishes the name _SCREEN.FontName="Courier"       && of the current font and then && sets the font to Courier. </li>  Add the following line of code to the bottom of the program: _SCREEN.FontName=oldfont         && This sets the font back to                                        && the original setting. </li> Run the program, and open the Test.txt file. Note that no extra blanks have been added to the end of each line.</li></ol> </li> To resolve the problem without displaying the text file on the screen as it is created:

 Change the SET CONSOLE ON line in the program to SET CONSOLE OFF.</li> Run the program. Now you will not see the Test.txt file scroll on the screen as it is being created. After the program completes, open the "text.txt" file. Note that no extra blanks have been added to the end of each line.</li></ol> </li></ol>

Additional query words: VFoxWin

Keywords: KB137316

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.