Page 1 of 1
WritePreferenceStringN and ReadPreferenceStringN...
Posted: Tue Jun 30, 2020 3:26 pm
by Joris
Expand the Preferences commands with Filehandle and Loc().
Something like this :
Code: Select all
Filehandle = OpenPreferences(Filename$ [, Flags])
Loc(Filehandle)
Re: Retrieve Preferences Filehandle and Loc()
Posted: Tue Jun 30, 2020 5:09 pm
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.
Re: Retrieve Preferences Filehandle and Loc()
Posted: Wed Jul 01, 2020 8:53 am
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.
Re: Retrieve Preferences Filehandle and Loc()
Posted: Wed Jul 01, 2020 9:00 am
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.
Re: Retrieve Preferences Filehandle and Loc()
Posted: Wed Jul 01, 2020 9:13 am
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.
Re: Retrieve Preferences Filehandle and Loc()
Posted: Wed Jul 01, 2020 9:46 am
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.