# NOT RUN {
local(envir=.PBSmodEnv,expr={
#initialize an option manager with a single logical option
.mypkg <- new( "PBSoptions", filename="my_pkg.txt",
initial.options=list( sillyhatday=FALSE ) )
#retrieving an option
silly <- getOptions( .mypkg, "sillyhatday" )
cat( "today is", ifelse( silly, "silly hat day!", "monday" ), "\n" )
#set an option
setOptions( .mypkg, sillyhatday = TRUE, photos = "/shares/silly_hat_photos" )
#create a GUI which works with options
createWin( c(
"check name=optionsillyhatday text=\"silly hat day\"",
"entry name=optionphotos width=22 mode=character label=\"photos directory\"",
"button func=doAction text=save action=saveOptionsGUI(.mypkg)" ), astext = TRUE )
#update GUI values based on values stored in .mypkg's options
loadOptionsGUI( .mypkg )
print(getOptions( .mypkg ))
})
# }
Run the code above in your browser using DataLab