DONE: Global/Static/User/Scripting .INI file and Object

Make a request or discuss new features.
Post Reply
User avatar
rjbill
Posts: 879
Joined: 13 Jun 2011 06:36

DONE: Global/Static/User/Scripting .INI file and Object

Post by rjbill »

If you "get some free time", this would be a nice thing to have for scripting users.

A Global .INI file that is loaded at Editor startup and written at Editor quit.

An associated Object, like the Scriptable Object, would have the values
loaded into it for Get and Set by the user's scripts, which would be fast
because they are "loaded into/from memory".

There should probably be an Update method in case the user wants to write the INI file.
And maybe Delete and/or ClearAll methods. (DeleteValue and DeleteSection ?)

And there could be [Session] and/or [Temp] sections that are not
written to the INI file on Exit or Update, so they are Editing Session-Temporary.
(this would be good for "First Time Script Run?" checks and other temp usage)

I would do them all as Strings and let the user mess with them,
or you could support types as in TMemIniFile.

Since you can run scripts from macros, I think this would also fix my desire
for an "auto-incrementing paste buffer" system.
That is, I could have a "Reset" script that would set a value to 0 or 1,
and then a "Get" script that would load the value into the Paste buffer
and increment / add-to the value for next time.

That's all I've thought about so far with this idea.
RJTE version 16.16 (actual) - 64-bit
Win 10 Pro 64-bit 8 GB RAM Intel Core i7-6700 3.40 GHz SCSI Hard Drive 1 TB

Note: The signature is dynamic, not static,
so it may not show the correct version above
that was in use at the time of the post.
User avatar
Rickard Johansson
Site Admin
Posts: 6628
Joined: 19 Jul 2006 14:29

Re: Global/Static/User/Scripting .INI file and Object

Post by Rickard Johansson »

Created a new "ScriptSettings" object with the following methods:

Code: Select all

procedure DeleteKey(const Section, Ident: String)
    procedure EraseSection(const Section: string)
    function ReadBool(const Section, Ident: string; Default: Boolean): Boolean
    function ReadDateTime(const Section, Name: string; Default: TDateTime): TDateTime
    function ReadDate(const Section, Name: string; Default: TDateTime): TDateTime
    function ReadFloat(const Section, Name: string; Default: Double): Double
    function ReadInteger(const Section, Ident: string; Default: Integer): Integer
    function ReadString(const Section, Ident, Default: string): string
    function ReadTime(const Section, Name: string; Default: TDateTime): TDateTime
    function SectionExists(const Section: string): Boolean
    procedure UpdateFile;
    function ValueExists(const Section, Ident: string): Boolean
    procedure WriteBool(const Section, Ident: string; Value: Boolean)
    procedure WriteDateTime(const Section, Name: string; Value: TDateTime)
    procedure WriteDate(const Section, Name: string; Value: TDateTime)
    procedure WriteFloat(const Section, Name: string; Value: Double)
    procedure WriteInteger(const Section, Ident: string; Value: Integer)
    procedure WriteString(const Section, Ident, Value: String)
    procedure WriteTime(const Section, Name: string; Value: TDateTime)
A [Temp] section is not saved to the file, when the program is closed.

E.g. ScriptSettings.WriteBool("Temp","ShowUI",true).

Done in next release (v16.12).
User avatar
rjbill
Posts: 879
Joined: 13 Jun 2011 06:36

Re: DONE: Global/Static/User/Scripting .INI file and Object

Post by rjbill »

THANKS.

That will come in very handy.
RJTE version 16.16 (actual) - 64-bit
Win 10 Pro 64-bit 8 GB RAM Intel Core i7-6700 3.40 GHz SCSI Hard Drive 1 TB

Note: The signature is dynamic, not static,
so it may not show the correct version above
that was in use at the time of the post.
Post Reply