I’m inserting Xojo comments into the code, explaining what each line does, but this is all stuff you can get from the user guide and the language reference.
// allocate a new file object instance
Dim f As FolderItem
// assign the file named "hello.mp3" to it
// the file would have to exist in the same
// folder as your Xojo app
f = GetFolderItem(“hello.mp3”)
// make sure the file object was created
// and that it exists
If f <> Nil And f.Exists Then
// create an instance of the sound object
Dim s As Sound
// open the file instance as a sound and
// put it into the sound instance
s = f.OpenAsSound
// play the sound
// end the If block from above
FWIW, I did a lot of AppleScript programming 20 years ago, but I outgrew its capabilities, so I know where you are coming from.
That said, I understand that you’re frustrated and want this to work now, but you cannot short circuit the learning process of going from AppleScript to an object-oriented language like Xojo. There’s going to be a learning curve. I suggest you start here
To learn the relevant concepts in Xojo and object oriented programming.
I feel it’s also important to point out that programming is not something where someone can give you a step-by-step instruction on how to attack a problem because those instructions will only serve you once or twice in the long run. Sure you can create libraries of code that you call into, but the issue that you are running into right now, that you are new to the language and you can’t read and understand the examples yet is going to cause you (and the people trying to help you) a lot of pain and frustration.
Everyone on this forum is here by choice… including the Xojo employees that you see from time to time like me. But keep in mind that most people have learned that if you don’t help the user learn by discovering instead of just giving them the code means that when they run into the next problem, they’ll be back for another “code snippet”. What this leads to is an app that’s written by the community, that you don’t understand and if you have any bugs, you have to go back to the forum for debugging help.