Writing a tab to a file

S

Simon Wigzell

I'm using the following to write a file :

filename = server.mappath(session("Directory") & "/Text/" &
ExportFileName)
Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject")
Set MyFile = ScriptObject.OpenTextFile(filename,2,true)
Myfile.writeline exportString
MyFile.Close

I'm putting tabs in the exportString the C way e.g. "\t" but they come out
in the text file literally. How does one write a tab to a file with asp? (I
don't want an HTML tab!) Thanks
 
D

Dave Anderson

TJS said:
if using vbscript then use "vbtab"

Or continue using "\t" and switch to JScript.


--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
 
P

Phillip Windell

You are writing a Text File. There is no such thing as a "Tab" in a
text file. Applications like Notepad "fake it" by inserting a series
of spaces (I think 5). I believe, at a minimum, you have to use an
RTF file to have "Tabs".


--

Phillip Windell [CCNA, MVP, MCP]
(e-mail address removed)
WAND-TV (ABC Affiliate)
www.wandtv.com
 
R

Ray at

What's chr(9) then?

Ray at work

Phillip Windell said:
You are writing a Text File. There is no such thing as a "Tab" in a
text file. Applications like Notepad "fake it" by inserting a series
of spaces (I think 5). I believe, at a minimum, you have to use an
RTF file to have "Tabs".


--

Phillip Windell [CCNA, MVP, MCP]
(e-mail address removed)
WAND-TV (ABC Affiliate)
www.wandtv.com

Simon Wigzell said:
I'm using the following to write a file :

filename = server.mappath(session("Directory") & "/Text/" &
ExportFileName)
Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject")
Set MyFile = ScriptObject.OpenTextFile(filename,2,true)
Myfile.writeline exportString
MyFile.Close

I'm putting tabs in the exportString the C way e.g. "\t" but they come out
in the text file literally. How does one write a tab to a file with asp? (I
don't want an HTML tab!) Thanks
 
P

Phillip Windell

Ray at said:
What's chr(9) then?

Ok, I guess I must have been confusing it with some other "element".
Next you're not gonna tell me that you can have bold, italic, and
underline in a text file are you? I must have had the "tab" tossed in
the same bucket as those and thought that text files had only Spaces,
CRs and LFs.

So what is the solution to his problem?...just replace the "/t" with
chr(9)? I'm was pretty sure using the / as an escape character with
"t" is the way a Tab is done in RTF.

--
Dammit Jim! I'm a Network Guy, not a blasted Programmer!
But Bones! We're paying you 5 bucks and hour to do both!

Phillip Windell [CCNA, MVP, MCP]
(e-mail address removed)
WAND-TV (ABC Affiliate)
www.wandtv.com
 
R

Ray at

Actually, had I gotten to speak my question instead of typing it, the tone
inflection would have indicated that I wasn't sure if CHR(9) was a tab or
not. ;] No attack!

Your job sounds like mine! Except I'm a programmer who has to support the
network services department all the time.

Ray at work

Phillip Windell said:
Ray at said:
What's chr(9) then?

Ok, I guess I must have been confusing it with some other "element".
Next you're not gonna tell me that you can have bold, italic, and
underline in a text file are you? I must have had the "tab" tossed in
the same bucket as those and thought that text files had only Spaces,
CRs and LFs.

So what is the solution to his problem?...just replace the "/t" with
chr(9)? I'm was pretty sure using the / as an escape character with
"t" is the way a Tab is done in RTF.

--
Dammit Jim! I'm a Network Guy, not a blasted Programmer!
But Bones! We're paying you 5 bucks and hour to do both!

Phillip Windell [CCNA, MVP, MCP]
(e-mail address removed)
WAND-TV (ABC Affiliate)
www.wandtv.com
 
G

Guinness Mann

"Ray at <% said:
I wasn't sure if CHR(9) was a tab or not.

Yes, CHR(9) is a tab. The fellow (Dave) that suggested vbTab was
correct, though. You can use CHR(9), but it requires a function call
every time the ASP dll encounters it. vbTab is a constant.

FWIW, there is also vbCrLf, vbCr, vbLf, vbNewLine ( = vbCrLf),
vbNullChar ( = 0), vbNullString, vbBack (backspace), and finally, (but
not useful in Windows) vbFormFeed and vbVerticalTab.

-- Rick
 
M

Mark Schupp

Phillip Windell said:
You are writing a Text File. There is no such thing as a "Tab" in a
text file. Applications like Notepad "fake it" by inserting a series
of spaces (I think 5). I believe, at a minimum, you have to use an
RTF file to have "Tabs".

Not true. A tab character can be inserted in a text file. Try this:

run notepad
hit the tab key
save the file
look at the file's properties and you will see it contains 1 byte, not 8.

To put a tab in with VBScript you have to concatenate the vbTab character
with the remainder of the string. For example:

strLineToWrite = "first tab here:" & vbTab & "second tab here:" & vbTab &
"rest of line"

Then it can be output with

Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject")
Set MyFile = ScriptObject.OpenTextFile(filename,2,true)
Myfile.writeline strLineToWrite
MyFile.Close
 
H

Harag

vbFormFeed is useful in a file - if the file is intended to be printed
out at sometime. eg a reports file

Al.
 
P

Phillip Windell

Ray at said:
Actually, had I gotten to speak my question instead of typing it, the tone
inflection would have indicated that I wasn't sure if CHR(9) was a tab or
not. ;] No attack!

Aw! No problem at all! I'm just getting frustrated at my little
"stumbles" lately, many of which I know better if I just stop and
think about it a little longer before I post..
Your job sounds like mine! Except I'm a programmer who has to support the
network services department all the time.

It must be common. One of our major Vendor's Tech Support referes to
the area where there developers work as "Network Support" so I guess
they roll them all into one and lock them all in one room together.

--

Phillip Windell [CCNA, MVP, MCP]
(e-mail address removed)
WAND-TV (ABC Affiliate)
www.wandtv.com
 
P

Phillip Windell

Yea, I went and tried that even before I saw your post,...sorry folks,
this week hasn't been good for "accuarcy" with me for some reason.


--

Phillip Windell [CCNA, MVP, MCP]
(e-mail address removed)
WAND-TV (ABC Affiliate)
www.wandtv.com
 
B

Bob Barrows

Don't worry about it. We all have those days. I've committed some doozies
myself .... no, you don't need to go googling to find them, thank you. :)
Just take my word for it. :)

Bob Barrows
 
H

Harag

Doh, I know a file is not windows... I was just pointing out to the OP
what the VBformfeed is usefull for.

Al.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top