Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
quick and dirty settings
#3
(07-08-2015, 05:48 AM)lelldorin Wrote: Why you des not use attributes?

Code:
//Creating Settings file
SettingsFile$ = "/boot/home/config/settings/Trope/Trope.settings"

SettingsWindowX=WINDOW GET "MainWindow", "position-x"
SettingsWindowY=WINDOW GET "MainWindow", "position-y"
SettingsWindowWidth=WINDOW GET "MainWindow", "width"
SettingsWindowHeight=WINDOW GET "MainWindow", "height"

WordWrap = 0
Backup = 0
Toolbar = 1

writefile = open(SettingsFile$, "a")
    Output$=System$("addattr -t string WindowX str$(SettingsWindowX)+" "+SettingsFile$)
        Output$=System$("addattr -t string WindowY str$(SettingsWindowY)+" "+SettingsFile$)
        Output$=System$("addattr -t string WindowWidth str$(SettingsWindowWidth)+" "+SettingsFile$)
        Output$=System$("addattr -t string WindowHeight str$(SettingsWindowHeight)+" "+SettingsFile$)
        Output$=System$("addattr -t string WordWrap str$(WordWrap )+" "+SettingsFile$)
        Output$=System$("addattr -t string Backup str$(Backup )+" "+SettingsFile$)
        Output$=System$("addattr -t string Toolbar str$(Toolbar )+" "+SettingsFile$)
close(writefile)

//Read Settings
SettingsWindowX=val(System$("catattr -d WindowX "+SettingsFile$))
SettingsWindowY =val(System$("catattr -d WindowY "+SettingsFile$))
SettingsWindowWidth=val(System$("catattr -d WindowWidth"+SettingsFile$))
SettingsWindowHeight =val(System$("catattr -d WindowHeight "+SettingsFile$))
WordWrap=val(System$("catattr -d WordWrap"+SettingsFile$))
Backup=val(System$("catattr -d Backup "+SettingsFile$))
Toolbar=val(System$("catattr -d Toolbar "+SettingsFile$))

Its out of my mind, i hope i does not add any bug
[/code]
or better:

Code:
sub GetSettings()
writefile = open(SettingsFile$, "a")
close(writefile)
local tempval$
tempval$ = attribute get$ "", SettingsFile$
if  not instr(tempval$,"WindowX") then
    return
else
    xorigin= val(attribute get$ "WindowX",SettingsFile$)
    yorigin = val(attribute get$ "WindowY",SettingsFile$)
    xwidth = val(attribute get$ "WindowWidth",SettingsFile$)
    yheight = val(attribute get$ "WindowHeight",SettingsFile$)
    WordWrap =  val(attribute get$ "WordWrap",SettingsFile$)
    Backup =  val(attribute get$ "Backup",SettingsFile$)
    Toolbar = val(attribute get$ "Toolbar",SettingsFile$)
end if




sub SaveSettings()
writefile = open(SettingsFile$, "a")
close(writefile)

        attribute set "string", "WindowX", str$(window get "MainWindow", "position-x"),SettingsFile$
        attribute set "string", "WindowY", str$(window get "MainWindow", "position-y"),SettingsFile$
        attribute set "string", "WindowWidth", str$( window get "MainWindow", "width"),SettingsFile$
        attribute set "string", "WindowHeight", str$( window get "MainWindow", "height"),SettingsFile$
        attribute set "string", "WordWrap", str$(WordWrap),SettingsFile$
        attribute set "string", "Backup", str$(Backup),SettingsFile$
        attribute set "string", "Toolbar", str$(Toolbar),SettingsFile$

end sub
Reply


Messages In This Thread
quick and dirty settings - by clasqm - 07-06-2015, 10:55 AM
RE: quick and dirty settings - by lelldorin - 07-08-2015, 05:48 AM
RE: quick and dirty settings - by bbjimmy - 07-08-2015, 06:33 AM
RE: quick and dirty settings - by clasqm - 07-08-2015, 08:59 PM
RE: quick and dirty settings - by lelldorin - 07-08-2015, 10:12 PM
RE: quick and dirty settings - by bbjimmy - 07-09-2015, 03:05 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)
Free Web Hosting