WritePreferenceStringN and ReadPreferenceStringN...

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Joris
Addict
Addict
Posts: 885
Joined: Fri Oct 16, 2009 10:12 am
Location: BE

WritePreferenceStringN and ReadPreferenceStringN...

Post by Joris »

Expand the Preferences commands with Filehandle and Loc().
Something like this :

Code: Select all

Filehandle = OpenPreferences(Filename$ [, Flags])
Loc(Filehandle)
Last edited by Joris on Thu Jul 02, 2020 10:48 am, edited 1 time in total.
Yeah I know, but keep in mind ... Leonardo da Vinci was also an autodidact.
User avatar
kenmo
Addict
Addict
Posts: 1967
Joined: Tue Dec 23, 2003 3:54 am

Re: Retrieve Preferences Filehandle and Loc()

Post by kenmo »

1. Why? What is your intended usage? I'm just wondering.

2. I don't know if the Preferences library actually keeps the file open, with a useful Location pointer... I assume OpenPreferences() loads the whole file into a memory structure for reading and writing, until you save it back to disk.
Joris
Addict
Addict
Posts: 885
Joined: Fri Oct 16, 2009 10:12 am
Location: BE

Re: Retrieve Preferences Filehandle and Loc()

Post by Joris »

Well I got a lot of files in this style :

[X Y W H BOXNAME]
097;104;033;040;Bass;
105;112;041;048;Strings;
113;120;049;056;Ensemble;
121;128;057;064;Brass;
...
[MSB LSB PRG VOICES]
000;000;001;GrandPno;
000;000;002;BritePno;
...

The Preferences commands would be very usefull to handle these too,
except all needs to be seperated with a = sign (sadly not changeable).
Retrieve a complete line isn't possible imo, so Stringfied etc. can't be of use.
That all, while the Preferences commands are very close to do all that too.

It might be even better to add only two commands like :
WritePreferenceStringN <= the N for a complete line
ReadPreferenceStringN <= the N for a complete line

Retrieve Preferences Filehandle and Loc() becomes obsolete then.
Yeah I know, but keep in mind ... Leonardo da Vinci was also an autodidact.
Little John
Addict
Addict
Posts: 4527
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Retrieve Preferences Filehandle and Loc()

Post by Little John »

Joris wrote:Well I got a lot of files in this style :

[X Y W H BOXNAME]
097;104;033;040;Bass;
105;112;041;048;Strings;
113;120;049;056;Ensemble;
121;128;057;064;Brass;
...
[MSB LSB PRG VOICES]
000;000;001;GrandPno;
000;000;002;BritePno;
...
This is not the format of a preference file.
And it is very easy to read such a file using ReadFile() and ReadString().
After opening a file with ReadFile(), you can also use Loc() if you want.
Joris
Addict
Addict
Posts: 885
Joined: Fri Oct 16, 2009 10:12 am
Location: BE

Re: Retrieve Preferences Filehandle and Loc()

Post by Joris »

Little John wrote:This is not the format of a preference file.
And it is very easy to read such a file using ReadFile() and ReadString().
After opening a file with ReadFile(), you can also use Loc() if you want.
I know that and use that already. It's just that the Preferences commands are very close to do that too,
but can't be used.
Yeah I know, but keep in mind ... Leonardo da Vinci was also an autodidact.
Little John
Addict
Addict
Posts: 4527
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Retrieve Preferences Filehandle and Loc()

Post by Little John »

The Preferences commands are specialized for use with Preference files, like the JSON commands are specialized for use with JSON files, and like the XML commands are specialized for use with XML files.
Post Reply