List of products.

You will find a general example for the use of productlist here.

Version :
12.03.2024, 15:56 Uhr

List of products. The list may be ascertained either using the current product research and its selections or build up using the script. List of the current product research can be expanded.

static ProductList alloc()

Create a new empty list. The list may be again deleted using release.

More information about product lists and products in lists can be found here.

Name Type Default Description
Return ProductList   pointer to a new empty list

Version 1.2.2 (24 Nov. 2004)

priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator

clear
release
get

static ProductList get(char* statement)

Create a new list from the entries of the Product Pool panel.

A second version of the function with two parameters fetches the n-th product of a given list.

Name Type Default Description
Return ProductList   New allocted list of products
statement String or char* - Instructions to fill the list, see here.
#include "internal/types.h"

Version 1.2.2 (24. Nov. 2004)

priint:comet InDesign® Plug-Ins, Illustrator

alloc
clear
release
comet.product.get

static void clear(ProductList pl, int delete_items = 1)

Clear list.

More information about product lists and products in lists can be found here.

Name Type Default Description
pl ProductList - pointer to a valid product list
delete_items int - Are the list elements likewise to be deleted from the memory?

1 - Delete objects 0 - do not delete

Version 1.2.2 (24. Nov. 2004)

priint:comet InDesign® Plug-Ins, comet_pdf

release
product::release

static void release(ProductList pl, int delete_items = 1)

Delete a list again from the active store.

More information about product lists and products in lists can be found here.

Name Type Default Description
pl ProductList - pointer to a valid product list
delete_items int 1 Are the list elements likewise to be deleted from the memory?

1 - Delete objects 0 - do not delete

Version 1.2.2 (24. Nov. 2004)

priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator

product::release
clear

static int length(ProductList pl)

Current length of the list

Name Type Default Description
Return int   Number of list elements
pl ProductList - pointer to a valid product list

Version 1.2.2 (24 Nov. 2004)

priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator

static Product get(ProductList pl, int nth)

Name Type Default Description
Return Product   found object. In case of error the call returns 0.
pl ProductList - Pointer to a valid product list
nth int - 0-based list index

Version 1.2.2 (24. Nov. 2004)

priint:comet InDesign® Plug-Ins

static int get_pos(
  ProductList pl,
  Product p,
  int setPos = 0)

Define the index which has an object in the list.

Name Type Default Description
Return int   0-based list position of the object. If the object is not found, the call returns -1.
pl ProductList - Pointer to a valid product list
p Product - Pointer to a valid product
setPos int 0 Set the current list position to this product?

0 : no
1 : yes

Version 1.2.2 (24 Nov. 2004)
Parameter setPos since v3.3.1 R3224, 16. Oct. 2012

priint:comet InDesign® Plug-Ins, comet_pdf

static Product get_nth(
  ProductList pl,
  int n,
  int setPos = 0)

Get the nth product of a given product list.

Name Type Default Description
Return Product   product found at the given 0-based list index

0 : list empty or index out of range
pl ProductList - Pointer to a valid product list
n int - 0-based index
setPos int 0 Set the current list position to this index?

0 : no
1 : yes

v3.3.1 R3224, 18. Oct. 2012, comet_pdf

priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator

static int append(
  ProductList pl,
  Product p,
  int allowDoubles = 1)

Insert an object to the list.

More information about product lists and products in lists can be found here.

Name Type Default Description
Return int   1 - The object could be inserted (and will be automatically deleted with clear (1))
0 - Objects not inserted (and must then be deleted)
pl ProductList - pointer to a valid product list
p Product - pointer to a valid product
allowDoubles int 1 Are entries with the same IDs permitted in the list?

0 - If the list already contains an entry with the ID of p, p will not be inserted in the list.
1 - The entry will be inserted without checking the ID.

Version 1.2.2 (24 Nov. 2004)

priint:comet InDesign® Plug-Ins, comet_pdf

static int insert(
  ProductList pl,
  Product p,
  int index,
  int allowDoubles = 1)

Insert an object in the list.

More information about product lists and products in lists can be found here.

Name Type Default Description
Return int   1 - The object could be inserted (and will be automatically deleted with clear/release (li, 1))
0 - Objects not inserted (and must then be deleted)
pl ProductList - pointer to a valid product list
p Product - pointer to a valid product
ix int - Insert in front of this position. The position is 0-based. To append an object to the list, use append or the Index -1.
allowDoubles int 1 Are entries with the same IDs permitted in the list?

0 - If the list already contains an entry with the ID of p, p will not be inserted in the list.
1 - The entry will be inserted without checking the ID.

Version 1.2.2 (24. Nov. 2004)

priint:comet InDesign® Plug-Ins, comet_pdf

static Product remove_pos(ProductList pl, int index)

Remove an object from the list. The object at the defined list position will be removed from the list. The product itself is not automatically deleted upon removal from the list.

More information about product lists and products in lists can be found here.

Name Type Default Description
Return Product   The removed object
0 - no object is to be removed from the list
pl ProductList - pointer to a valid product list
ix int - 0-based list index

Version 1.2.2 (24. Nov. 2004)

priint:comet InDesign® Plug-Ins, comet_pdf

static Product remove(ProductList pl, Product p)

Delete an object from the list. The object will be removed from the list. The product itself is not automatically deleted upon removal from the list.

More information about product lists and products in lists can be found here.

Name Type Default Description
Return Product   The removed object
0 - the object was not found in the list
pl ProductList - pointer to a valid product list
p Product - pointer to a valid product

