[Class] Java Properties Styled Data Management

Post your working scripts, libraries and tools
User avatar
Delta Pythagorean
Posts: 575
Joined: 13 Feb 2017, 13:44
GitHub: DelPyth
Location: Somewhere in the US

[Class] Java Properties Styled Data Management

09 Jul 2020, 21:17

To be honest, Java's Properties is actually quite simplistic, easy to follow, and very minimalistic. I'd actually recommend it if you're not wanting to use something like JSON or XML to store data.
If you've ever used INI to store data (which is built into AHK), then you'll know the basics of using Java's Properties.
Here's a basic run down:

# I'm a comment!
variable_name = Some Data!
another_variable = Some More Data!
im_true = true
im_false = false
im_nothing = null
multi_line_string = I take up \
exactly \
three lines!
single_line_str = There's a\nSnake in my\nBoot!

# These are objects, no need to define it before setting the info:
object.name = Megaman
object.index = 1
object.is_content = true
another_object.is_new = true

That's it. No need to create a line before the definition, no fancy curly brackets surrounding a bunch of stuff. Nothing.
Just define the path of the object and go!

To read and write your data to and from files it's as easy as doing this:

Code: Select all

; Read a file into an object.
MyObject := Properties.Parse(A_ScriptDir . "\settings.cfg")

; Save an object to a file.
Properties.Dump(MyObject, A_ScriptDir . "\settings.cfg")
Gist Page for the Class.

NOTE: I have only added the \u escapes for Parse not for Dump yet, so keep that in mind.

- [AHK].......: 1.1.33.02 Unicode 64-bit
- [OS].........: Windows 10.0.19041
- [GITHUB]...: github.com/DeltaPyth
- [PAYPAL]....: paypal.me/DelPyth
- [DISCORD]..: Tophat Cat // Delta#8888

Remember to use [code]CODE[/code] for your multi-line scripts.
Stay safe, stay inside, and remember to wash your hands for 20 seconds!

Return to “Scripts and Functions”

Who is online

Users browsing this forum: Google [Bot] and 12 guests