Tristian,
I'm working on just that sort of thing right now, and got it working for my
type of variables.
I don't know what type of data you are going to save but this may give you
some ideas.
(sample *.ini file and Save and restore code):
Sample ini file:
********************
Machine generated file...Do NOT edit !
UEGO configuration settings:
[RPM]
RPMDROcolor=&hFFFF00
RPMgraphcolor=&hFF0000
RPMgreen_yellowpercent=33
RPMyellow_redpercent=55
MaxRPM=16000
LogTriggerRPM=12345
StatusRPM=True
[Colors]
AFRDROcolor=&h000000
EGTDROcolor=&h000000
.
.
.
**********************
SAVE-code:
**********************
Dim TempOut As Variant 'For crosslinking datatypes
Dim ConfigFile As FolderItem
Dim fileStream As TextOutputStream
ConfigFile=GetFolderItem("config.ini")
fileStream=ConfigFile.CreateTextFile
'------------- Header ----------------------------------------------
fileStream.WriteLine "Machine generated file...Do NOT edit !"
fileStream.WriteLine "UEGO configuration settings:"
fileStream.WriteLine ""
'-------------------------------------------------------------------
'
'-------------------
fileStream.WriteLine "[RPM]"
TempOut=RPMDROcolor
fileStream.WriteLine "RPMDROcolor="+TempOut.stringvalue
TempOut=RPMgraphcolor
fileStream.WriteLine "RPMgraphcolor="+TempOut.stringvalue
TempOut=RPMgreen_yellowpercent
fileStream.WriteLine "RPMgreen_yellowpercent="+TempOut.stringvalue
TempOut=RPMyellow_redpercent
fileStream.WriteLine "RPMyellow_redpercent="+TempOut.stringvalue
TempOut=MaxRPM
fileStream.WriteLine "MaxRPM="+TempOut.stringvalue
TempOut=LogTriggerRPM
fileStream.WriteLine "LogTriggerRPM="+TempOut.stringvalue
TempOut=StatusRPM
fileStream.WriteLine "StatusRPM="+TempOut.stringvalue
'-------------------
fileStream.WriteLine "" 'Separate the sections
fileStream.WriteLine "[Colors]"
TempOut=AFRDROcolor
fileStream.WriteLine "AFRDROcolor="+TempOut.stringvalue
TempOut=EGTDROcolor
fileStream.WriteLine "EGTDROcolor="+TempOut.stringvalue
TempOut=CH1DROcolor
'
'
'
*********************
RESTORE-code:
********************
Dim ConfigFile as FolderItem
Dim stream as TextInputStream
Dim TempIn As Variant 'For crosslinking datatypes
'---------
ConfigFile=GetFolderItem("config.ini")
If ConfigFile = Nil then
MsgBox "config.ini not found !"
Else
If not ConfigFile.Exists then
MsgBox "config.ini not found !"
Else
'----------------------------------
stream = ConfigFile.OpenAsTextFile
TempIn=stream.ReadLine 'Skip the headers
TempIn=stream.ReadLine
'
TempIn=stream.ReadLine 'section
separator
'----------- RPM -------------------------------------
TempIn=stream.ReadLine
'
TempIn=stream.ReadLine 'Read next
record from file
TempIn=Right(TempIn,8) 'Extract the
data
RPMDROcolor=TempIn.colorValue '---- MOVE TO
VARIABLES ----
RPMDROcolorCounter=ColorArray.IndexOf(TempIn)
'
TempIn=stream.ReadLine 'Read next
record from file
TempIn=Right(TempIn,8) 'Extract the
data
RPMgraphcolor=TempIn.colorValue '---- MOVE TO
VARIABLES ----
StaticRPM.TextColor=TempIn
RPMgraphcolorcounter=ColorArray.IndexOf(TempIn)
'
TempIn=stream.ReadLine 'Read next
record from file
TempIn=Right(TempIn,(Len(TempIn)-InStr(TempIn,"="))) 'Extract data
right of "="
RPMgreen_yellowpercent=val(TempIn) '---- MOVE TO
VARIABLES ----
'
TempIn=stream.ReadLine 'Read next
record from file
TempIn=Right(TempIn,(Len(TempIn)-InStr(TempIn,"="))) 'Extract data
right of "="
RPMyellow_redpercent=val(TempIn) '---- MOVE TO
VARIABLES ----
'
TempIn=stream.ReadLine 'Read next
record from file
TempIn=Right(TempIn,(Len(TempIn)-InStr(TempIn,"="))) 'Extract data
right of "="
MaxRPM=val(TempIn) '---- MOVE TO
VARIABLES ----
'
TempIn=stream.ReadLine 'Read next
record from file
TempIn=Right(TempIn,(Len(TempIn)-InStr(TempIn,"="))) 'Extract data
right of "="
LogTriggerRPM=val(TempIn) '---- MOVE TO
VARIABLES ----
'
TempIn=stream.ReadLine 'Read next
record from file
TempIn=Right(TempIn,(Len(TempIn)-InStr(TempIn,"="))) 'Extract data
right of "="
StatusRPM=TempIn '---- MOVE TO
VARIABLES ----
If StatusRPM=True Then 'Button IN and Light ON
BButtonRPM.value=True
LightON=NewPicture(BButtonRPM.width,BButtonRPM.height,16)
LightON.graphics.ForeColor=ButtLightColor ' Lightcolor:Light Amber
LightON.graphics.FillRect 0,0,(BButtonRPM.width,BButtonRPM.height)
BButtonRPM.icon=LightON
Else 'Button OUT and Light OFF
BButtonRPM.value=False
LightOFF=NewPicture(BButtonRPM.width,BButtonRPM.height,16)
LightOFF.graphics.ForeColor=ButtDarkColor 'Windows Standard Gray
LightOFF.graphics.FillRect 0,0,(BButtonRPM.width,BButtonRPM.height)
BButtonRPM.icon=LightOFF
End If
'------------------------------------------------------
'
'
'
'
************************
Hope This Helps
Tristan wrote:
> I know that many programs have preferences that stay at the value that
> the user wants instead of reverting to the defaults. Is it possible for
> me to do this in REALBasic? If so, HOW?
>
> Thx,
> Tbg10101
--
*******************************************
VISIT MY HOME PAGE:
<http://home.online.no/~eikarlse/index.htm>
LAST UPDATED: 23/08/2003
*******************************************
Regards
Eirik Karlsen
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
|