I knew I saw this somewhere recently, I was looking at JSON, I couldn't find it via Google.
You've found the most complicated ever example of Format.
The 'Join' relates to continuation sections, which is used (for example) to create a WYSIWYG string over multiple lines.
AutoHotkey Scripts and Macros
https://autohotkey.com/docs/Scripts.htm#continuation
Btw:
Format
https://autohotkey.com/docs/commands/Format.htm
Use {{} and {}} to include literal braces in the string. Any other invalid placeholders are included in the result as is.
That script (the JSON library example) takes a string in JSON format (similar to the ini file format but more versatile), and from that creates an object.
I've replicated the object that the script creates. The script then shows the output text of Format, and then the continuation section text by itself.
Code: Select all
q:: ;Format and continuation section example
parsed := {}
parsed.str := "Hello World"
parsed.num := 12345
parsed.float := 123.5
parsed.true := true
parsed.false := false
parsed.null := null
parsed.array := ["Auto","Hot","key"]
parsed.object := {A:"Auto",H:"Hot",K:"key"}
parsed_out := Format("
(Join`r`n
String: {}
Number: {}
Float: {}
true: {}
false: {}
null: {}
array: [{}, {}, {}]
object: {{}A:""{}"", H:""{}"", K:""{}""{}}
)"
, parsed.str, parsed.num, parsed.float, parsed.true, parsed.false, parsed.null
, parsed.array[1], parsed.array[2], parsed.array[3]
, parsed.object.A, parsed.object.H, parsed.object.K)
parsed := ""
MsgBox, % parsed_out
MyContinuationSection := "
(Join`r`n
String: {}
Number: {}
Float: {}
true: {}
false: {}
null: {}
array: [{}, {}, {}]
object: {{}A:""{}"", H:""{}"", K:""{}""{}}
)"
MsgBox, % MyContinuationSection
return