Reference to a InDesign® object (frame, table, document, , ...).

Reference to a InDesign® object (frame, table, document, , ...). With the help of the ItemRefs the object can be found in the target document. The object contains a reference to the document and a so-called UID, this which the object can be found in the document. UIDs are unique throughout the document and always growing for new created objects. The UID 1 designates the document itself.

The most common use of ItemRefs are gFrame and gTable.

How to show the frame UIDs inside the document:

  1. Right-click in the document
  2. In the appearing context menu choose the entry Nails and magnets -> Show
  3. Again right-click in the document
  4. In the appearing context menu choose the entry Nails and magnets -> Show UIDs

To get the UID of an ItemRef variable, use the function item::getint. With the help of the menu

  fly out the Product Pool - > Miscellaneous -> Select frame ...

the frames can be selected in the document: In the appearing dialog you can put in any text. All numbers in the text are interpreted as to be UIDs and valid frame UIDs are selected in the document.

int main ()
{
 	showmessage ("UID of gFrame : %d", item::getint (gFrame));

  return 0; }

With item::define, you can easily generate an ItemRef from a UID given as an integer (int). But be careful: The given UID (here 1234) should then also address a valid object in the document (here the current front document).

int main ()
{
 	ItemRef 		myRef	= item::alloc ();

  item::define (myRef, 0, 1234);

  return 0; }

The class of an ItemRef variable can be queried with item::get_class.

int main ()
{
 	ItemRef 		pageRef	= item::alloc ();

  page::get_uid (0, 1, pageRef);

  showmessage ("Class of frames : 0x%04X", item::get_class (gFrame));   showmessage ("Class of pages : 0x%04X", item::get_class (pageRef));

  return 0; }

The UID 1 always refers to the document itself. The example generates an ItemRef of the document of the current script frame and displays its document name.

int main ()
{
 	ItemRef		docRef	= item::alloc ();
 	char		docName	[4000];

  item::define (docRef, gFrame, 1);   document::name (docName, docRef);   showmessage (docName);

  return 0; }

See Also
item
frame
table
...

Alphabetic index HTML hierarchy of classes or Java