FullResDump! Using Mac Resource Forks the Hard Way!

Deploying to Mac OS? Ask Mac OS specific questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
PaulDaMacMan
Posts: 683
Joined: Wed Apr 24, 2013 4:53 pm
Contact:

FullResDump! Using Mac Resource Forks the Hard Way!

Post by PaulDaMacMan » Tue Apr 29, 2014 7:56 am

So, I've really been getting into LiveCode lately and have set out to bringing my old Hypercard projects into this century. When I realized how much I relied on Externals (XCMDs/XFCNs) back then, I decided I would try to replace those externals with my own native functions and commands. I used a lot of Frederic Rinaldi's externals and did a lot of moving stuff in and out of the mac resource forks in particular (GetRes, resText, textRes, fullResSomethingOrOther). I found resfile:/ url syntax in the LC dictionary and had already been playing with binfile: parsing a bit, The end result was a stack that decodes / dumps all of a Mac files resource fork data into a field whilst labeling it and such. Parsing the res-fork raw based on some old scanned pages from "Inside The Macintosh". Half way though this project I suddenly found the copyResource, deleteResource, getResource, getResources, and setResource syntax in the LC dictionary! UH DUH!!! Wow, did I feel stupid and angry at myself for wasting my time, but decided to finish it anyway! Here it is, "FullResForkDump". If nothing else it is a good example of using the binaryDecode function.
Attachments
ResForkDumper-final.livecode.zip
FullResForkDump - Resource Fork Parsing the hard way!
(3.97 KiB) Downloaded 389 times

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: FullResDump! Using Mac Resource Forks the Hard Way!

Post by jacque » Tue Apr 29, 2014 5:00 pm

I think if you keep searching a bit you'll find you don't need almost any of those externals any more. Virtually everything we needed externals for in HC is built into LC natively.

If you feel like giving us a list of the ones you need, we can tell you the native syntax.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10053
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: FullResDump! Using Mac Resource Forks the Hard Way!

Post by FourthWorld » Wed Apr 30, 2014 6:13 am

You may rarely ever need externals or resource forks anymore, but learning how to use binaryDecode will be very valuable for years to come. Congrats..
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

PaulDaMacMan
Posts: 683
Joined: Wed Apr 24, 2013 4:53 pm
Contact:

Re: FullResDump! Using Mac Resource Forks the Hard Way!

Post by PaulDaMacMan » Wed Apr 30, 2014 4:13 pm

While LC's dictionary is way more robust in many respects then HC's, I already know that I will need externals!

One of my other hobbies is Music creation and I used to play around with Ear-Level Training's (free) HyperMIDI xcmd a lot! I know of only one (commercial, Mac only) LC external that deals with MIDI, and LC has absolutely zero musical notation abilities built-in (not even HyperCard's play notes...Ab,B,C#). I have been using UDI's (free, public domain) Metacard MIDI file lib PMD/makeSMF (reading MIDI files is broken, maybe I can fix it). I've even made some mods to make it work on Android. However, it relies on external engines for playback. The problem with that is QuickTime X has removed it's built-in GM/GS MIDI Synth so now it only works if QuickTime 7.x or lower is installed! I've been trying to use shell() and launch process / open process for update in conjunction with the open-source FluidSynth or MyMIDIApp CLI apps which sort-of works but it's a messy solution and introduces extra latency (a no-no for music).

What about using USB-HID controllers? I'm sure I could think of many more, but those are at the top of my list.
I'd love to see someone wrap some key parts of the SDL.framework into an LC External!
My GitHub Repos: https://github.com/PaulMcClernan/
Related YouTube Videos: PlayList

PaulDaMacMan
Posts: 683
Joined: Wed Apr 24, 2013 4:53 pm
Contact:

Re: FullResDump! Using Mac Resource Forks the Hard Way!

Post by PaulDaMacMan » Wed Apr 30, 2014 4:39 pm

...And I know resource forks have been discouraged / deprecated for a long time but one of my old projects that I'm trying to revive did stuff with the postscript embedded in the resource fork of mac formatted type-1 fonts. I work in the print industry and I can tell you resource-fork based Mac fonts haven't come close to going away yet (though my project could help that happen).
My GitHub Repos: https://github.com/PaulMcClernan/
Related YouTube Videos: PlayList

PaulDaMacMan
Posts: 683
Joined: Wed Apr 24, 2013 4:53 pm
Contact:

Re: FullResDump! Using Mac Resource Forks the Hard Way!

Post by PaulDaMacMan » Wed Apr 30, 2014 4:51 pm

If anyone knows of a CLI app that can play a MIDI file out though a switch selectable CoreMIDI device (and Ideally record as well, though I'm less interested in live performances then I am in algorithmic composition) that would be really helpful... Some of the other options I'm looking at now are LC+Java's Music and LC+PD (PureData, it's a descendent of MAX)
My GitHub Repos: https://github.com/PaulMcClernan/
Related YouTube Videos: PlayList

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: FullResDump! Using Mac Resource Forks the Hard Way!

Post by jacque » Wed Apr 30, 2014 6:32 pm

Yup, you need an external, you're right. You're one of those "special needs" programmers. :)

Sorry, I don't know of any MIDI externals except for SUNNY, which you already know about.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: FullResDump! Using Mac Resource Forks the Hard Way!

Post by bn » Wed Apr 30, 2014 8:28 pm

Hi Paul,

thanks for posting this example of decoding binary data.

I pray I never have to do it but if it ever happens your example is very clear and well documented. It should help me to decode binary data of different sources.

Kind regards

Bernd

PaulDaMacMan
Posts: 683
Joined: Wed Apr 24, 2013 4:53 pm
Contact:

Re: FullResDump! Using Mac Resource Forks the Hard Way!

Post by PaulDaMacMan » Fri May 02, 2014 5:21 am

@ bn
You're welcome. binaryDecode is extremely useful! I hope more people will share their scripts.

Note about binaryDecode: while playing around it I noticed some flakiness. Sometimes I had to break the calls into separate lines with fewer different data types or it wouldn't return the correct values (CCCm3M to just CCC for example). I was checking it against other Resourcer and other apps. But that was OK because my variables names were so long you would've had to scroll a lot to read it anyway!

@ jacque
I don't know if Music/composition and education should be considered a "special need" and USB-HID is for game-controllers (definitely should not be considered a "special need")
Sunny external looks pretty good but it's not compatible with LC Community Edition (locked scripts) so I can't try it (maybe someday I'll get a Commercial LC license)! And I don't know if it's worth the money to me anyway. Seems like the basic (50$) version uses QT Instruments and I have my doubts about the future of QuckTime.
My GitHub Repos: https://github.com/PaulMcClernan/
Related YouTube Videos: PlayList

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: FullResDump! Using Mac Resource Forks the Hard Way!

Post by jacque » Fri May 02, 2014 4:27 pm

Music isn't a special need, but writing a stack that requires an external is. ;)

There are so few stacks that really do need externals, that if one shows up, the stack is special. This one sounds very special, and a bit ambitious too. Good luck!
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply