Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print # Statement Question

Status
Not open for further replies.

denko

Programmer
May 17, 2001
70
0
0
US
Hi there, how can I use Print # statement to create an Output file that is not char delimited. I need every field to start on the certain position like
ABX.DV 2.05 2.25 03/27/03
ABX.GV 2.4 2.6 03/27/03
AYE.SA 0.5 0.75 03/27/03
DDS.QW 4.4 4.7 03/27/03
DUJ.EU 2.55 2.85 03/27/03
FD.TF 3.4 3.6 03/27/03

Thanks
 
You have to format the string to be printed (include appropriate number of spaces to fill up between the columns) and then print the entire line at once.
Greetings,
Rick
 

there is an easier way...(from vb help)
[tt]
Print # Statement

Writes display-formatted data to a sequential file.

Syntax

Print #filenumber, [outputlist]

The Print # statement syntax has these parts:

Part Description
filenumber Required. Any valid file number.
outputlist Optional. Expression or list of expressions to print.

Settings

The outputlist argument settings are:

[{Spc(n) | Tab[(n)]}] [expression] [charpos]

Setting Description
Spc(n) Used to insert space characters in the output, where n is the number of space characters to insert.
Tab(n) Used to position the insertion point to an absolute column number, where n is the column number. Use Tab with no argument to position the insertion point at the beginning of the next print zone.
expression Numeric expressions or string expressions to print.
charpos Specifies the insertion point for the next character. Use a semicolon to position the insertion point immediately after the last character displayed. Use Tab(n) to position the insertion point to an absolute column number. Use Tab with no argument to position the insertion point at the beginning of the next print zone. If charpos is omitted, the next character is printed on the next line.


Remarks

Data written with Print # is usually read from a file with Line Input # or Input.

If you omit outputlist and include only a list separator after filenumber, a blank line is printed to the file. Multiple expressions can be separated with either a space or a semicolon. A space has the same effect as a semicolon.

For Boolean data, either True or False is printed. The True and False keywords are not translated, regardless of the locale.

Date data is written to the file using the standard short date format recognized by your system. When either the date or the time component is missing or zero, only the part provided gets written to the file.

Nothing is written to the file if outputlist data is Empty. However, if outputlist data is Null, Null is written to the file.

For Error data, the output appears as Error errorcode. The Error keyword is not translated regardless of the locale.

All data written to the file using Print # is internationally aware; that is, the data is properly formatted using the appropriate decimal separator.

Because Print # writes an image of the data to the file, you must delimit the data so it prints correctly. If you use Tab with no arguments to move the print position to the next print zone, Print # also writes the spaces between print fields to the file.

Note If, at some future time, you want to read the data from a file using the Input # statement, use the Write # statement instead of the Print # statement to write the data to the file. Using Write # ensures the integrity of each separate data field by properly delimiting it, so it can be read back in using Input #. Using Write # also ensures it can be correctly read in any locale.
[/tt]

so if you wanted to print this...
[tt]
Thisisatest
[/tt]
you would have your print line like
[tt]
Print #FNumb, "This"; "is"; "a"; "test"
'or
'Print #FNumb, "Thisisatest"
[/tt]
But then again that is not really what you want. From my understanding you are wanting an easy way to align colums when you print. So you can do...
[tt]
Print #FNumb, "This", "is", "a", "test"
[/tt]
This will align up each word in a column, or for readability...
[tt]
Me.Print "This"; Tab; "is"; Tab; "a"; Tab; "test"
[/tt]
OR, if you are looking for a littlt more contol you can use the space(n)...
[tt]
Me.Print "This"; Space(5); "is"; Space(5); "a"; Space(5); "test"
[/tt]

and if you are wanting to create a padding function here is an example thread222-487039 that I created a while ago.

Good Luck



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top