Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help needed with Open statement -- need to display a text file

Status
Not open for further replies.

mrw13

IS-IT--Management
Dec 3, 2004
2
US
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.

 
I've never seen the input statement used as you do. I usually put:
Input #1, fchar(X)

calculus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top