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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

crlf special characters

Status
Not open for further replies.

boettger

Programmer
Sep 27, 2000
15
US
Hi:
I need a way to write control characters "CRLF" to a flat file. It sounds easy but when I edit the file after
I write the control characters it actually does the "carriage return line feed" so that I get a blank line. I don't want that. The file has to have in position 79 and 80 "CrLf" special characters. Can you help????? I tried the same thing in Oracle and it won't work either.


Thanks
Pat
 
It's hard to give any specific answers without some more details, but I'll give it a shot.
Judging by your question, I'm guessing you have single line records and you need to insert a CrLf into the middle of one. It sounds like you're pulling the records into a database using whatever facilities the database software provides.
The fix depends on how the database reads the file. A CrLf is a CrLf, no matter where it occurs, and if the software is looking for CrLf as a record delimiter, you have a problem. You can probably change the settings for your database connection to use a different record delimiter, but then you'd have to change your file format. Probably a better option would be to see if you can get the database to read records of a fixed length rather than using a delimiter. Of course, this only works if your records are a fixed length, and you'd have to account for that final CrLf. Depending on your situation, it might even be easier to just write your own code to process the text file into the database.
Or maybe I'm completely wrong.
 
Hi:
I have to explain my problem better. I have a flat ascii file that has a file header on it. At the end of the
file header record I need the control characters "CrLf".
This file is then ftped to another system that requires
the control characters at the end of the file header.


FH*003280*xxx.xxx.xxx.x**020102* CrLf

It has to look like the above. Right now I using a program on a Vax machine to do it but I'ds like to be able to do it in VB. Can you help.
 
You could try using this:
Open "Filename" for input as #1 statement

Read each line you need to modify and write it back with the vbCrLf concatenated to the end (or just go ahead and write it to another file directly).

You could probably use the FileSystemObject (part of the scripting runtime) to do much the same thing.

Hope this helps.

O.
 
What are you writing to the file? You have several possibilities:
vbCR Chr(13) Carriage Return
vbCrLf Chr(13) & Carriage Return-linefeed combination
Chr(10
vbLf Chr(10) Linefeed
vbNewLine Chr(13) & Newline character, platform-specific
Chr(10) &
Chr(10)

Maybe you should print the vbCr instead of the vbCrLf?

Herman :-Q
 
Hi:
I tried that. It generates a new file that gives me a blank line in my data file. It does not give me the control characters at the end of the line it executes a "Carriage Return New Line".
 
Has the file header already got some control characters?
If the file has come from a UNIX box or other, it might already have a LF character at the end.

Also, what method are you using to write to the file. some of the VB functions (eg. Print) automatically puts a CRLF at the end of every line it prints to the file, thus

Print FileHnd, "This is a test" & VBcrLf

will print two CRLF's

Hope this helps,

Chris Dukes
 
Another Note,

What are you using to view the output file, If you are using notepad to something like it, two CRLF's will show as a blank line?

Most text editors will not show you the control characters.

If you need to see control chracters, get a text editor that will show you the file in binary/Hex format.

I use Textpad which is a very good text editor.

Chris Dukes
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top