Platforms to show: All Mac Windows Linux Cross-Platform

Back to ResourceForkMBS class.

ResourceForkMBS.AddResource(Data as Memoryblock, ResourceType as String, ID as Integer, Name as String)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS MacClassic Plugin 13.0 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Adds a resource of the Type specified, using the Name and ID specified and fills it with the Data specified.

We added this method to avoid extra conversion from memoryblock to string when adding data.

See also:

ResourceForkMBS.AddResource(Data as String, ResourceType as String, ID as Integer, Name as String)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS MacClassic Plugin 13.0 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Adds a resource of the Type specified, using the Name and ID specified and fills it with the Data specified.
Example
dim f as FolderItem = SpecialFolder.Desktop.Child("test.rsrc")
dim r as ResourceForkMBS = ResourceForkMBS.Create(f)

r.AddResource "Hello World", "TEXT", 128, "just a test"

See also:

ResourceForkMBS.Close

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS MacClassic Plugin 13.0 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Closes the open resource fork.

The resource fork will be closed automatically when the instance is destroyed.

ResourceForkMBS.Constructor   Private

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS MacClassic Plugin 13.0 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
The private constructor.

ResourceForkMBS.GetIndResource(ResourceType as String, index as Integer) As String

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS MacClassic Plugin 13.0 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns the specified resource as a string.
Example
dim f as FolderItem = SpecialFolder.Desktop.Child("test.rsrc")
dim r as ResourceForkMBS = ResourceForkMBS.create(f)

r.AddResource "Hello World", "TEXT", 128, "just a test"

dim s as string = r.GetIndResource("TEXT", 0)
MsgBox s

Index is zero based.

ResourceForkMBS.GetNamedResource(ResourceType as String, Name as String) As String

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS MacClassic Plugin 13.0 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns the specified resource as a string.
Example
dim f as FolderItem = SpecialFolder.Desktop.Child("test.rsrc")
dim r as ResourceForkMBS = ResourceForkMBS.create(f)

r.AddResource "Hello World", "TEXT", 128, "just a test"

dim s as string = r.GetNamedResource("TEXT", "just a test")
MsgBox s

ResourceForkMBS.GetResource(ResourceType as String, ID as Integer) As String

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS MacClassic Plugin 13.0 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns the specified resource as a string.
Example
dim f as FolderItem = SpecialFolder.Desktop.Child("test.rsrc")
dim r as ResourceForkMBS = ResourceForkMBS.create(f)

r.AddResource "Hello World", "TEXT", 128, "just a test"

dim s as string = r.GetResource("TEXT", 128)
MsgBox s

Some examples using this method:

ResourceForkMBS.GetResourceMemory(ResourceType as String, ID as Integer) As Memoryblock

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS MacClassic Plugin 13.0 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns the specified resource as a Memoryblock.
Example
dim f as FolderItem = SpecialFolder.Desktop.Child("test.rsrc")
dim r as ResourceForkMBS = ResourceForkMBS.create(f)

r.AddResource "Hello World", "TEXT", 128, "just a test"

dim s as MemoryBlock = r.GetResourceMemory("TEXT", 128)
MsgBox s

