:script saving system
:base
:help.m


eval addhelp fsave&fsave&saves current format settings.
alias fsave {
	if (fexist($fsavefile)) {
		@ rename($fsavefile $(fsavefile)~)
	}
        @ :thsave = open($twiddle($(fsavefile)) W T)
	@ write($thsave @actionform=[$actionform])
	@ write($thsave @abotform=[$abotform])
	@ write($thsave @awayform=[$awayform])
	@ write($thsave @boxesform=[$boxesform])
	@ write($thsave @cdccform=[$cdccform])
	@ write($thsave @colorsform=[$colorsform])
	@ write($thsave @ctcpform=[$ctcpform])
	@ write($thsave @ctcprform=[$ctcprform])
	@ write($thsave @dccform=[$dccform])
	@ write($thsave @estringform=[$estringform])
	@ write($thsave @joinform=[$joinform])
	@ write($thsave @killform=[$killform])
	@ write($thsave @kickform=[$kickform])
	@ write($thsave @kstringform=[$kstringform])	
	@ write($thsave @modeform=[$modeform])
	@ write($thsave @msgform=[$msgform])
	@ write($thsave @ncompform=[$ncompform])
	@ write($thsave @nickform=[$nickform])
	@ write($thsave @noticeform=[$noticeform])
	@ write($thsave @partform=[$partform])
	@ write($thsave @pubform=[$pubform])
	@ write($thsave @qstringform=[$qstringform])
	@ write($thsave @quitform=[$quitform])
	@ write($thsave @sactionform=[$sactionform])
	@ write($thsave @sbarform=[$sbarform])
	@ write($thsave @scform=[$scform])
	@ write($thsave @sctcpform=[$sctcpform])
	@ write($thsave @sdccform=[$sdccform])
	@ write($thsave @smsgform=[$smsgform])
	@ write($thsave @snoticeform=[$snoticeform])
	@ write($thsave @spubform=[$spubform])
	@ write($thsave @svform=[$svform])
	@ write($thsave @wallform=[$wallform])
	@ write($thsave @whoisform=[$whoisform])
	@ write($thsave @c1=[$c1)
	@ write($thsave @c2=[$c2)
	@ write($thsave @c3=[$c3)
	@ write($thsave @c4=[$c4)
	@ close($thsave)
	xecho -b saved format info to file $(c4)[$(c2)$(fsavefile)$(c4)]
        ^restub fsave save.m
}
eval addhelp csave&csave&saves script settings
alias csave {
        if (fexist($csavefile)) {
                @ rename($csavefile $(csavefile)~)
        }
        @ :thsave = open($twiddle($(csavefile)) W T)
        for (@i = 1,getitem(set $i),@ i++) {
		@write($thsave @ $before(& $getitem(set $i)) = [$($before(& $getitem(set $i)))])
        }
	@ close($thsave)
        xecho -b saved core settings info to file $(c4)[$(c2)$(csavefile)$(c4)]
	^assign -thsave
        ^restub csave save.m
}
eval addhelp saveall&saveall&saves all client and script settings.
alias saveall {
	^csave
	^fsave
	^save
	xecho -b all client and script settings have been saved.
        ^restub saveall save.m
}
on ^exit "*" {
	if (autosave == [on]) {
		saveall
	}
	if (autocdcc == [on]) {
		^cdcc save
	}
}