I need help creating nested class of this.value := "str"
My brain tells me to nest this class with the parent being a dictionary method
this is all in service of setting json values for json.dump
I left a duplication for "this.dictionary:={}" for where I tried placing it, this parent class being the first attempt, right within the nested class after.
I felt it would be easier to describe the workflow via image but raw code is below as well
edit: I have a syntax error in the msgbox section, it should be .= not :=
I think I figured part of it out, I needed to do this:
Code: Select all
myApp := appDic()
appOne := myApp.defineApp("samfisherirl", "Github.ahk")
appOne.connectGithubAPI()
Code: Select all
; Include the JSON library
#Include %A_ScriptDir%\lib\Native.ahk
#Include %A_ScriptDir%\lib\github.ahk
; Example usage
; Create a new instance of the appDictionary class
myApp := appDic.defineApp("samfisherirl", "Github.ahk")
; Call the defineApp method to add a dictionary to the array
myApp.connectGithubAPI()
;set further existing unset values in object
; Serialize the array of dictionaries as JSON and print the result
;//////////json := myApp.SerializeToJson()
myApp.setDic(myApp)
; enumerates set values in nested class into dictionary
myApp.printDic()
; Define a class for building dictionaries of 3 strings
class appDic {
__New() {
this.dictionary := {}
}
; Define a method for adding a dictionary of 3 strings to the array
class defineApp {
__New(username, repo) {
; Create a new dictionary with the given strings
this.username := username,
this.repo := repo,
this.downloadUrl := "",
this.version := "",
this.releaseNotes := "",
this.appPath := "",
this.downloadPath := ""
this.dictionary := {}
}
setPath(appPath) {
this.downloadPath := appPath
}
connectGithubAPI() {
; retieve from github library latest releaseUrl, notes, and version
git := Github(this.username, this.repo)
this.downloadUrl := git.releaseUrl()
this.version := git.version()
this.releaseNotes := git.details()
}
setDic() {
for key, value in appDic.defineApp {
this.dictionary[key] := value
}
}
printDic() {
for key, value in this.dictionary {
msg := key . ": " . value . "`n"
}
msgbox(msg)
}
; Add the new dictionary to the array
; this.dictionaries.push(defineApp)
/*
; Define a method for serializing the array of dictionaries as JSON
SerializeToJson() {
; Serialize the array of dictionaries as JSON
jdata := JSON.stringify(this.dictionaries)
; Return the serialized JSON string
return jdata
}
; retreive github library data including url to download and version data
*/
}
}