I would NOT recommend using the XML class to read plist files, as plist can be in a variety of formats.
I am sure that I’ve made a feature request somewhere for Xojo to support Apple’s native dictionary serialization. But since I made the feature request, it’ll probably never get added.
It can be done with declares, a sheet-ton of declares or I bet the plugin vendors have a plugin you can buy for it.
I’m sure that there are other workarounds floating around that I don’t know about it.
I had a crack at this but wasted an hour and a half , getting nowhere.
The main problem, to me, is that its a valid but crazy format, where different kinds of things have the same key name.
You cant just XQL for for example … you get Application1 and Visible
To me, Visible and Path are attributes of Application 1
You could brute force this file by reading sequentially from the top down,
finding Application row - then reading until you get a Visible row, then reading the visible state,
then changing the Application on the next one and so on. That assumes that Application as a word appears as the first part of a group.
If it is actually an app name that can be a different form each time, like Banana, it wouldn’t even work like that.
Thanks @Jeff_Tullin,
So, what do you suggest as the ideal structure of the plist to memorize these 3 pieces of information (program name, program path and visibility status)?
XQL gets you an XMLnodelist of all apps
Loop through them, and ask each whether visible or not
mylist = somenode.XQL("//app")
For i as integer = 0 To mylist.Length-1
localappname = mylist.Item(i).GetAttribute("appname")
localvisible = mylist.Item(i).GetAttribute("visible")
next
Yes. I’ve used it for many years. The developer was Floyd Resler. A few years ago I found him on LinkedIn.
Over the years, I’ve updated it a couple of times. While still in the RB days, I had to convert EditField references to TextFields, etc. And (sigh), I eventually bit the bullet and converted it to API2.
Wow, I’ve long wondered who “MacCrafters” was, thanks!
Yes, me too. Added methods for things like appending a dict to another dict, additional constructors (including one where you can pass nil for the target folderitem and it’ll give you a new pList with just headers), a toDictionary method, etc. Also I needed to change all instances of “Chr(13)” to EndofLine.MacOS for some reason, it was long ago…