[Closed] storing info to file
Not quite sure why this does not work…
When the user selects from the jobdown it should save the selected item to the rootenode using the setAppData but it doesn’t do anything. I’m assuming it has to do with the part where it says
setappdata rootnode (data_JobName as integer) (with printallelements on ini_JobName as string)
)
the variable ini_JobName is not an array it is just string. so printallelements does not work then.
rollout rlinfo "Info"
(
local data_Project = 5004
local data_JobName = 6052
fn loadInfo =
(
projectNaming = try (execute (getappdata rootnode data_Project)) catch(#())
jobNaming = try (execute (getappdata rootnode data_JobName)) catch(#())
print projectNaming
print jobNaming
)
fn saveInfo =
(
ini_Project = if rlinfo.dlProject.selected == undefined then "" else rlinfo.dlProject.selected
setappdata rootnode (data_Project as integer) (with printallelements on ini_Project as string)
ini_JobName = if rlinfo.dJobName.selected == undefined then "" else rlinfo.dJobName.selected
setappdata rootnode (data_JobName as integer) (with printallelements on ini_JobName as string)
)
dropdownlist dlProject "" items:#("cool","nice","donuts")
dropdownlist dJobName "" items:#("old","new","shitty")
button btnPrint "Print"
on btnPrint pressed do
(
loadInfo()
)
on dlProject selected idx do
(
saveInfo()
)
on ini_JobName selected idx do
(
saveInfo()
)
on rlInfo open do
(
print (dlProject.selected)
)
)
createDialog rlInfo 150 150
There is no need for the execute. Instead you should use if != undefined do.
rollout rlinfo "Info"
(
local data_Project = 5004
local data_JobName = 6052
fn loadInfo =
(
projectNaming = getappdata rootnode data_Project
jobNaming = getappdata rootnode data_JobName
print projectNaming
print jobNaming
)
fn saveInfo =
(
ini_Project = if rlinfo.dlProject.selected == undefined then "" else rlinfo.dlProject.selected
setappdata rootnode (data_Project as integer) (with printallelements on ini_Project as string)
ini_JobName = if rlinfo.dJobName.selected == undefined then "" else rlinfo.dJobName.selected
setappdata rootnode (data_JobName as integer) (with printallelements on ini_JobName as string)
)
dropdownlist dlProject "" items:#("cool","nice","donuts")
dropdownlist dJobName "" items:#("old","new","shitty")
button btnPrint "Print"
on btnPrint pressed do
(
loadInfo()
)
on dlProject selected idx do
(
saveInfo()
)
on ini_JobName selected idx do
(
saveInfo()
)
on rlInfo open do
(
print (dlProject.selected)
)
)
createDialog rlInfo 150 150
A word of warning – setAppData and getAppData are good ways of storing and saving info quickly and easily, but they can very easily be overwritten by other scripts using the same values. If you do use them I’d recommend using much more than 4 digits just to be safe.
Scripted custom attributes saved to the rootNode are also a good way to go as they can be accessed with a post merge callback using the xRef Scene system.
Thanks for the quick response.
I initially was using execute to turn the stored string back into an array. But this time around I was just trying to save a stand alone string and was overlooking that part of it.
Thanks for the help and explanation of things.