O'Reilly logo

REALBasic: TDG, 2nd Edition by Matt Neuburg

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Predefined Data Formats

So far in this chapter, all writing and reading of data has basically been at the level of individual bytes. You can read and write these bytes as numbers and strings, but interpreting them is ultimately up to you. However, there are some types of data where mere bytes won’t do you any good. Therefore, REALbasic also stands ready to translate between a few standard data formats and its own datatypes.

Sounds

A type 1 System 7 sound is a 'snd' resource. To obtain such a resource as a REALbasic Sound object that REALbasic can play, send a ResourceFork the GetSound message, handing it the resource’s ID as a parameter.

If the resource lives in a System 7 sound file (of type "sfil/movr"), you can save a step; send a FolderItem the OpenAsSound message.

Unfortunately, the GetSound message assumes that you know the 'snd' resource’s ID number. Often, this is just what you don’t know; you know its name instead. In such a case, you’ll have to cycle through all the 'snd' resources, looking for the one with the right name, in order to obtain its ID number. It’s easy to see how to do this by adapting the code from the end of Section 21.6.2, earlier in this chapter.

See Chapter 26 for more about sounds.

Pictures

To obtain a 'PICT' resource as a REALbasic Picture object, send a ResourceFork the GetPicture message, supplying the resource’s ID, or the GetNamedPicture message, supplying the resource’s name.

To obtain an icon resource as a REALbasic Picture object, send a ResourceFork ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required