news
About Elegant Chaos
info
About me and my friends
people
Software from Elegant Chaos
software
Other stuff...
stuff

Rezzer

This XFCN does all sorts of utility things with resources, including moving them from stack to stack, and returning lists of them.

Rezzer XFCN. Version 1.0, by Sam Deane. Copyright ©1994 ULTRALAB. Compiled 16:57:54, 28/04/94.


[last exit to hypercard] [externals index] [download Rezzer]

Description

This XFCN contains a number of utilities for manipulating resources of various kinds.

You can obtain a list of all resources, and all types of resource present, either in the current stack or in all stacks in the inheritance path.

You can rename, renumber, copy and delete resources, and test whether a particular resource is present.

You can also use this XCMD to manipulate TEXT/styl resources, by getting and setting their contents.


Commands

save

This command is used in conjunction with the handle command to save resources in to the current stack.

The syntax is:

  get Rezzer("save",<handle>,<name>)

The <handle> parameter should be a handle to some resource, as returned by the handle command.

The <name> parameter should be the name or id to use for the new resource.

all

This command returns a list of all of the resources of a given resource type. It looks for all resources available to the current stack: ie those stored in the current stack, any stacks in the stacksInUse, the home stack, or the system.

The syntax is:

  get Rezzer("all",<type>)

The <type> parameter should be a four letter resource type, for example PICT for picture resources.

The result is returned as a list, with one line for each resource found. Each line contains two items: the name of the resource and its id.

Example script for all

on mouseUp
  ask "Type?"
  if it is not empty then
    ShowResult "Resources of type " & it,Rezzer(all,it)
  end if
end mouseUp

list

This command returns a list of all of the resources of a given resource type. It only lists the resources stored in the current stack.

The syntax is:

  get Rezzer("list",<type>)

The <type> parameter should be a four letter resource type, for example PICT for picture resources.

The result is returned as a list, with one line for each resource found. Each line consists of two items: the name of the resource, and its id.

Example script for list

on mouseUp
  ask "Type?"
  if it is not empty then
    ShowResult "Resources of type " & it,Rezzer(list,it)
  end if
end mouseUp

types

This command returns a list of all of the types of resources that are stored in the current stack.

The syntax is:

  get Rezzer("types")

The result is returned as a comma-delimited list of resource types.

Example script for types

on mouseUp
  ShowResult "Resources types in stack",Rezzer(types)
end mouseUp

rename

This command allows you to rename an existing resource.

The syntax is:

  get Rezzer("rename",<name>,<type>,<newname>)

The <name> parameter should be the name or id of an existing resource.

The <type> parameter should be a four letter resource type.

The <newname> parameter should contain the new name of the resource. Note that this command does not check for duplicate names, so that it is possible to give two or more resources the same name.

Example script for rename

on mouseDown
  ask "name, kind, new name?"
  if the number of items in it is 3 then
    put item 1 of it into oldname
    put item 2 of it into type
    put item 3 of it into newname
    
    get Rezzer(rename,oldname,type,newname)
    get Rezzer(list,type)
    answer it
  end if
end mouseDown

renumber

This command allows you to renumber an existing resource.

The syntax is:

  get Rezzer("renumber",<name>,<type>,<newnumber>)

The <name> parameter should be the name or id of an existing resource.

The <type> parameter should be a four letter resource type.

The <newnumber> parameter should contain the new id of the resource.

Example script for renumber

on mouseDown
  ask "name, kind, new id?"
  if the number of items in it is 3 then
    put item 1 of it into oldname
    put item 2 of it into type
    put item 3 of it into newid
    
    get Rezzer(renumber,oldname,type,newid)
    get Rezzer(list,type)
    answer it
  end if
end mouseDown

remove

This command allows you to remove resources from the current stack.

The syntax is:

  get Rezzer("remove",<name>,<type>)

The <name> parameter should be the name or id of the resource to remove.

The <type> parameter should be a four letter resource type.

alltypes

