[Implemented] For OpenFile() a new parmeter #PB_Append?

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Falko
Enthusiast
Enthusiast
Posts: 271
Joined: Sat Oct 04, 2003 12:57 pm
Location: Germany
Contact:

[Implemented] For OpenFile() a new parmeter #PB_Append?

Post by Falko »

Hello Fred and PB-team

#PB_Append into Openfile() for set read/write pointer position for beginning opfenfile to end of File?
www.falko-pure.de
Win11 Pro 64-Bit, PB_6.11b1
Little John
Addict
Addict
Posts: 4777
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Post by Little John »

I do support this request. Reasons:
a) Such a feature is useful and not seldom needed.
b) People who have previously used another programming language probably know such a feature, and are confused when they don't find it in PB. This also means, that offering this feature would make it easier for programmers to switch from another language to PB.
c) Although we can implement this functionality ourselves, beginners can *not* do so.

Regards, Little John
jamirokwai
Enthusiast
Enthusiast
Posts: 796
Joined: Tue May 20, 2008 2:12 am
Location: Cologne, Germany
Contact:

Re: For OpenFile() a new parmeter #PB_Append?

Post by jamirokwai »

Falko wrote:Hello Fred and PB-team

#PB_Append into Openfile() for set read/write pointer position for beginning opfenfile to end of File?
I also support this request. For my latest Application, I needed to append data
to an existing file. I use FileSeek(0, LoF(0)) at the moment... Should be
possible without a second line of code, I think.
Regards,
JamiroKwai
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: For OpenFile() a new parmeter #PB_Append?

Post by PB »

> FileSeek(0, LoF(0))

You can always create a new macro command made up of OpenFile and
FileSeek(0, LoF(0)) after it, make it a resident, then the new command will
always be available when you run PureBasic without any extra typing at all.
The new command could be named something like AppendFile(#num,name$).

Oh damn, I think I even further dissuaded the team from doing it now. :twisted:

(For the record, I've love an append flag too).
Last edited by PB on Thu Jul 24, 2008 10:30 am, edited 1 time in total.
Little John
Addict
Addict
Posts: 4777
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: For OpenFile() a new parmeter #PB_Append?

Post by Little John »

PB wrote:> FileSeek(0, LoF(0))

You can always create a new macro command made up of CreateFile and
FileSeek(0, LoF(0)) after it,
CreateFile() will delete any existing file. This certainly is not wanted, when someone intends to append stuff to an existing file.

Writing a macro as suggested is not easy for new users of PB, and -- as you demonstrated :mrgreen: -- there is some risk of making a fatal mistake.

Regards, Little John
User avatar
Falko
Enthusiast
Enthusiast
Posts: 271
Joined: Sat Oct 04, 2003 12:57 pm
Location: Germany
Contact:

Post by Falko »

+1 :twisted:
www.falko-pure.de
Win11 Pro 64-Bit, PB_6.11b1
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: For OpenFile() a new parmeter #PB_Append?

Post by PB »

> CreateFile() will delete any existing file

Ah, that was just a typo. Of course I meant OpenFile. I've edited my post.
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

I think the Team has more relevant things to do than caring about such peepee....

In my eyey, it's better to let a beginner see what is necessary to append to a file
than let him believe you could magically open a file with the pointer at the end.
oh... and have a nice day.
Little John
Addict
Addict
Posts: 4777
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Post by Little John »

Kaeru Gaman wrote:I think the Team has more relevant things to do than caring about such peepee....
I think the team members can decide that themselves. In any case, this sub-forum is for posting wishes, no?
Kaeru Gaman wrote:In my eyey, it's better to let a beginner see what is necessary to append to a file
than let him believe you could magically open a file with the pointer at the end.
From a current thread in the German forum, where both you and me participate, we know that this seems to be too hard for some beginners. And in the proposed functionality, there is no magic involved. It is standard in several other languages. I already wrote above, why implementing standard features can be advantageous also for Fantaisie Software themselves.

Regards, Little John
Post Reply