[Implemented] Reading/Writing Designated File
[Implemented] Reading/Writing Designated File
I find the requirment that all read and write operations to file have to be
to the current file to be a real aggrivation. I'm sure it has been mentioned
before, but commands like ReadString() could be made much more
versitile if you permitted an optional file designation parameter, like
ReadString(f1), where f1 designated which file was to be read from. That
would make it much easier to work with multiple files simultaneously.
FileSeek() should allow a second parameter to designate the specific
file, and there needs to be a companion command that returns the
current file position so that you can tell where you are in the file.
In fact almost every command needs its counterpoint. If you can write to
the screen, you sometimes need to read from the screen. File I/O is
particularly critical, since most information ends up in that form sooner
or later.
to the current file to be a real aggrivation. I'm sure it has been mentioned
before, but commands like ReadString() could be made much more
versitile if you permitted an optional file designation parameter, like
ReadString(f1), where f1 designated which file was to be read from. That
would make it much easier to work with multiple files simultaneously.
FileSeek() should allow a second parameter to designate the specific
file, and there needs to be a companion command that returns the
current file position so that you can tell where you are in the file.
In fact almost every command needs its counterpoint. If you can write to
the screen, you sometimes need to read from the screen. File I/O is
particularly critical, since most information ends up in that form sooner
or later.
has-been wanna-be (You may not agree with what I say, but it will make you think).
I agree that for readibility and consistance that would be the best.
You can switch between files to work with multiple files. Just use
The #File points to the filehandle of the file you want to use.

You can switch between files to work with multiple files. Just use
Code: Select all
UseFile(#File)
this point is valid for many commands, i'd like to see both, that is support for current syntax
ie. using
refers to the last used file / command / ... and
... specifying it
ie. using
Code: Select all
whatever()
Code: Select all
whatever( <nr> )
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
...,
Concerning file commands most languages use a file number as an attribute, also for Read / Write ... so I totally agree with this.
And for some other commands too ... Genralizing such an attribute would make coding far easier.
Rgrds
Concerning file commands most languages use a file number as an attribute, also for Read / Write ... so I totally agree with this.
And for some other commands too ... Genralizing such an attribute would make coding far easier.
Rgrds
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.
but keep both syntaxes as that will allow procedures that don't have to receive the file number... and that wouldn't break old code 

( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
The way with UseFile(Nr) and other Use...() commandsaXend wrote:You can switch between files to work with multiple files. Just useThe #File points to the filehandle of the file you want to use.Code: Select all
UseFile(#File)
makes it absolutely impossible to program thread-safe.
1 Thread calls an Use....() function and does some things now.
If another thread calls the same Use....() function now, the
first thread is affected by this too, and things get corrupt and
mixed up.
The Use....() commands set a global number internally, and other
functions rely on this global number. Global stuff isnt good for
thread-safety.
Every Object (Function/Procedure) has to run absolutely standalone
without relying on a global internal number - thread-safety and
callbacks are not safe with this global stuff.
In OOP its much better, because the handle is saved *local*
as data in the object:
Code: Select all
file1.FILE = File()
If file1\Create("c:\xyz.bin")
file1\WriteByte(12)
file1\Close()
EndIf
Code: Select all
file2 = CreateFile("c:\xyz.bin")
If file2
WriteByte(file2,12)
CloseFile(file2)
EndIf
I think following (what is real!) is simply stupid:
ActivateGadget(#gadget)
ActivateWindow()
In the case of the gadget, you have to write #gadget, in case of the window, you must not write #window! Please, make following possible:
ActivateGadget([#gadget])
ActivateWindow([#window])
Optional Parameters allow everyone to use the style he prefers...
Jürgen
ActivateGadget(#gadget)
ActivateWindow()
In the case of the gadget, you have to write #gadget, in case of the window, you must not write #window! Please, make following possible:
ActivateGadget([#gadget])
ActivateWindow([#window])
Optional Parameters allow everyone to use the style he prefers...
Jürgen
ActivateGadget() (without any parameter) is useless, because there is no
"current gadget". (There is no such thing as UseGadget() as well, because
it would not make much sense.) That's why it needs to be specified all the
time.
I agree with the ActivateWindow([#Window]) thing though.
Timo
"current gadget". (There is no such thing as UseGadget() as well, because
it would not make much sense.) That's why it needs to be specified all the
time.
I agree with the ActivateWindow([#Window]) thing though.
Timo
quidquid Latine dictum sit altum videtur