ResourceForkMBS.RemoveResource(ResourceType as String, ID as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS MacClassic Plugin 13.0 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Removes the specified resource from the resource fork.
Example
dim f as FolderItem = SpecialFolder.Desktop.Child("test.rsrc")
dim r as ResourceForkMBS = ResourceForkMBS.Create(f)

r.AddResource "Hello World", "TEXT", 128, "just a test"
MsgBox str(r.TypeCount)+" resources"
r.RemoveResource "TEXT", 128
MsgBox str(r.TypeCount)+" resources"

ResourceForkMBS.ResourceAttributes(ResourceType as String, ID as Integer) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Files MBS MacClassic Plugin 13.0 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Get or set all resource attributes together.
Example
dim f as FolderItem = SpecialFolder.Desktop.Child("test.rsrc")
dim r as ResourceForkMBS = ResourceForkMBS.Create(f)

r.AddResource "Hello World", "TEXT", 128, "just a test"

MsgBox str(r.ResourceAttributes("TEXT", 128))
// shows 2 which means it has been changed and need to be written to disk soon

(Read and Write computed property)

ResourceForkMBS.ResourceCount(ResourceType as String) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS MacClassic Plugin 13.0 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns the number of resources of the specified type.
Example
dim f as FolderItem = SpecialFolder.Desktop.Child("test.rsrc")
dim r as ResourceForkMBS = ResourceForkMBS.create(f)

r.AddResource "Hello World", "TEXT", 128, "just a test"

MsgBox str(r.ResourceCount("TEXT")) // shows 1

ResourceForkMBS.ResourceID(ResourceType as String, index as Integer) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS MacClassic Plugin 13.0 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns the resource ID as an Integer based on the Type and Index passed.
Example
dim f as FolderItem = SpecialFolder.Desktop.Child("test.rsrc")
dim r as ResourceForkMBS = ResourceForkMBS.Create(f)

r.AddResource "Hello World", "TEXT", 128, "just a test"

MsgBox str(r.ResourceID("TEXT", 0)) // shows 128

This list is zero-based.

ResourceForkMBS.ResourceLocked(ResourceType as String, ID as Integer) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Files MBS MacClassic Plugin 13.0 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Used to get and set the locked attribute of the resource.

(Read and Write computed property)

ResourceForkMBS.ResourceName(ResourceType as String, index as Integer) As String

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS MacClassic Plugin 13.0 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns the resource name as a string based on the Type and the zero-based index to that type.
Example
dim f as FolderItem = SpecialFolder.Desktop.Child("test.rsrc")
dim r as ResourceForkMBS = ResourceForkMBS.Create(f)

r.AddResource "Hello World", "TEXT", 128, "just a test"

MsgBox r.ResourceName("TEXT", 0)

ResourceForkMBS.ResourcePreload(ResourceType as String, ID as Integer) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Files MBS MacClassic Plugin 13.0 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Used to get and set the Preload attribute of the resource.

(Read and Write computed property)

ResourceForkMBS.ResourceProtected(ResourceType as String, ID as Integer) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Files MBS MacClassic Plugin 13.0 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Used to get and set the Protected attribute of the resource.

(Read and Write computed property)

ResourceForkMBS.ResourcePurgeable(ResourceType as String, ID as Integer) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Files MBS MacClassic Plugin 13.0 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Used to get and set the Purgeable attribute of the resource.

(Read and Write computed property)

ResourceForkMBS.ResourceSizeOnDisk(ResourceType as String, ID as Integer) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS MacClassic Plugin 13.0 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Queries the size on disk for a given resource.
Example
dim f as FolderItem = SpecialFolder.Desktop.Child("test.rsrc")
dim r as ResourceForkMBS = ResourceForkMBS.Create(f)

r.AddResource "Hello World", "TEXT", 128, "just a test"
MsgBox str(r.ResourceSizeOnDisk("TEXT", 128))+" bytes"

ResourceForkMBS.ResourceSysHeap(ResourceType as String, ID as Integer) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Files MBS MacClassic Plugin 13.0 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Used to get and set the SysHeap attribute of the resource.

(Read and Write computed property)

ResourceForkMBS.ResourceType(index as Integer) As String

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS MacClassic Plugin 13.0 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns the resource type as a string based on the Index passed.
Example
dim f as FolderItem = SpecialFolder.Desktop.Child("test.rsrc")
dim r as ResourceForkMBS = ResourceForkMBS.create(f)

r.AddResource "Hello World", "TEXT", 128, "just a test"

MsgBox r.ResourceType(0)

This list is zero-based.

ResourceForkMBS.UniqueID(ResourceType as String) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS MacClassic Plugin 13.0 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Finds an unique ID for a given resource type.
Example
dim f as FolderItem = SpecialFolder.Desktop.Child("test.rsrc")
dim r as ResourceForkMBS = ResourceForkMBS.create(f)

MsgBox str(R.UniqueID("TEXT"))

The items on this page are in the following plugins: MBS MacClassic Plugin.


The biggest plugin in space...