PDA

View Full Version : Save spinner Settings - revisited


craigpmiller
11-26-2009, 12:06 AM
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 ... :cry:
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?

MarcoBrunetta
11-26-2009, 11:47 AM
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.

craigpmiller
11-27-2009, 12:30 AM
Thanks for the hint. :wavey:

I'll give it a go.:thumbsup:

holycause
11-27-2009, 07:17 AM
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
11-27-2009, 07:31 AM
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

holycause
11-27-2009, 08:03 AM
my bad, I was thinking about booleans.

Actually I'm doing the same with floats or integers

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

CGTalk Moderation
11-27-2009, 08:03 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.