Hello readers,
Over the following months I'll be posting some source code examples using my base:library which is available (as an older version which will be shortly updated) on OS4Depot.
The base:library contains many useful functions for creating:
Your always start extraction by skipping over the first 3 lines, in this example we are only defining 1 array so we can safely skip over the first 7 lines to begin at the line:
We then define a While....Wend block to extract the information from the the table line by line. So In the example above we only need to make use of base:GetXMLString and base:GetXMLInteger within the loop.
XML documents can be as complex or simple as you wish, for example in application software you may wish the user to be able to save settings in different areas of the application. Instead of using multiple XML documents you can instead save everything into one single file and define an
<?xml version="1.0" encoding="UTF-8"?> <pobjects version="1.0"> <dict> <key>High Score Table</key> <array> <dict> <key>Name</key> <string>Richard Lake</string> <key>Score</key> <integer>12345678</integer> <key>Name</key> <string>Fred Bloggs</string> <key>Score</key> <integer>12345</integer> </dict> </array> </dict> </pobjects>
<key>Name</key>
<array>
block to each application area.
In the source code provided the While...Wend block only performs extraction top to bottom and line by line with no structural validation taking place. Under normal circumstances, the end user should not have to manually edit XML documents, but XML documents are inheritly plain text so can be easily opened and edited within a simple text editor.
So if you were doing a game with a high score table you'd probably want to compress or encrypt the XML document in someway as well - Hollywood provide functions for this as well which go outside the scope of this blog.
Okay here is the source code example, I hope you will find it of some use in your future projects. Thanks for reading.
Source code
You can find out more writing software for Hollywood on the official forums:
Hollywood forums
Comments
Submitted by trixie on
Submitted by djrikki on
Submitted by trixie on