?
Solved

64k string size limitation

Posted on 1998-09-23
10
Medium Priority
?
221 Views
Last Modified: 2012-08-13
I am using VB 6

I have a log file (text format) that I am parsing. Here are the steps I am using:

1. Open the text file
2. Start the loop
3. Read the 1st line, and extract the needed info
4. Write the extracted data to a new file
5. Loop again until EOF

The program starts, and then errors. It looks like its a limitation of the 64K string size. If I go into the text file, and make it a 10-20 lines in length, it works fine.

The file I am extracting the info out of is 624K and will grow daily.

How can I overcome this limitation?
0
Comment
Question by:purphaze
10 Comments
 

Author Comment

by:purphaze
ID: 1436249
Edited text of question
0
 
LVL 2

Expert Comment

by:dabellei
ID: 1436250
   Open "file.txt" For Input As #1
   
    Do While Not EOF(nfic)
        Line Input #nfic, texte_share
        Rem  texte_share is a variable wich contain the text for the current line
    Loop
    Close #1



This should work even for big file.
0
 
LVL 2

Expert Comment

by:dabellei
ID: 1436251
replace nfic by 1 in the open statement
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 12

Expert Comment

by:mark2150
ID: 1436252
The LINE INPUT command presumes that there are occassional breaks in the line. A break is defined as a <CR>/<LF> pair. Not all programs place these at the end of the line. Look at the string you're being passed. Some log programs write a fixed length string every time they fire and do not supply the <CR>/<LF> pair. If this is the case then you'll have to change your OPEN and LINE INPUT statements with

OPEN "file.txt" FOR BINARY AS #1
DO WHILE NOT EOF(1)
    Buffer = SPACE( RecordLen )
    GET #1, , Buffer
.
LOOP

The RecordLen is a constant that is the exact number of bytes in one record.


0
 

Author Comment

by:purphaze
ID: 1436253
Here is the code I am using:
Open "c:\internet\data\log.txt" For Input As #1
Open "TESTFILE.TXT" For Output As #2
    Do While Not EOF(1)
        Line Input #1, strTemp
        intPos1 = InStr(1, strTemp, "EMPIRE\")
        intPos2 = InStr(intPos1, strTemp, " ")
        UserID = Mid(strTemp, intPos1 + 7, intPos2 - intPos1 - 7)
        Write #2, UserID
    Loop
    Close #1

If I make the log.txt file about 20 lines, it works. If I leave it the normal size (1400+ lines) it errors.

Note - each line in the log file is a different size. Some of the lines contain 284+ characters
0
 

Author Comment

by:purphaze
ID: 1436254
Here is the code I am using:
Open "c:\internet\data\log.txt" For Input As #1
Open "TESTFILE.TXT" For Output As #2
    Do While Not EOF(1)
        Line Input #1, strTemp
        intPos1 = InStr(1, strTemp, "EMPIRE\")
        intPos2 = InStr(intPos1, strTemp, " ")
        UserID = Mid(strTemp, intPos1 + 7, intPos2 - intPos1 - 7)
        Write #2, UserID
    Loop
    Close #1

If I make the log.txt file about 20 lines, it works. If I leave it the normal size (1400+ lines) it errors.

Note - each line in the log file is a different size. Some of the lines contain 284+ characters
0
 

Author Comment

by:purphaze
ID: 1436255
Unless I'm missing something (and that happens alot) it looks like I already implemented what you suggested. I tried to impement another Expert's suggestion mark1250, but it looks like each record must be the same size. I got close to my end result, as it would return 1402 records, but it is not completing the entire log.
0
 

Author Comment

by:purphaze
ID: 1436256
Unless I'm missing something (and that happens alot) it looks like I already implemented what you suggested. I tried to impement another Expert's suggestion mark1250, but it looks like each record must be the same size. I got close to my end result, as it would return 1402 records, but it is not completing the entire log.
0
 
LVL 1

Accepted Solution

by:
cd74013 earned 200 total points
ID: 1436257
I think the problem might be unrelated to the file records but to the logic of the program:

        intPos1 = InStr(1, strTemp, "EMPIRE\")
        intPos2 = InStr(intPos1, strTemp, " ")
       
if the string "EMPIRE\ " does not occur in the record read from the file then intpos1 will be set to zero.  In that case the next statement will try to find the substring from position zero in the string which will cause a run time error.

0
 

Author Comment

by:purphaze
ID: 1436258
OK, I manually searched the log file I am trying to extract info from, and there are about 6 lines in the log file  that do not contain the string "Empire\". Setup an "On Error" and it went thru the entire log file. The code I ended up with is:
Open "c:\internet\data\log.txt" For Input As #1
    Open "TESTFILE.TXT" For Append As #2
    Do While Not EOF(1)
        Line Input #1, strTemp
        On Error Resume Next
        intPos1 = InStr(1, strTemp, "EMPIRE\")
        intPos2 = InStr(intPos1, strTemp, " ")
        UserID = Mid(strTemp, intPos1 + 7, intPos2 - intPos1 - 7)
        Write #2, UserID
    Loop
       
    End

Now that I have a basic understanding of this, time to expand the extraction criteria
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month15 days, 21 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question