DesignCAD 3D Max 2027 box
Now available

DesignCAD 2027

Hatches that follow their boundaries, an on-screen dial to turn your model, and a way to find any command by name, in a clean Windows 11 look.

writing to a text file

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

Previous topic - Next topic

0 Members and 0 Guests 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