I need to create a simple macro that an Attachmate session will run on startup -- the macro should simply display the contents of a text file if it exists.
The following works most of the time:[tt]
====================
Sub Main
Dim fchar()
Dim x as Integer
Dim msgtext
Close #1
Open "alerts.txt" for Input as #1
If Err<>0 then
Exit Sub
End If
Redim fchar(Lof(1))
For x=1 to Lof(1)
fchar(x)=Input(1,#1)
msgtext=msgtext & fchar(x)
Next x
MsgBox msgtext
Close #1
End Sub
====================[/tt]
however, sometimes I get "Disk not ready" (line # for fchar... line above) errors.
Should I be using the Open statement a different way? I looked at the online help for:
[tt]
Open filename$ [For mode] [Access access] [lock] As [#] filenumber% [Len = reclen]
[/tt]
but my help seems corrupted becasue the modes are jumbled -- is there one other than 'Input' that I should use since I am merely reading the file.
Final note, I am going to distribute the session.edp file to 100+ users on the network who will all call the same macro and the same file will be read by them all so I do not want any locking, etc. errros.
Thanks.
The following works most of the time:[tt]
====================
Sub Main
Dim fchar()
Dim x as Integer
Dim msgtext
Close #1
Open "alerts.txt" for Input as #1
If Err<>0 then
Exit Sub
End If
Redim fchar(Lof(1))
For x=1 to Lof(1)
fchar(x)=Input(1,#1)
msgtext=msgtext & fchar(x)
Next x
MsgBox msgtext
Close #1
End Sub
====================[/tt]
however, sometimes I get "Disk not ready" (line # for fchar... line above) errors.
Should I be using the Open statement a different way? I looked at the online help for:
[tt]
Open filename$ [For mode] [Access access] [lock] As [#] filenumber% [Len = reclen]
[/tt]
but my help seems corrupted becasue the modes are jumbled -- is there one other than 'Input' that I should use since I am merely reading the file.
Final note, I am going to distribute the session.edp file to 100+ users on the network who will all call the same macro and the same file will be read by them all so I do not want any locking, etc. errros.
Thanks.