gettingstarted
[Top] [All Lists]

RE: Loading Data

To: "Getting Started" <gettingstarted at lists dot realsoftware dot com>
Subject: RE: Loading Data
From: "Dixon, Tom" <dixont at Jostens dot com>
Date: Sat, 30 Apr 2005 10:01:06 -0500
Delivered-to: gettingstarted at lists dot realsoftware dot com
Thread-index: AcVNH+b1DZdRZ7mcQu2DL+ajNDJgnQAbXmjw
Thread-topic: Loading Data
Brian,

Perhaps it would be better for you if you create string variables as
properties in a Globals module and store your settings there. That way
you can read the settings file and set the global properties and your
edit fields can retrieve the settings from the global variables. You
also may want to take a look at using some modules that are designed to
be used for settings/preferences like XML Preferences by Joseph Sharp.
You can find XML Preferences at RB garage.

Unlike writing a plain text settings file XML Preferences will save your
settings in an XML plist format and uses get and set methods for
variable types including Boolean, String, Integer, Real, Date, Color,
FolderItem and Window.  

It is so painful for me to watch you struggle with what should be
relatively simple code to get working in RB so I am passing on this
little tidbit of advice for your preference file creation. Follow these
instructions:

Download XMLPreferences from RB Garage and import XMLDictionary.rbo and
XMLPreferences.rbo into your project.

If you do not already have a Globals module create one.

Create two global methods, one called LoadPrefs and one called SavePrefs

Create two global String Properties, one called HmPg and one called
WlcmSpch

Create a constant called k_PrefsFileName and set the Type as String,
Value as InternetPal.pref and the Access Scope as Global. If you are
developing cross platform leave the Value blank and set platform
specific values in the constant listbox as follows:

Platform   Language   Value
Macintosh  Default    InternetPal.pref
Windows    Default    InternetPal.ini

In the LoadPrefs method use the following code:

 InitPrefFile(k_PrefsFileName)
 HmPg = GetPrefString("homepage","The default value if prefs don't
exist")
 WlcmSpch= GetPrefString("welcomespeech","The default value if prefs
don't exist")
 settingsWIN.homepage.text = HmPg
 settingsWIN.welcomespeech.text = WlcmSpch

In the SavePrefs method use the following code:

 InitPrefFile(k_PrefsFileName)
 SetPrefString("homepage",HmPg)
 SetPrefString("welcomespeech",WlcmSpch)

You are going to have to figure out for yourself how to make sure the
global properties HmPg and WlcmSpch get updated when they are changed in
your settings window. You are also going to have to figure out when to
call LoadPrefs and SavePrefs.

The great thing I have found about using Joseph Sharp's XMLPreferences
is the capability to store settings properties easily for multiple
variable types. Please read all of the notes and comments so you will
not have to post any questions about using these modules correctly.
Everything you need to know is there and in the RB language reference.

HTH

Tom Dixon

 ______________________________________________________________ 

-----Original Message-----
From: gettingstarted-bounces at lists dot realsoftware dot com
[mailto:gettingstarted-bounces at lists dot realsoftware dot com] On Behalf Of
Brian Heibert
Sent: Friday, April 29, 2005 7:59 PM
To: Getting Started
Subject: Loading Data

I have this in my settings window open event:
  Dim f as folderitem
  Dim t as textinputstream
  f=preferencesfolder.child("InternetPal Settings")
  if f <> Nil then
    t = f.OpenAsTextFile
    t.readline //settingsWIN.homepage.text
    t.readline //settingsWIN.welcomespeech.text
    t.close
  end if
  SettingsWIN.close

And this in the Save button in my settings window:
  Dim f as folderitem
  Dim t as textoutputstream
  f=preferencesfolder.child("InternetPal Settings")
  if f <> Nil then
    t = f.CreateTextFile
    t.writeline settingsWIN.homepage.text
    t.writeline settingsWIN.welcomespeech.text
    t.close
  end if
  SettingsWIN.close

While it does save the file
I am having trouble loading the data and putting it in the proper edit
fields and then using the data like webkit1.loadurl homepage data goes
here

Brian

_______________________________________________
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>

_______________________________________________
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>

<Prev in Thread] Current Thread [Next in Thread>
  • Loading Data, Brian Heibert
    • RE: Loading Data, Dixon, Tom <=