|
-
Jun 26th, 2007, 08:18 PM
#1
Thread Starter
Member
Restarting an application upon error
I have written a program in VB6. It works fine for a few hours, but then it receives an error saying "Invalid procedure 67", "Too many files". I have tried many ways to fix this but they have not had any effects.
I would be happy if it just autorestarted when it gets an error. I was wondering if that is possible
-
Jun 26th, 2007, 08:27 PM
#2
Re: Restarting an application upon error
Rather than coming up with ways to bypass the error, try to address the error first. Which procedure, line of code is causing it? My guess is that your not releasing file handles (closing files) or simply opening too many files at the same time.
Last edited by leinad31; Jun 26th, 2007 at 08:46 PM.
-
Jun 26th, 2007, 10:37 PM
#3
Thread Starter
Member
Re: Restarting an application upon error
It opens 3 files at a time. I made sure that they all close properly also. This is why I want to know a way to restart it on error.
-
Jun 26th, 2007, 10:41 PM
#4
Re: Restarting an application upon error
 Originally Posted by JohnNewman
It opens 3 files at a time. I made sure that they all close properly also. This is why I want to know a way to restart it on error.
Can you show the code you use to open and close the files.
-
Jun 26th, 2007, 10:50 PM
#5
Re: Restarting an application upon error
What you should want is a way to stop the error in the first place.
There is code on www.pscode.com/vb for detecting GPFs (ex: Windows XP message saying it's encountered a critical error and needs to close). But what you should be concerned with is getting rid of the error.
-
Jun 26th, 2007, 11:20 PM
#6
Thread Starter
Member
Re: Restarting an application upon error
Well here are the times i open and close my files:
Code:
Dim intFF As Integer
Dim wordToRead As Integer
intFF = FreeFile
wordToRead = 5
Dim strLine As String
Open "C:\logs\log.txt" For Input As #intFF
Do While Not EOF(intFF)
Line Input #intFF, strLine
Dim lngFileNo As Long
lngFileNo = FreeFile
Dim myStr() As String
strLine = Left$(strLine, Len(strLine) - 1)
Open strLine For Binary As lngFileNo
Dim bytData(7) As Byte
Dim byt(20) As Byte
Get lngFileNo, &HC5, bytData
hex5 = Hex$(CLng(bytData(4)))
Get lngFileNo, &H2C0, byt
Dim hexx(20) As String
hexx(1) = (byt(0))
hexx(2) = (byt(1))
hexx(3) = (byt(2))
hexx(4) = (byt(3))
hexx(5) = (byt(4))
hexx(6) = (byt(5))
hexx(7) = (byt(6))
hexx(8) = (byt(7))
hexx(9) = (byt(8))
hexx(10) = (byt(9))
hexx(11) = (byt(10))
hexx(12) = (byt(11))
hexx(13) = (byt(12))
hexx(14) = (byt(13))
hexx(15) = (byt(14))
i = 1
Do Until i = 15
If hexx(i) = 0 Then
hexx(i) = x
i = i + 1
ElseIf Chr$(hexx(i)) = Chr$(255) Then
hexx(i) = x
i = i + 1
Else
hexx(i) = Chr$(hexx(i))
i = i + 1
End If
Loop
Dim char(20) As Byte
Get lngFileNo, &H10, char
Dim charn(15) As String
charn(1) = (char(0))
charn(2) = (char(1))
charn(3) = (char(2))
charn(4) = (char(3))
charn(5) = (char(4))
charn(6) = (char(5))
charn(7) = (char(6))
charn(8) = (char(7))
charn(9) = (char(8))
charn(10) = (char(9))
charn(11) = (char(10))
charn(12) = (char(11))
charn(13) = (char(12))
charn(14) = (char(13))
i = 1
Do Until i = 15
If charn(i) = 0 Then
charn(i) = x
i = i + 1
Else
charn(i) = Chr$(charn(i))
i = i + 1
End If
Loop
'SQL stuff
Loop
Close lngFileNo
Close #intFF
Open "C:\logs\log.txt" For Output As #intFF
Close #intFF
Please don't mind the beginner coding in this, as I am fairly new to VB.
-
Jun 27th, 2007, 02:44 AM
#7
Re: Restarting an application upon error
Yes, It would make it a heck of a lot easier to follow your code if it were properly indented and formulated.
Several things:
You should use the Read parameter in your Open statements since you are not writing to the file.
You define one file handle as integer and another as long. Both should be integer.
You use the # sign on one and not the other.
use a loop to assign your arrays (hexx(15) = (byt(14)) and charn(14) = (char(13)))
Post your whole project for I can't make heads or tails of what you are doing.
-
Jun 27th, 2007, 10:43 AM
#8
Re: Restarting an application upon error
There's one other possibility (other than opening files and not closing them).
Error 67 is also thrown if you try to make a 513th entry to the root
directory.
Code:
MS-DOS operating system: More files have been created
in the root directory than the operating system permits.
The MS-DOS operating system limits the number of files that can be in the root
directory, usually 512. If your program is opening, closing, or saving files in the
root directory, change your program so that it uses a subdirectory.
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.
Please Help Us To Save Ana
-
Jun 27th, 2007, 02:24 PM
#9
Re: Restarting an application upon error
He is not using the root. But VB can only have 511 open file handle total.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|