[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 204
  • Last Modified:

writing to a file

HOw do you open a file for read and write access? And can you write to the file while you read from it?
0
GoofyJoe99
Asked:
GoofyJoe99
1 Solution
 
stedan_98Commented:
yes! here is the code:
(miss out the number and bracket if your copying and pasting into vb):

---------------------------------------
0) open "data.dat" for random as #1
---------------------------------------

functions:

---------------------------------------
1) get #1,indata
2) get #1,1,indata

3) put #1,outdata
4) put #1,1,outdata
---------------------------------------

ok now for an explanation:

0 = this function opens a file for both read and write access
1 = this gets all the data in the file and assigns is to the variable indata
2 = this gets the data at record number 1 in the file and stores it in the indata variable
(note: you must use the put statement example 4 to use records as you have to create them first or make sure they exist)
3 = writes to the file all the data in the outdata variable
4 = puts to record number 1 in the file all the data in the outdata variable

NOTE: the #1 stands for file number 1
when you say open ....... for random as #1 you could also say #2,#3 whatever

*hope this helps*
0
 
GoofyJoe99Author Commented:
thanks
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now