Notifications
Clear all
[Closed] Saving my Choice Number from Dropdownlist to external file
Jan 06, 2018 8:51 am
Hello everyone,
I’ve been struggling all day long with my script, without success. I need to save my Choice Number from Dropdownlist to an .ini file, but Parameter4 returns undefined. What am I doing wrong ?
try(destroydialog a)catch()
fn SaveIniFile =
(
presetDir = ((getdir #scripts) + "\\Myscriptfolder\\presets\\")
if (getDirectories presetDir).count == 0 then makeDir presetDir
OutputFilename = presetDir + "MyParameters.ini"
setINISetting OutputFilename "MyParameters" "Parameter1" "1"
setINISetting OutputFilename "MyParameters" "Parameter2" "false"
setINISetting OutputFilename "MyParameters" "Parameter3" "true"
setINISetting OutputFilename "MyParameters" "Parameter4" (MyChoiceNumber as string)
)
rollout a "Myscript"
(
dropdownlist Dropdown "" items:#("A","B","C","D","E") width:120
on Dropdown selected i do MychoiceNumber = i
button Go_btn "Go"
on Go_btn pressed do SaveInifile()
)
createDialog a
4 Replies
Jan 06, 2018 8:51 am
You have to pass the value to your function.
So:
- Create a local rollout variable
- and, not needed but better, include your function inside your rollout
(Another possibility is to declare your ‘MyChoiceNumber’ variable as a global one, but it’s a worse solution.)
try(destroydialog a)catch()
rollout a "Myscript"
(
local MychoiceNumber = 1
fn SaveIniFile MychoiceNumber =
(
presetDir = ((getdir #userscripts) + "\\Myscriptfolder\\presets\\")
if (getDirectories presetDir).count == 0 then makeDir presetDir
OutputFilename = presetDir + "MyParameters.ini"
setINISetting OutputFilename "MyParameters" "Parameter1" "1"
setINISetting OutputFilename "MyParameters" "Parameter2" "false"
setINISetting OutputFilename "MyParameters" "Parameter3" "true"
setINISetting OutputFilename "MyParameters" "Parameter4" (MyChoiceNumber as string)
)
dropdownlist Dropdown "" items:#("A","B","C","D","E") width:120
on Dropdown selected i do MychoiceNumber = i
button Go_btn "Go"
on Go_btn pressed do SaveInifile MychoiceNumber
)
createDialog a
Jan 06, 2018 8:51 am
Thank you for your quick answer, but your version is not working
No ini file is generated.
Jan 06, 2018 8:51 am
Yes, it works.
I have changed the #scripts directory to the #userscripts directory. Search in this path or change it again to #scripts.
Jan 06, 2018 8:51 am
You’re right, I didn’t notice that change.
Great Thanks Andres, you’re a genius !