Version 1.2.2 (24 Nov. 2004)

priint:comet InDesign® Plug-Ins, comet_pdf

static Product first(ProductList pl)

Get the first object of the list and define the current list pointer at the list start.

Name Type Default Description
Return Product   First object in the list
0 - Empty list
pl ProductList - Pointer to a valid product list

Version 1.2.2 (24 Nov. 2004)

priint:comet InDesign® Plug-Ins, comet_pdf

static Product next(ProductList pl)

Move the current list pointer toe position onwards and get the next object of the list. The call is dependent on either first or last and some prev calls.

Name Type Default Description
Return Product   Next object of the list
0 - List end not reached
pl ProductList - Pointer to a valid product list

Version 1.2.2 (24 Nov. 2004)

priint:comet InDesign® Plug-Ins, comet_pdf

static Product prev(ProductList pl)

Move the current list pointer toe position onwards and get the next object of the list. The call is dependent on either first or last and some next calls.

Name Type Default Description
Return Product   Next object of the list
0 - List start reached
pl ProductList - Pointer to a valid product list

Version 1.2.2 (24 Nov. 2004)

priint:comet InDesign® Plug-Ins, comet_pdf

static Product last(ProductList pl)

Get the last object of the list and define the current list pointer at the list end.

Name Type Default Description
Return Product   Last object of the list
0 - List empty
pl ProductList - Pointer to a valid product list

Version 1.2.2 (24 Nov. 2004)

priint:comet InDesign® Plug-Ins, comet_pdf

static int build(
  char* statement = "watched",
  int flags = 0,
  char* errmess = 0,
  ItemRef baseFrame = 0,
  int removeFrame = 0,
  int pageNum = -1,
  char* layerName = "",
  char* defaultMasterpage = "",
  int gridID = 0,
  int pageitemID = 0,
  int anchor = 0,
  float left = 0.0,
  float top = 0.0,
  float right = 0.0,
  float bottom = 0.0,
  int purgeSequence = 0,
  char* sequName = "",
  int preScript = kNoRule)

Product build. Like document::build_products.


priint:comet InDesign® Plug-Ins

document::build_products

static int build_list(
  ProductList pl,
  int flags = 0,
  char* errmess = 0,
  ItemRef baseFrame = 0,
  int removeFrame = 0,
  int pageNum = -1,
  char* layerName = "",
  char* defaultMasterpage = "",
  int gridID = 0,
  int pageitemID = 0,
  int anchor = 0,
  float left = 0.0,
  float top = 0.0,
  float right = 0.0,
  float bottom = 0.0,
  int purgeSequence = 0,
  char* sequName = "",
  int preScript = kNoRule)

Product build. Like document::build_products, but the first argument is a ProductList. No prescript is executed. You may prepare your products inside the script instead. Multiple products removed from the list by default.

This statement is prefered to use in a faceless InDesign® Server environment. In all other situations use the (faster) statement document::build_products please. The only exceptions are if you fill the productlist inside the script or if you want to make some special changes inside the resulting list from productlist::get.

#include "internal/types.h"
#include "internal/products.h"

Build a small amount of products.

#include "internal/products.h"
int gGridID = 12;
int append_product (ProductList li, int id1, int id2, int id3, int pi) { Product p;
if (!li) return 1;
p = product::alloc (); product::set (p, kID, id1); product::set (p, kID2, id2); product::set (p, kID3, id3); product::set (p, kPageitemid, pi);
productlist::append (li, p, 1);
return 0; }
int main () { ProductList li = productlist::alloc ();
append_product (li, 100, 10, 0, 2); append_product (li, 300, 10, 0, 2); append_product (li, 400, 10, 0, 12); append_product (li, 500, 10, 0, 2);
productlist::build_list (   li,   kUseDefaultGrid,   0, 0, 0, -1, "", "", gGridID);
productlist::clear (li, 1);
return 0; }


priint:comet InDesign® Plug-Ins

static ProductList load(
  int sourceType,
  void* dsn,
  int format,
  char* statement = "",
  List values = 0 )

Load a list of products from a file (XML or CSV), a database connection or an XMLTree.

Name Type Default Description
Return ProductList   Newly allocated list of products or 0 in case of some errors
sourceType int Type of data source

- kXML
XML-file
- kCSV CSV file
- kDB database or SOAP connection
- kXMLTree XMLTree
dsn void * depending on sourceType

- kXML
complete path to XML file
- kCSV complete path to CSV file
- kDB database or SOAP connection
- kXMLTree XMLTree
format int kStandardSet Data format : Describes the expected result columns:

- kStandardSet : ID,ID2,ID3,StringID - kExtendedSet : ID,ID2,ID3,StringID,Pageitemid - kCustomSet self defined set. In this case, parameter values must contain a list of expected results (see product::get)
statement String or char* "" Statement to select data (depends on the sourceType and format)

- kXML, kXMLTree: optionally if XML structure is like shown in example 1 or 2.
- kCSV: ignored
- kDB: required
List values 0 List of expected result rows (see product::get). The list entries and their datatypes must match the statements result rows.
#include "internal/products.h"

XML standard set

//
// <productlist>
//   <product>
//     <ID/>
//     <ID2/>
//     <ID3/>
//     <StringID/>
//   </product>
// </productlist>
//
ProducList pl = productlist::load (kXML, "/Export/catalogue_data/2007_05.xml");

XML extented set

