News:

Please note new Forum URL: forum.designcad.com

Main Menu

writing to a text file

Started by Mark Laing, December 17, 2007, 10:19:07 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Mark Laing

In the following code fragment, I know I'm opening and closing the file right because it come's up in Notepad, but how do I write to the file?  I get nowhere with Input# or Print#.

filename$ = "Timesheet"
Open "A", 1, filename$
'Input# 1, "Hello, World!"
Close 1
run$ = "c:\windows\notepad.exe ", filename$
run run$, 1

And for opening a file for random access I need the file length. How on earth do I get that?

bdeck

#1
Hi Mark,

Try this.


filename$ = "Timesheet"
Open "A", 1, filename$
print #1, "Hello, World!"      ' no space after #, space before # is optional
Close 1
run$ = "c:\windows\notepad.exe " + filename$    ' plus sign is more conventional, but comma works in DC
run run$, 1

Random access requires record length for data files, not file length. Choose whatever record size works for your application. The system will index that number of bytes between reads.

BD