[Closed] Load Var in Edit Box from INI {Maxscript}
so i have a INI settings rollout where user chooses a path,
local dir
on btn_setINIPath pressed do (
tempPathVar = getSavePath caption:"Choose INI Folder Destination" initialDir:"C:\\"
if (tempPathVar != undefined) then (
edt_iniPath.text = tempPathVar
dir = tempPathVar + INI_FILENAME
lbl_savePthSuccess.text = "SAVED!"
setINISetting dir iniCategories[1] iniKeys[1] dir
)
)
putting something like
editText edt_iniPath "" pos:[6,141] width:461 height:17 readOnly:true text:dir
iirc will often default to undefined if you exit the script and restart it, which shows nothing in the textBox, i know it does this on Max Restart.
I just can’t figure out how to find out if an ini file exists in a user defined path and then load that into the editText box across script and Max restarts without saving any scene (.max) files.
the problem is i don’t understand how to keep the pathing to the ini
getINIsetting {dir doesn't work here b/c its undefined on restart} "Category" "Key"
any ideas?
Maybe something like this:
(
global rol_
try(destroyDialog rol_)catch()
rollout rol_ ""
(
local myRolloutINISettingsPath = (getFilenamePath (getSourceFileName()) ) + "MyRolloutSettings.ini"
local INI_FILENAME = "INI_FILE_NAME"
local dir = ""
button btn_setINIPath "Set INI path" width:140
editText edt_iniPath "" readOnly:true text:dir
on btn_setINIPath pressed do
(
tempPathVar = getSavePath caption:"Choose INI Folder Destination"
if (tempPathVar != undefined) do
(
edt_iniPath.text = tempPathVar
dir = (tempPathVar + "\\" + INI_FILENAME + ".ini")
-- lbl_savePthSuccess.text = "SAVED!"
setINISetting dir "INI Category" "INI Key" (dir as string)
setINIsetting myRolloutINISettingsPath "User Settings" "UserINIPath" (dir as string)
)
)
on rol_ open do
(
dir = getINIsetting myRolloutINISettingsPath "User Settings" "UserINIPath"
edt_iniPath.text = dir
)
)
createdialog rol_
)
Thanks miauu, i did try setting a global, but it didn’t save on Max Restart, and thinking about it, it made little sense having someone choose where the INI went i guess, i will try your solution when i get finished with the rest of the script. thanks, i’ll post back when i do.
I don’t know why you want to let the user to choose where to save the INI file. Everything can be saced in one INI file and the settings can be loaded when the script is ran by the user. As you can see from the code, the script, automatically, creates the INI file in the same place where the script file is.
You can read this: http://forums.cgsociety.org/showpost.php?p=8256318&postcount=5