This command returns a list of all the types of resources that are available to the current stack. It looks in the current stack, any stacks in the stacksInUse, the home stack, or the system.

The syntax is:

  get Rezzer("alltypes")

The result is returned as a comma-delimited list of resource types.

Example script for alltypes

on mouseUp
  ShowResult "All resources types in path",Rezzer(allTypes)
end mouseUp

getField

This command is used to extract styled text from a TEXT/style reousrce pair, and put it into a field.

The syntax is:

  get Rezzer("getField",<resource>,<field>,<background>)

The <resource> parameter should contain the name or id of the TEXT resource to use.

The <field> parameter should contain the name of the field to put the text into.

The <background> parameter is a boolean, indicating whether or not the field is a background field.

Example script for getField

on mouseDown
  get Rezzer(getField,"another test","text",true)
end mouseDown

storeField

This command is used to extract styled text from a field, and store it in a TEXT/style reousrce pair.

The syntax is:

  get Rezzer("storeField",<resource>,<field>,<background>)

The <resource> parameter should contain the name or id of the TEXT resource to use.

The <field> parameter should contain the name of the field to that the text should be taken from.

The <background> parameter is a boolean, indicating whether or not the field is a background field.

Example script for storeField

on mouseDown
  get Rezzer(storeField,"another test","text",true)
end mouseDown

getText

This command is used to retrieve text from a TEXT/style reousrce pair.

The syntax is:

  get Rezzer("getText",<resource>)

The <resource> parameter should contain the name or id of the TEXT resource to store the text in.

Example script for getText

on mouseDown
  put Rezzer(getText,"another test")
end mouseDown

storeText

This command is used to store text in a TEXT/style reousrce pair.

The syntax is:

  get Rezzer("storeText",<resource>,<text>)

The <resource> parameter should contain the name or id of the TEXT resource to use.

The <text> parameter should contain the text to store.

Example script for storeText

on mouseDown
  get Rezzer(storeText,"another test",bg fld "text")
end mouseDown

handle

This command returns a handle to a given resource. You can use this command, in conjunction with the save command, to copy resources from one stack to another.

The syntax is:

    get Rezzer(handle,<name>,<type>)

The <name> parameter should be the name or id of the resource.

The <type> parameter should be a four letter resource type, eg PICT.

styleInfo

This command is used to find out what the style of the text in a TEXT/styl resource pair is.

The syntax is:

get Rezzer("styleInfo",<name>)

The <name> parameter should be the name or id of the TEXT/styl resources to look at.

Because styled text can contain a number of text runs with different fonts, sizes and styles, the XFCN actually only returns the style of the first character in the text. To get more detailed information about a TEXT/styl resource pair, use the getField command to copy it into a text field, then use standard hypertalk commands to examine the field.

Example script for styleInfo

on mouseDown
  ask "Which TEXT resource?" with "another test"
  get Rezzer(styleInfo,it)
  answer it
end mouseDown

exists

This command allows you to check whether a resource of a given name/id and type exists, either in this stack, or anywhere within the inheritance path.

The syntax is:

  get Rezzer("exists",<name>,<type>,<here>)

The <name> parameter should contain the name or id number of the resource to look for.

The <type> parameter should contain the type of the resource, ie PICT.

The <here> parameter should be true if you want to look only in the current stack. If it is false, all stacks in the inheritance path are searched.

Example script for exists

on mouseDown
  ask "Name or id?"
  if it is not empty then
    put it into name
    ask "Type?"
    if it is not empty then
      put it into type
      
      answer "Search" with "This stack" or "Everywhere"
      put (it is "This stack") into inOne
      
      get Rezzer(exists,name,type,inOne)
      if it then
        answer "Resource was found"
      else
        answer "Resource was not found"
      end if
    end if
  end if
end mouseDown

[last exit to hypercard] [externals index] [download Rezzer]

This page was created automatically, on 25/03/1999 from version 3.0d4 of Last Exit To Hypercard.