Does anyone see anything wrong with this small program? I am trying
to read through each byte in a text file script with the binary Get
statement. Then I am trying to use PUT to "poke" each character into
an exe starting at a certain position. It initially worked, but now it
is not working.
Sub Main()
On Error GoTo BigError
If Command$ = "" Then End
REM leave template.exe unaltered
FileCopy fileloc + "template.exe", fileloc + "a.exe"
Open fileloc + "a.exe" For Binary As #1
Open Command$ For Binary As #2
Dim character As String * 1
Dim filepos As Long
filepos = 25947
Dim filelength As Long
filelength = LOF(2)
If filelength > 28000 Then
MsgBox "Script exceeds 28000 bytes. Compile failed"
Close
End
End If
Dim x As Long
For x = 1 To filelength
Get #2, x, character
Put #1, filepos, character
filepos = filepos + 1
Next x
Close #1
Close #2
MsgBox "Task Complete"
End
BigError:
MsgBox "Compile failed: " + Str$(Err.Number) + "-" +
Err.Description
Close
End
End Sub
Function fileloc() As String
' returns path to executable
a$ = App.Path
If a$ <> "\" Then
a$ = a$ + "\"
End If
fileloc = a$
End Function
Dos-Man 64 - 24 Jun 2009 02:19 GMT
> Does anyone see anything wrong with this small program? I am trying
> to read through each byte in a text file script with the binary Get
[quoted text clipped - 52 lines]
> fileloc = a$
> End Function
Never mind. I don't think it is a problem with this code. There was
an illegal function call happening within a.exe.