dbTalk Databases Forums  

Difficulty w/ EOF character chr(26)

comp.database.ms-access comp.database.ms-access


Discuss Difficulty w/ EOF character chr(26) in the comp.database.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Mike Turco
 
Posts: n/a

Default Difficulty w/ EOF character chr(26) - 10-22-2004 , 11:44 AM









I have a bunch of text files I'm trying to parse. The files all have several
occurrences of chr(26), which is EOF (End Of File). Each file is ~ 1meg of
text, and every file is a real mess. The looks something like this:

Date=1/1/04-=time4:20pmSalesperson-=-)JIM HENDERSON$%L_#*(%-+*
da_FIRST.........------MIKE
da_LAST .........------TURCO
da_PRODUCT.....------BOAT
da_YY...........------04
)(#$%^&*

Date=1/1/04-=time4:20pmSalesperson-=-)JIM HENDERSON$%L_#*(%-+*--=
da_FIRST.........------JAMES
da_LAST .........------THAMES
da_PRODUCT.....------RV
da_YY...........------02
)(#$%^&*


Note that this is pseudo data (for simplicity) and also that I am using the
* character to represent the EOF character. Also, if I do a manual
search-and-replace for the EOF character, my code works perfectly. What is
happening, for sure, is that Access Basic is seeing the EOF character and
interpreting it as an actual end of file. Here is a code snippet:

Do While Not EOF(FileNo)
Input #FileNo, g$
Select Case left(g$, 4)
Case "da_F"
.AddNew
If Len(g$) > 53 Then
![RO CLOSE] = Right(g$, Len(g$) - 53)
End If
Case "da_L"
If Len(g$) > 53 Then
![RO-NUMBER] = Right(g$, Len(g$) - 53)
End If


So, the problem I have is how to either ignore or get rid of this EOF
character. I've tried Line Input, Input # and Input functions. In every
case, when I hit the EOF char, Access thinks it is the end of the file. If
you have any suggestions, I'd appreciate it.

Here's another issue, which I guess is a little OT because its a windows
problem, but it still relates to this database. Doing a search-and-replace
for this EOF character in notepad is (marginally) acceptable for now. On
some XP computers, using notepad, I see this EOF character as a right facing
arrow and its easy to find, search out and replace. On other computers,
control characters are displayed as a box. I don't think its a Unicode
problem because I'm able to see all of the higher characters on the screen.
Its just the lower (control) characters that display on some computers and
not on others. FWIW, I have tried different fonts on the different
computers. Both fixedsys and courier fonts display the character correctly
on my computer, but as boxes on other computers. Is there a control panel
setting somewhere, or something, that turns the display of control
characters on or off?

I'm using AccessXP.

Thanks!

Mike








Reply With Quote
  #2  
Old   
Ira Solomon
 
Posts: n/a

Default Re: Difficulty w/ EOF character chr(26) - 10-22-2004 , 03:09 PM






Mike:

This will work:
Public Function TEOF()

Dim rline, newline As String
Dim eof As String
Dim fs, r
Set fs = CreateObject("Scripting.FileSystemObject")
Set r = fs.OpenTextFile("d:\alexdata\eof.txt", 1, 0)
eof = Chr(26)
Do While r.AtEndOfStream <> True
rline = r.readline
Debug.Print rline
newline = Replace(rline, eof, "")
Debug.Print newline
eloop:
Loop
endit:
r.Close
End Function

In this case all eof chars in the input line are removed and not
replaced by anthything. You could replace with a space or anything
else.

This uses the FileSystemObject. It is in some ways more powerful than
the older method.

Good Luck

Ira Solomon

On Fri, 22 Oct 2004 09:44:04 -0700, "Mike Turco"
<miketurco (AT) yahoo-nospam4me (DOT) com> wrote:

Quote:


I have a bunch of text files I'm trying to parse. The files all have several
occurrences of chr(26), which is EOF (End Of File). Each file is ~ 1meg of
text, and every file is a real mess. The looks something like this:

Date=1/1/04-=time4:20pmSalesperson-=-)JIM HENDERSON$%L_#*(%-+*
da_FIRST.........------MIKE
da_LAST .........------TURCO
da_PRODUCT.....------BOAT
da_YY...........------04
)(#$%^&*

Date=1/1/04-=time4:20pmSalesperson-=-)JIM HENDERSON$%L_#*(%-+*--=
da_FIRST.........------JAMES
da_LAST .........------THAMES
da_PRODUCT.....------RV
da_YY...........------02
)(#$%^&*


Note that this is pseudo data (for simplicity) and also that I am using the
* character to represent the EOF character. Also, if I do a manual
search-and-replace for the EOF character, my code works perfectly. What is
happening, for sure, is that Access Basic is seeing the EOF character and
interpreting it as an actual end of file. Here is a code snippet:

Do While Not EOF(FileNo)
Input #FileNo, g$
Select Case left(g$, 4)
Case "da_F"
.AddNew
If Len(g$) > 53 Then
![RO CLOSE] = Right(g$, Len(g$) - 53)
End If
Case "da_L"
If Len(g$) > 53 Then
![RO-NUMBER] = Right(g$, Len(g$) - 53)
End If


So, the problem I have is how to either ignore or get rid of this EOF
character. I've tried Line Input, Input # and Input functions. In every
case, when I hit the EOF char, Access thinks it is the end of the file. If
you have any suggestions, I'd appreciate it.

Here's another issue, which I guess is a little OT because its a windows
problem, but it still relates to this database. Doing a search-and-replace
for this EOF character in notepad is (marginally) acceptable for now. On
some XP computers, using notepad, I see this EOF character as a right facing
arrow and its easy to find, search out and replace. On other computers,
control characters are displayed as a box. I don't think its a Unicode
problem because I'm able to see all of the higher characters on the screen.
Its just the lower (control) characters that display on some computers and
not on others. FWIW, I have tried different fonts on the different
computers. Both fixedsys and courier fonts display the character correctly
on my computer, but as boxes on other computers. Is there a control panel
setting somewhere, or something, that turns the display of control
characters on or off?

I'm using AccessXP.

Thanks!

Mike








Reply With Quote
  #3  
Old   
Mike Turco
 
Posts: n/a

Default Re: Difficulty w/ EOF character chr(26) - 10-22-2004 , 03:26 PM




"Ira Solomon" <isolomon (AT) solomonltd (DOT) com> wrote

Quote:
Mike:

This will work:
Public Function TEOF()

Dim rline, newline As String
Dim eof As String
Dim fs, r
Set fs = CreateObject("Scripting.FileSystemObject")
Set r = fs.OpenTextFile("d:\alexdata\eof.txt", 1, 0)
eof = Chr(26)
Do While r.AtEndOfStream <> True
rline = r.readline
Debug.Print rline
newline = Replace(rline, eof, "")
Debug.Print newline
eloop:
Loop
endit:
r.Close
End Function

In this case all eof chars in the input line are removed and not
replaced by anthything. You could replace with a space or anything
else.

This uses the FileSystemObject. It is in some ways more powerful than
the older method.

Good Luck

Ira Solomon
Thanks & goot Shabbos.

Mike




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.