Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

64k string size limitation

Posted on 1998-09-23
10
Medium Priority
?
218 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

715 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