We will be undergoing scheduled maintenance on May 20th, 2013 at 02:00 GMT.
Visitors to VTC.com will be able to view all introductory videos for each training course.
Free Trial Members will gain access to first three chapters for each training course.
Full Access Members have full access to VTC.com�s entire library of video tutorials.
Now we will add the ability to Save our Preferences settings to an XML file. Let's Open our Preferences Module, first we will Add a Constant to contain the name of the Preferences file. We are saving the Preferences to an XML file because XML is a very flexible file format that is ideally suited for saving Preferences and because REAL Studio has built-in commands for processing XML files. Now in order to access the XML file we're going to need two methods, one to Load the Preferences from the XML file and one to Save the Preferences to an XML file. I've previously created these methods which we will add now, let's start with Load. And this is the Load Method, you can see the first thing it does is Create the actual Preferences Folder item using the REAL Studio Preferences Value of the Special Folder Class. This allows the Preferences file to be stored in the appropriate place for the operating system depending on where it's identified Preferences files, for example on Mac OS X this would be in the User Library Preferences folder. This is an Instance Variable though so we should Add that, and it is Private. If our XML file exists then we will attempt to load it, we've wrapped this in a Try-Catch Block in case the XML file becomes invalid for any reason, this is just to prevent unnecessary crashes in the application. We Create a new XML Document and we Load our file, assuming that there was no exception and the XML file is valid we can now loop through the contents of the XML and Assign our Properties. So we check for the first node and we check each node I should say, now the order is not going to matter so we loop through each node of the XML file, if the Node Name matches this then we know it contains the Setting for our Use Row Alternate Row Highlighting Preference and we set it accordingly. If the Node Name is this then we know it contains the Alert Minutes Value and we set that accordingly. Now let's look at the Save method, here we just Save the Preferences into the XML file, so we Create a New XML file or a new XML Document and we Assign the Alert Minutes to a Node and we Assign the Alternate Row Highlighting to a Node and then we Save this Preferences file. Now in order to Save and Load the Preferences we need to actually Call these Methods, we will do this on the Open Event of the App Class. We will call it Preferences.Load when the application starts and we will call it Preferences.Save when the application closes. Now let's Run the Application, you can see we have our settings here, let's Set it to 30 minutes and Check this, now we can Quit the Application and Rerun it and you will see that the settings have been retained. If you would go to your file system Library-Preferences you will find the two new Preferences file out there, Double-clicking it will show you what the XML looks like, unfortunately it is not nicely formatted so we'll have to add a few line breaks so we can read it. But you can see this very simple XML file format has our Alert Minutes Setting, and our Use Alternate Row Highlighting Setting. Lastly, we actually want to make the Todo Window respect our Use Alternate Row Highlighting Setting, so we need to Open up the Base Class which you can check by clicking on the window and you'll remember we created a Listbox Control Subclass, and here we can just say-so it will only attempt to Alternate Highlight the Rows if the Preferences has been set. Now if we go and uncheck that the highlighting has disappeared.
| Course: | Real Studio |
| Author: | Paul Lefebvre |
| SKU: | 34190 |
| ISBN: | 1-936334-77-1 |
| Release Date: | 2011-02-02 |
| Duration: | 7 hrs / 87 lessons |
| Work Files: |
Yes |
| Captions: | No |
| Compatibility: |
Vista/XP/2000, OS X, Linux QuickTime 7, Flash 8 |