//
// <productlist>
//   <product>
//     <ID/>
//     <ID2/>
//     <ID3/>
//     <StringID/>
//     <Pageitemid/>
//   </product>
// </productlist>
//
ProducList pl = productlist::load (kXML, "/Export/catalogue_data/2007_05.xml");

Load from xml structure (e.g. for validating parameters passed as an XML String)

XMLTree        tree;
ProductList      pl;
tree = xmlquery::parse ("<productlist><product><ID/><ID2/><ID3/><StringID/></product></productlist>"); pl = productlist::load(kXMLTree, tree);

SQL with own result set

ProductList		pl;
int				dbc = datapool::get_dbc (); // DBC oder SOAP
// Create a list of expected return values
List			values = list::alloc ();
list::insert (values, kID); list::insert (values, kID2);
pl = productlist::load(kDB, dbc, kCustomSet, "SELECT ID,ID2 FROM product", values);
// product lists loaded like shown above can be used like this: productlist::build_list (pl, kUseDefaultGrid, 0, 0, 0, 1, "produktlayer", "A-Mustervorlage", 1, 0, 0);

Version 1.4.1 (15. Juni 2007)

priint:comet InDesign® Plug-Ins, comet_pdf

static int seek(ProductList pl, int pos)

Set internal list iterator to position pos

Name Type Default Description
Return int 1 if successful, 0 otherwise    
pl ProductList - Pointer to a valid product list      
pos int - position      


priint:comet InDesign® Plug-Ins, comet_pdf

static int establish(
  ProductList pl,
  ItemRef dref = 0,
  int pageNum = -1,
  char* layer = "",
  int pageTemplate = 0,
  int pageItem = 0,
  int flags = 0,
  int preScript = 0,
  int singleSequences = 0,
  char* sequName = 0,
  char* errMess = 0,
  char* ignoreLayers = 0,
  int snippetMatchFlag = 0,
  char* snippetContext = 0,
  int snippetFilterFunc = 0,
  ...)

Product building using page templates.

Buildig products by using page templates. In the Tutorial PageBuilding you will find more information about page template based product build-ups. Here is a flowchart of the product build-up:

Here is a flowchart of the product build:

#NextItem #FixTemplate #FixPageElement #ExecPageitemScript #CreateNewPage #SetPageTemplate #FixTemplate #PrepareOversets #ExecPreRule #Full #Full #Full #ExecPostRule #NextPageElement #NextPageElement #RemoveFramesFromGrid #MoveFrames Finished #Continuation #FixTemplate #ExecPageitemScript #CreateTextframe #InsertTemplate #MoveFrames #MoveFrames #MoveFrames #LinkPlaceholders #LinkPlaceholders #LoadPlaceholders #LoadPlaceholders #BuildElements #Reorg #LayoutRules #LayoutRules #LayoutRules #LayoutRules #IsProduct #PageCreated #OversetsSmaller #HasOversets #CheckBefore #CheckAfter #PageCreated #PageCreated #OnePageCreated #CheckPageType #ContinueCall #ContinueCall #IsTextflow #ProductExists #BuildSupport2 #BuildSupport2 #BuildSupport2 #BuildSupport2 #BuildSupport2 #BuildSupport2 #BuildSupport2 #BuildSupport2 #BuildSupport2

Descriptions:

Name Type Default Description
Return int   0 or ErrorCode. If parameter errmess is given and allocated, it contains an error description too.
pl ProductList - products to build
dref ItemRef - destination document

0 : Current front document
int pageNum - start page

0 : Current page on front document

Using InDesign® Server or comet_pdf the current front page is undefined!

layer String or char* - layer name

"" : Current front layer
int pageTemplate - Initial page template to use for building

