Notifications
Clear all

[Closed] Save spinner Settings – revisited

I was hoping to save my spinner settings by creating a rcmenu
rcmenu RC_Menu_Main
(
submenu “File”
(
menuitem File_Open “Open …”
menuitem File_Save “Save …”
separator sp1
menuitem File_Exit “Exit”
)
)
in combination with
fn saveSettings =
(
setINISetting INIFilename “Home” “W_C_D” (SPN_W_C_D.value as string)
setINISetting INIFilename “Home” “Advance” (SPN_Stride_Advance.value as string)
)

 fn loadSettings =
 (
     try(SPN_W_C_D.value = (getINISetting INIFilename "Home" "W_C_D" ) as float)catch()
     try(SPN_Stride_Advance.value = (getINISetting INIFilename "Home" "Advance") as float)catch()
 )

BUT …
the rcmenu is defined BEFORE the rollout and the values that need saving are IN the rollout so loadSettings() and saveSettings() don’t eval properly, of course.

I could use a button generated in the rollout but that negates the point of using the rcmenu…

Any pointers?

5 Replies

It’s all a mater of correctly dealing with variable scope. One way could be to access the values directly inside the rollout so that instead of “SPN_W_C_D.value as string” you use “rolloutName.SPN_W_C_D.value as string”; where rolloutName is of course the variable that holds the rollout.

Thanks for the hint. :wavey:

I’ll give it a go.

when using an ini file to store some value, I never could convert it as a float or something different than a string.

but with “execute” it’s working fine.


RC_Menu_Main . SPN_W_C_D.value = (execute(getINISetting INIFilename "Home" "W_C_D"))
 JHN

No need to use execute in this case:


s = "10"
i = s as integer
>> 10

f = s as float
>> 10.0

Avoid execute as long as you can for simple data types and large loops. For something like a matrix3 value in string I think you can only use execute.

-Johan

my bad, I was thinking about booleans.

Actually I’m doing the same with floats or integers

Fe = (getinisetting MyInitest "Section" "Key") as float