• Welcome to Valhalla Legends Archive.
 

Read/Write from files

Started by zeth369, September 29, 2004, 08:44 PM

Previous topic - Next topic

zeth369

.. just what the title says.. im trying to make my very first bot.. and I'm not sure how to read or write from files.. could someone please help.. i need this for my config..

Michael

To read a file

Open app.path & "/filename.txt" for input as #1
dim text as string
do until eof(1)
input #1, text
'note that adds each line of the file into the bot then you would have to make 'something to add it to a list box or sort it out
'example
'list1.additem text
'or use instr to check for a certian string

to write to a file instead of Open app.path & "/filename.txt" for input as #1 use Open app.path & "/filename.txt" for output as #1
then instead if input #1, text do print #1, text

Hope this helps you.

ctype

Or, if you'd find it easier (i don't tho) you could make a reference to Microsoft Scripting Runtime and declare a global variable (like FSO) 'as new FileSystemObject' and then - for example - use it to access file / drive info...

Dim FSO as new FileSystemObject
Dim D as Drive

Set D = FSO.GetDrive("C:\")
MsgBox FormatNumber(D.AvailableSpace / 1024, 0) _
& " Kb"

I prefer to use the good old open / close statements from QBasic, unless I want / need specific info (such as date created) about a file.