Page breaks are achieved by inserting products with kProductType = 4 (page template) into the product list. Here you will find an example.
int pageItem 0 template to use for building product(s), see (kPreferDefaultPageItem for more information
int flags 0 Customize building.

kPreferDefaultPageItem . Use pageItem for all products. Otherwise pageItem is used only for products with no pageitem given.

kSkipEmptyTemplates : Skip products with no template defined. (available since Comet 3.2 R2187)

kShowProgress show progressbar

kCheckIfNotExists : Check whether a product already exists in the document and suppress inserting if so.

kAutoDetectType : While inserting templates as text we have two possibilities : Insert a frame as inline or insert the frames (text) content. With kAutoDetectType set, the following is done : Insert the text content if the frame is a text frame and inserted the frame as an inline otherwise.

kSuppressAlerts Suppress alerts while building products. Some alerts like 'Object will leave the paste board' are too deep inside InDesign® and cannot suppressed!

kIgnoreErrors Ignore errors and continue. This may generate gaps in page elements. Reorganizing the document again will fill this gaps.

kPreferExistingPages If document pages are already linked against page templates, prefer this page templates instead of the the page template given in pageTemplate. If the last page is reached, the normal page templates successor rules are used.

kPreferProductPT Since v3.3 R2731 Products may contain a page template. Product page templates are shown (delimited by an @) behind the products template in the product pool. The page template is given by the panelstatements in the column gridID.
Every page template will create a page break. Products without a page template will use the standard page template as given above.
ATTENTION : This version of Comet does NOT support page breaks to specific page type (left, right pages)!

kLoadMasterItems Seit v3.3 R3051 Override and link all parent page frames linked with placeholders after successfully building all products. In this case, we walk through all pages of the document. The document will remember, wether the flag is set or not : If the flag is set, all subsequent reorganizations will walk through the parent pages items too.
Overriden parent items always lie above the non-overridden items and may cover these frame. If necessary, frames that are to be in the foreground must be provided with an empty placeholder and arranged accordingly.

kSuppressLoad Since v4.1.8 R30123 Suppress loading placeholders and building repeating elements.
preScript int kNoRule ID of the preparation script. The script is executed in that the list of the products to be imported is determined and can then be used to process the product list. For more see product::set, product::clone, productlist and on chapter Script support.

kNoRule - No script is executed
Otherwise : ID of script, see here for more information.
singleSequences int 0 ignored
sequName String or char* "" ignored
errmess String or char* 0 If the variable identifies an allocated string (e.g. of type char[256]), an error message can be received here.
ignoreLayers, ... String or char* 0 since Comet 3.2 Any number of layer names. New products are allowed to intersect objects on this layers.

"invisibles" : All invisibles layers
"except name" : All but this
"behind name" : Alle All behind this
"background" : Background layer
0 or "" : no more layers given
otherwise : Name of layer. Ignored, if it is the active front layer of the document.
If snippet parameter should be used, the list of ignoreLayers must be terminated by a '0'. Therefore, for no ignoreLayers, therefore a single '0' must be written.
snippetMatchFlags int kSnippetsNever since v4.1.6 R26609 Should Comet Snippets be used? Flags can be added, e.g. kSnippetMatchesProduct + kSnippetMatchesTemplate

kSnippetsNever : No, don't use snippets
kSnippetMatchesProduct : Yes, if products match
kSnippetMatchesTemplate : Yes, if templates match
kSnippetMatchesDocument : Yes, if documents match
kSnippetMatchesLayer : Yes, if layers match
kSnippetMatchesContext : Yes, if the contexts match
kSnippetFallbackToTemplate : if the snippet doesn't fit the page element, use original template instead.
kSnippetCreate : create non existing snippets on the fly
snippetContext String oder char* 0 since v4.1.6 R26609 arbitrary string to identify a snippet's "context". This will be used for snippet search and for new snippets created during building.
snippetFilterFunc int 0 since v4.1.6 R26609 Pointer to a function, which is executed before snippet creation to check, whether a snippet should be created for a product or not. The function must be defined in the same script (or be included from a script library) and follow this signature: int (*snippetFilterFunc)(Product p). See prefs::snippet_filter for an example
#include "internal/types.h"
#include "internal/products.h"
#include "internal/products.h"
#include "internal/types.h"
int main () { ProductList pl = productlist::get ("selected"); int result;
result = productlist::establish (   pl,   0, // front document   -1, // current page   "", // front layer   2, // page template   0, // default template   kShowProgress, // flags, (showprogress)   0, // pre script   0, // no single sequences   "", // sequence name not used   0 // errmess ); if (result == 0) wlog ("", "# Establishing %d products done\n", productlist::length (pl)); else wlog ("", "# Establishing %d products returned error %d\n", productlist::length (pl), result);
return 0; }

Comet 3.0, 28. October 2008

priint:comet InDesign® Plug-Ins, comet_pdf

is_in_build
trace_build
get_established
reorganize
comet.product.establish

static int grid_build(
  ItemRef docRef,
  PlanningList plannings,
  int flags,
  char* buildMessage)

Build a list of plannings according page, coordinates and dimension configured in grid planning.

Name Type Default Description
Return int   0 or error code.
docRef ItemRef - document
0 : current document
plannings PlanningList - list of planning objects
flags int - control flags.
Basically, all flags supported by productlist::establish are allowed, mainly useful in this context:
0 : ignore grid size. This also implies: ignore existing page content kCheckGridElementSize : respect grid size
buildMessage char * 0 buffer for build messages

v4.3

priint:comet InDesign® Plug-Ins, comet_pdf

static int trace_build(
  ItemRef docRef,
  int pg,
  char* fileName)

Add an image to the build trace. The statement is a *NOP* if the build trace is not activated. To activate the build trace, use the ProductPool flyout menu Produktpool -> Misc -> Build Trace

Name Type Default Description
Return int   0 or ErrorCode.
docRef ItemRef - Document
0 : Current document
pg int - 1-based page to create an image from
fileName String or char* - File name of image. The file name is added to an automatic counter number. In addition, a message is written to the log:

# Trace image created : '$CACHE/BuildTrace/NN_p1_fileName.png'

v4.0.5 R11600, 10. Jun. 2016

priint:comet InDesign® Plug-Ins, comet_pdf

static ProductList get_established(
  ItemRef docRef = 0,
  int startPage = 1,
  ItemRef behindRef = 0)

Create a new list of the products built in a document and the page templates used for building these products. The result is the same list the panel Products of document shows. if you insert new objects in this list, create them using kListOwner, see product::alloc for more information. More information about product lists and products in lists can be found here.

Name Type Default Description
Return ProductList   pointer to the new list
docRef ItemRef 0 Document
0 : current document
startPage int 1 start collecting at the given page (1-based)
behindFrame ItemRef 0 Start collecting behind this frame. If given, the start page is ignored.
#include "internal/types.h"
#include "internal/products.h"

Write all established products of the current document page to the logfile.

#include "internal/products.h"
int main () { ProductList pl; Product p; ItemList li = itemlist::alloc (); ItemRef f1 = item::alloc (); int pg1 = page::get (gFrame); int pg = -1;
pl = productlist::get_established (0, pg1, 0); p = productlist::first (pl);
if (!p) { wlog ("", "No products found!\n"); return 0; } if (product::get (p, kProductType) != 4) { wlog ("", "No page template found!\n"); return 0; }
wlog ("", "Products found on page %d\n", pg1); for (p = productlist::next (pl); p; p = productlist::next (pl)) { if (product::get (p, kProductType) != 0) break; // no a built product product::get_itemlist (p, kProductOriginals, li); if (itemlist::length (li) == 0) break; if (page::get (itemlist::get (li, f1, 0)) != pg1) break; // next page
wlog ("", "[%d, %d %d %s] : used template %d\n",   product::get (p, kID),   product::get (p, kID2),   product::get (p, kID3),   product::gets (p, kStringID),   product::get (p, kPageitemid)); }
return 0; }

Version 3.2 R2110, 7. Sept. 2010

priint:comet InDesign® Plug-Ins, comet_pdf

clear
release
comet.product.getEstablished

static int reorganize(
  ItemRef docRef = 0,
  ProductList plist = 0,
  ItemRef firstFrame = 0,
  int thisPageOnly = 0,
  int flags = 1,
  char* errmess = 0,
  int* failedIndex = 0,
  Product* firstEntry = 0)

Reorganization of a document. If th given product list is empty or 0, the document is scanned to get the current document products.

Name Type Default Description
Return int   0 or ErrorCode
docRef ItemRef 0 Document
0 : current document
plist ProductList 0 List of products. You may get such a list by a call to get_established.

0 : Scan the list of products directly from the document at runtime
firstFrame ItemRef 0 Start reorganization at the Comet group of this frame.

0 : Reorganize whole document
thisPageOnly int 0 Reorganize only this page

0 : Ignore. Reorganize complete document (starting after firstFrame if given).

Otherwise : 1-based page index. In this case firstFrame and plist are ignored.

-2 : Clean up only the page where either the first frame of the first product of plist or (if plist is empty) the frame firstFrame is located. If both data are empty, the first page of the document is reorganized. This conforms to the menu "Reorganize page" or (if used with flag kFillPage) the menu "Fill and reorganize page".
flags int kShowProgress Used flags

kShowProgress show progressbar

kReloadAll suppress copying contents between frames with same frame labels and same groups on template changes

kSuppressAlerts Suppress alerts while building products. Some alerts like 'Object will leave the paste board' are too deep inside InDesign® and cannot suppressed!

kIgnoreErrors Ignore errors and continue. This may generate gaps in page elements. Reorganizing the document again will fill this gaps.

kPreferExistingPages If document pages are already linked against page templates, prefer this page templates instead of the the page template given in pageTemplate. If the last page is reached, the normal page templates successor rules are used.

kLoadMasterItems Seit v3.3 R3051 Override and link all parent page frames linked with placeholders after successfully building all products. In this case, we walk through all pages of the document. If the last products are built using this flag, the option has no effect : Parent page items are overridden/loaded if the flag is set or not.
Overriden parent items always lie above the non-overridden items and may cover these frame. If necessary, frames that are to be in the foreground must be provided with an empty placeholder and arranged accordingly.

kFillPage since v3.4 R5115 and in case of thisPageOnly > 0 : Fill page before reorganizing.

kCropPage since v3.4 R5115 and in case of thisPageOnly > 0 : Insert product-building page breaks around the reorganized page.
errmess String or char* 0 0 or allocated string to get error messages (if the variable type is char*, please allocate at least 4000 bytes).
failedIndex int* 0 Index in plist of th first failed product.
firstEntry Product 0 Reorganize from the given entry to the end of the list plist

0 : Ignore

Otherwise : Valid list entry in plist. The specifications for firstFrame and thisPageOnly are ignored in this case.
#include "internal/types.h"
#include "internal/products.h"

Version 3.2 R2110, 7. Sept. 2010
thisPageOnly == -2 since v4.1.7 R27225, 1. Jul 2020
firstEntry since v4.2 R31320, 1. Aug 2022

priint:comet InDesign® Plug-Ins, comet_pdf

clear
release

static int get_default_pageitem()

Retreive the current default template selected in the Product pool panel. If the panel is closed, the function will return 0.

Name Type Default Description
Return int   ID of default template or 0.

Version 3.2.1 R2310, 26. Feb. 2011

priint:comet InDesign® Plug-Ins

static int sort(LinkList lli, int cmpFunc)

Sort a list of products.

The compare function cmpFunc must be defined in the script and must be of the following type:

   int yourCmpFunction (Product a, Product b)

The function is used by the sorter to check whether two list objects are well placed in the list. At calling time a stands before b. If you want to change the objects positions, return 1 otherwise 0.

Name Type Default Description
Return int   0 or ErrorCode
lli ProductList - Valid ProductList.
cmpFunc int yourCmpFunction (Product a, Product b) - Compare function.The function is used by the sorter to check whether two list objects are well placed in the list. At calling time a stands before b. If you want to change the objects positions, return 1 otherwise 0.

Do not use script global variables inside the function!
#include "internal/types.h"
#include "internal/products.h"

Get all selected entries of the product pool panel and sort them by different ways. Resuts are written to the log.

#include "internal/text.h"
#include "internal/types.h"
#include "internal/products.h"
int w_pli (ProductList pli, char * trailer) { Product p;
wlog ("", "%s\n", trailer); for (p = productlist::first (pli); p; p = productlist::next (pli)) { wlog ("", "[%d %d %d, '%s'] (Template %d): '%s'\n",   product::get (p, kID),   product::get (p, kID2),   product::get (p, kID3),   product::get (p, kStringID),   product::get (p, kPageitemid),   product::gets (p, kRow1)); } wlog ("", "\n"); }
int byName_asc (Product a, Product b) { char s1 [8000]; char s2 [8000];
strcpy (s1, product::gets (a, kRow1)); strcpy (s2, product::gets (b, kRow1));
if (strcmp (s1, s2) > 0) return 1;
else return 0; }
int byName_desc (Product a, Product b) { char s1 [8000]; char s2 [8000];
strcpy (s1, product::gets (a, kRow1)); strcpy (s2, product::gets (b, kRow1));
if (strcmp (s1, s2) < 0) return 1;
else return 0; }
int byTemplate_asc (Product a, Product b) { if (product::get (a, kPageitemid) > product::get (b, kPageitemid)) return 1;
else return 0; }
int byID_asc (Product a, Product b) { if (product::get (a, kID) > product::get (b, kID)) return 1;
else return 0; }
int main () { ProductList pli = productlist::get ("selected");
w_pli (pli, "Original");
productlist::sort (pli, byName_asc); w_pli (pli, "By name (ascent)");
productlist::sort (pli, byName_desc); w_pli (pli, "By name (descent)");
productlist::sort (pli, byTemplate_asc); w_pli (pli, "By template (ascent)");
productlist::sort (pli, byID_asc); w_pli (pli, "By id1 (ascent)");
return 0; }

Version 3.2.1 R2321, 3.3.2011

priint:comet InDesign® Plug-Ins, comet_pdf

static int update_findstatements(
  int reloadFindStatements,
  int popupSelection,
  int reloadProducts)

Update the search methods popup on the Products panel.

Name Type Default Description
Return 0 or ErrorCode    
reloadFindStatements int 0 Reload popup entries?
0 : no
1 : yes
popupSelection int -1 Select this popup entry (0-based with delimiter lines counted)
-1 : Do not change selection (if possible)
>= number of menu entries : Select last item
reloadProducts int 0 Reload products?
0 : no
1 : yes

v3.3 R2819, 6. Mar 2012

priint:comet InDesign® Plug-Ins

static int create_snippets(
  ItemRef docRef = 0,
  int page = 0,
  int snippetMatchFlags = 0,
  char* snippetContext = 0,
  char* snippetLayer = 0,
  int snippetFilterFunc = 0)

Create Comet-Snippets from the Comet groups of a given document. Existing snippets matching the same criteria are overwritten. This means: the more specific match criteria are defined, the less snippets are affected by updates. If no matching snippet can be found, new snippet entries are created.

Comet-Snippets are only created from products without continuing frames!

Name Type Default Description
Return int   0 or ErrorCode
docRef ItemRef 0 Document to create snippets from

0 : current front document
page int 0 Wich pages?

0 : all pages
> 0 : only this page
-1 : Comet groups of selected frames
snippetMatchFlags int kSnippetsNever since v4.1.6 R26609 Should Comet Snippets be used? Flags can be added, e.g. kSnippetMatchesProduct + kSnippetMatchesTemplate
Set to -1 to show the snippet match criteria dialog.

kSnippetsNever : No, don't use snippets
kSnippetMatchesProduct : Yes, if products match
kSnippetMatchesTemplate : Yes, if templates match
kSnippetMatchesDocument : Yes, if documents match
kSnippetMatchesLayer : Yes, if layers match
kSnippetMatchesContext : Yes, if the contexts match
snippetContext String oder char* 0 since v4.1.6 R26609 arbitrary string to identify a snippet's "context". This will be used for snippet search and for new snippets created during building.
snippetLayer String oder char* 0 since v4.1.6 R26609 if provided, also snippets layer also checked against this.
snippetFilterFunc int 0 since v4.1.6 R26609 Pointer to a function, which is executed before snippet creation to check, whether a snippet should be created for a product or not. The function must be defined in the same script (or be included from a script library) and follow this signature: int (*snippetFilterFunc)(Product p). See prefs::snippet_filter for an example.
#include "internal/products.h"

v4.0.5 R8410, 10. Jul 2015

priint:comet InDesign® Plug-Ins

remove_snippets

static int remove_snippets(char* key, ItemRef docRef)

Remove Comet-Snippets.

Name Type Default Description
Return int   0 or ErrorCode
Snippets eines Dokumentes löschen
key String or char* - "DOC"
value ItemRef - Remove all snippets of a given document

0 : current front document
Dokumentauswahl
key String or char* - "DOCID" or "DOCPATH"
value String or char* - key == "DOCID" : Document-ID of Pubserver
key == "DOCPATH" : Complete path of document
Produkt-ID
key String or char* - "RECORDID"
id1 int - record ID of snippet(s) to remove
id2 int - record ID2 of snippet(s) to remove
id3 int - record ID3 of snippet(s) to remove
sid String or char* - record string ID of snippet(s) to remove

v4.0.5 R8410, 10. Jul 2015

priint:comet InDesign® Plug-Ins

create_snippets

static char* to_xml(ProductList list, char* rootElementName = "products")

Generate a XML structure of a ProductList object.

If you think about using this function, you might be interested in further information about cscript / java interaction. Related information can be found here.

Name Type Default Description
Return char *   xml string or 0 on errors. The result string is valid until the next time a to_xml function is called and must not be changed or released.
list ProductList - object  
rootElementName String or char* products name of the root element

4.0.5 R9650
comet.publication.toXMLProductList

static ProductList from_xml(char* xml)

Create a ProductList object from an xml structure.

There are two formats in which product lists can be transferred:

This format contains all the data that the products of a Product Pool know (cf. here). The format is used in the PubServer environment and the XML description is expected as string input of this function.

If you think about using this function, you might be interested in further information about cscript / java interaction. Related information can be found here.

<products xsi:type="cscript-products" xmlns:xsi="http:www.w3.org/2001/XMLSchema-instance" xmlns:xs="http:www.w3.org/2001/XMLSchema">
 	<product>
 		<classId>0</classId>
 		<column1/>
 		<column2/>
 		<docId>0</docId>
 		<gridElementId>0</gridElementId>
 		<gridElementName/>
 		<gridId>0</gridId>
 		<gridName/>
 		<gridElmentId>0</gridElmentId>
 		<pageTemplateElementId>0</pageTemplateElementId>
 		<pageTemplateId>0</pageTemplateId>
 		<forceDelete>false</forceDelete>
 		<id>1</id>
 		<id2>0</id2>
 		<id3>0</id3>
 		<stringId/>
 		<masterPage/>
 		<pageItemId>0</pageItemId>
 		<preRuleId>0</preRuleId>
 		<postRuleId>0</postRuleId>
 		<documentPosition>-1</documentPosition>
 		<toDelete>0</toDelete>
 		<start>-1</start>
 		<end>-1</end>
 		<type>4</type>
 		<tagId1>0</tagId1>
 		<tagId2>0</tagId2>
 		<pageType>1</pageType>
 		<preRuleParams/>
 		<postRuleParams/>
 		<adParams/>
 		<snippetAttribute/>
 	</product>
 	<product>
 		<classId>0</classId>
 		<column1/>
 		<column2/>
 		<docId>0</docId>
 		<gridElementId>0</gridElementId>
 		<gridElementName/>
 		<gridId>0</gridId>
 		<gridName/>
 		<gridElmentId>0</gridElmentId>
 		<pageTemplateElementId>0</pageTemplateElementId>
 		<pageTemplateId>0</pageTemplateId>
 		<forceDelete>false</forceDelete>
 		<id>1</id>
 		<id2>0</id2>
 		<id3>0</id3>
 		<stringId/>
 		<masterPage/>
 		<pageItemId>1</pageItemId>
 		<preRuleId>0</preRuleId>
 		<postRuleId>0</postRuleId>
 		<documentPosition>-1</documentPosition>
 		<toDelete>0</toDelete>
 		<start>-1</start>
 		<end>-1</end>
 		<type>0</type>
 		<tagId1>0</tagId1>
 		<tagId2>0</tagId2>
 		<pageType>-1</pageType>
 		<preRuleParams/>
 		<postRuleParams/>
 		<adParams/>
 		<snippetAttribute/>
 	</product>
</products>

This format contains all the information necessary for a product buildup and reorganizations. The format can be read only via input files. The path is specified after a leading file: in the xml parameter of the function. You can get valid items.xmls e.g. by using the Save button of the panel Products of Document from a document with previously built products.

<?xml version="1.0" encoding="utf-8"?>
<items version="4.2" pluginRevision="33067" ref="document" documentID="" spreadID="" pageID="" groupID="" elementID="" importFlags="0x0" documentPath="" documentName="" isMissingPlugIns="0" isConverted="0" isModified="1" isReadOnly="0">
 	<item>
 		<ID>1</ID>
 		<ID2>0</ID2>
 		<ID3>0</ID3>
 		<stringID/>
 		<pageitemID>0</pageitemID>
 		<type>pagetemplate</type>
 		<pageType>1</pageType>
 		<layout_layers/>
 		<document-position>-1</document-position>
 		<groupID>0</groupID>
 		<classID>3</classID>
 		<status>normal</status>
 		<elementID>0</elementID>
 		<preruleID>0</preruleID>
 		<preruleParams/>
 		<postruleID>0</postruleID>
 		<postruleParams/>
 		<keepWithNext>0</keepWithNext>
 	</item>
 	<item>
 		<ID>1</ID>
 		<ID2>0</ID2>
 		<ID3>0</ID3>
 		<stringID/>
 		<pageitemID>1</pageitemID>
 		<type>product</type>
 		<pageType>-1</pageType>
 		<layout_layers/>
 		<document-position>-1</document-position>
 		<groupID>0</groupID>
 		<classID>3</classID>
 		<status>normal</status>
 		<elementID>0</elementID>
 		<preruleID>0</preruleID>
 		<preruleParams/>
 		<postruleID>0</postruleID>
 		<postruleParams/>
 		<keepWithNext>0</keepWithNext>
 	</item>
<items>

Name Type Default Description
Return ProductList   object of type ProductList. This list must be released using productlist::release.
xml String or char* - Valid XML string of an products.xml XML

"file://..." [since v4.2 R33100, not supported by Illustrator] Specification of a path to an items.xml XML file. Please note that the syntax of an items.xml is different from a products.xml. The following path specifications are supported:
  • Full paths, e.g. file:///Users/paul/Desktop/myproducts.xml
  • ~ at the beginning of the path is replaced by the home directory ($HOME) of the current user, e.g.. file://~/Desktop/myproducts.xml
  • Paths starting with a defined alias, e.g. file://$DESKTOP/myproducts.xml
  • Incomplete paths are resolved relative to the path of the current front document (if there is such a path).

4.0.5 R9650
"file://..." since v4.2 R33100, 20. Jun 2023

priint:comet InDesign® Plug-Ins

comet.publication.fromXMLProductList

static int add_all(
  ProductList target,
  ProductList src,
  int deleteFromSource)

Append all elements from list src to list target. If deleteFromSource is non-zero, all elements are removed from source list. (but not deleted)

Name Type Default Description
Return int   0 oder Fehlercode.
target ProductList - target list
src ProductList - source list
deleteFromSource 0 delete elements from source  

4.0.5 R9700

priint:comet InDesign® Plug-Ins

static int is_in_build(int* pageTemplateID = 0, int* elementSeq = 0)

Is the currently executing script in a product build up or not?

Name Type Default Description
Return int   0 : No, there is no product build active

1 : Yes
pageTemplateID int* 0 If return value is 1 : ID of the currently used page template
elementSeq int* 0 If return value is 1 : Sequence number of the currently used page element.

4.1.8 R28440, 21. Apr 2021

priint:comet InDesign® Plug-Ins, comet_pdf

static int get_build_trace(
  int* on = 0,
  int* showNails = 0,
  int* showUIDs = 0,
  int* showEdges = 0,
  float* resolution = 0)

Get the current values used for build tracings.

Name Type Default Description
Return int   0 or ErrorCode
on int* 0 Build tracing activated?

0 : ignore
otherwise : The variable will contain the current state (0 off, 1 on) on successful return
showNails int* 0 Show nails and magnets in build traces?

0 : ignore
otherwise : The variable will contain the current state (0 no, 1 yes) on successful return
showUIDs int* 0 Show frame UIDs in build traces?

0 : ignore
otherwise : The variable will contain the current state (0 no, 1 yes) on successful return
showEdges int* 0 Show frame edges in build traces?

0 : ignore
otherwise : The variable will contain the current state (0 no, 1 yes) on successful return
resolution float* 0 Resolution of build trace images

0 : ignore
otherwise : The variable will contain the current resolution on successful return

v4.0.5 R14000, 8. Nov 2016

priint:comet InDesign® Plug-Ins

static int set_build_trace(
  int on = -2,
  int showNails = -2,
  int showUIDs = -2,
  int showEdges = -2,
  float resolution = 0.0)

(De)activate build tracing. Build tracing is deactivated after InDesign® restarts automatically!

Build tracing may cause extremely slower building processes. Images are created in the folder $CACHE/BuildTrace. Don't forget to trash this folder from time to time.

Name Type Default Description
Return int   0 or ErrorCode
on int -2 Activate build tracing?

-2 : Leave untouched
-1 : Toggle
0 : Off
>0 : On
showNails int 0 Show nails and magnets?

-2 : Leave untouched
-1 : Toggle
0 : No
>0 : Yes
showUIDs int 0 Show frame UIDs?

-2 : Leave untouched
-1 : Toggle
0 : No
>0 : Yes
showEdges int 0 Show frame edges?

-2 : Leave untouched
-1 : Toggle
0 : No
>0 : Yes
resolution float 0 Resolution of snapshots

0.0 : Leave untouched
otherwise : Snapshot resolution in px/pt. Values are delimited in the range [20.0 - 600.0].

Here's a simple Javascript building some products of the Comic Showcase.

var gOptions    = app.comet.ping () + ";-1;";
var myPath  	= "/Users/paul/Desktop/aaa.indd";
var gScriptID = 2006; var gScript = "gray">"\ \ #include \"internal/types.h\"\ #include \"internal/text.h\"\ #include \"internal/products.h\"\ \ int main() \ {\ productlist::set_build_trace (1, 1, 1, 0, 56.7);\ return 0;\ }\ ";
app.comet.setEnvironment ("/DATA/CometEnvironment", 2, ""); // XMLData with connections.xml app.comet.use ("demo", "", "", false, ""); // Entry in connections.xml
app.comet.documentOpen (myPath, true, gOptions);
app.comet.eval (gScript, '', '');
var gItemsXML ="gray">"\ <item><ID>1</ID><ID2>0</ID2><ID3>0</ID3><stringID>109007</stringID><pageitemID>1</pageitemID></item>\ <item><ID>1</ID><ID2>0</ID2><ID3>0</ID3><stringID>116507</stringID><pageitemID>1</pageitemID></item>\ <item><ID>1</ID><ID2>0</ID2><ID3>0</ID3><stringID>105507</stringID><pageitemID>1</pageitemID></item>\ <item><ID>1</ID><ID2>0</ID2><ID3>0</ID3><stringID>110007</stringID><pageitemID>1</pageitemID></item>\ </items>";
app.comet.build (myPath, // document path   Scope.SPREAD, // Scope.SPREAD | Scope.PAGE   0, // spread or page index   gItemsXML, // items xml   0.0, 0.0, // x / y   gOptions);
app.comet.documentSave (myPath, gOptions); app.comet.documentClose (myPath, gOptions);

v4.0.5 R14000, 8. Nov 2016

priint:comet InDesign® Plug-Ins

Preconditions
#include "internal/products.h"
#include "internal/products.h"
int main () { ProductList li; Product p; int i;
li = productlist::get ("watched [id3 = 1 or id3=6]"); if (!li) { showmessage ("no products"); return 0; }
showmessage ("-- %d --", productlist::length (li)); for ( p = productlist::first (li);   p;   p = productlist::next (li)) { showmessage ("%d : %s (template %d)",   product::get (p, kID),   product::gets (p, kRow1),   product::get (p, kPageitemid)); }
return 0; }

Author
Paul Seidel
Version
12.03.2024, 15:56 Uhr
Since
Version 1.2.2 (24. Nov. 2004)
See Also
product

Alphabetic index HTML hierarchy of classes or Java