Integer lists.

Here you will find examples to use list.

Version :
09.11.2021, 08:27 Uhr

Integer lists. The lists can be be filled either with the object IDs of the list panels (e.g. the Product Pool) or 'manually'.

static List alloc(
  int classid,
  int selection_type = 0,
  int id_index = 1)

Get the object list of the panel which contains the objects of the desired classid. If no corresponding panel is found, 0 is returned. Otherwise the list will be filled with the desired IDs of the loaded objects. The result list must be deleted again using list::release.

[ab v3.3 R3136] InDesign® removes all list entries from unvisible panels. It's a mess to refill the list again. But, if we have the data, we can use them. So list::alloc still works for invisible panels too now.
ATTENTION : But take care! This will work for kAll and kEyeMarked only. Unvisible lists still haven't a selection, so kSelected still returns an empty list!

Name Type Default Description
Return List   Created list of the 0
classid int - Class ID of the panel
selection_type int kAll kAll : All datasets of the panel
kAll : Only the eye marked datasets of the panel
kAll : Selected panel entries only

The following include is neeeded

   #include "internal/panels.h"
id_index int 1 Which IDs are to be fetched? 1 = ID, 2 = ID2, 3 = ID3

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

Create a list with the IDs of the marked products

#include "internal/panels.h"
List li = list::alloc ((kPanelProducts, kEyeMarked, 1);


priint:comet InDesign® Plug-Ins, comet_pdf

static List alloc()

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

Name Type Default Description
Return List   Created list or 0

Create a new empty list

List = list::alloc ();
 	:
list::release (li);


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

static int release(List li)

Delete a created list again using list::alloc

Name Type Default Description
li List - List to be deleted


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

static int length(List li)

Ascertain the number of elements of a list

Name Type Default Description
Return int   Number of entries in the list
li List - List

int len = list::length (li);


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

static int first(List li)

Get the first entry of a non-empty list

Name Type Default Description
Return int   First value of the list
li List - List with at least one element

The current list pointer is now at the start of the list. Further values can be fetched using next or last.

The following example can be used for lists that have no 0-entry.

int main ()
{
    List		li	= list::alloc ();
    int		i;
for (i=1; i<6; i++) list::insert (li, 3*i); for (i=list::first (li); i; i=list::next (li)) { showmessage ("%d", i); } list::release (li); }


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

next
prev
last
get
get_pos

static int next(List li)

Get the next entry in a list.

Name Type Default Description
Return int   Next value of the list
li List - List with at least one element after the current list pointer

Current list pointer with first, get_pos or get set and not the last element in the list
Current list pointer will be re-located one position forwards

The following example can be used for lists that have no 0-entry.

int main ()
{
    List		li	= list::alloc ();
    int		i;
for (i=1; i<6; i++) list::insert (li, 3*i); for (i=list::first (li); i; i=list::next (li)) { showmessage ("%d", i); } list::release (li);


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

first
prev
last
get
get_pos

static int prev(List li)

Get the previous entry in the list.

Name Type Default Description
Return int   Value of the preceding entry in the list
li List - List with at least one element after the current list pointer

Current list pointer with first, get_pos or get set and not the last element in the list
Current list pointer will be re-located one position backwards

The following example can be used for lists that have no 0-entry.

int main ()
{
    List		li	= list::alloc ();
    int		i;
for (i=1; i<6; i++) list::insert (li, 3*i); for (i=list::last (li); i; i=list::prev (li)) { showmessage ("%d", i); } list::release (li); }


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

first
next
last
get
get_pos

static int last(List li)

Get the last entry in a non-empty list

Name Type Default Description
Return int   First value of the list Wert der Liste
li List - List with all least one element

The current list pointer is now located at the end of the list. Using prev or first further values can be fetched.

The following example can be used for lists that have no 0-entry.

int main ()
{
    List		li	= list::alloc ();
    int		i;
for (i=1; i<6; i++) list::insert (li, 3*i); for (i=list::last (li); i; i=list::prev (li)) { showmessage ("%d", i); } list::release (li);


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

first
next
prev
get
get_pos

static int get_pos(
  List li,
  int val,
  int setPos = 0)

Search for the position of a value in the list. If the value is not found, the function returns -1. List positions are 0-based, meaning the first element has the position 0, the last the position-1.

Name Type Default Description
Return int   >= 0 : First occurrence of the value in the list
-1 : Value not found
li List - List in which the value is to be searched for
val int - This value is searched for
setPos int 0 0 : Do not change list positions
1 : Set current list positions at place of finding

If the value was found in the list and if setPos is > 0, the current list position is at the place of finding.
pos	= list::get_pos (li, val [, setPos]);


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

get

static int get(
  List li,
  int pos,
  int doSelect= 0)

Get the i-te element of the list. List positions are 0-based, meaning the first element has the position 0, the last the position-1.

Name Type Default Description
Return int   Value of the list at the position i or -1
li List - List from which the element is to be fetched
pos int - 0-based list position
setPos int 0 0 : Do not change list positions
1 : Set list position to pos

If setPos > 0, the current list position is set at i.
k	= list::get (li, pos [, setPos]);


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

get_pos

static int append(List li, int val)

Append elements to the list

Name Type Default Description
Return int   1 action successful, 0 otherwise
li List - List to which the append to be made
val int - Value to be appended

list::append (li, k);


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

insert
remove
remove_pos
clear

static int insert(
  List li,
  int val,
  int pos = -1)

Insert element in the list. List positions are 0-based, meaning the first element has the position 0, the last the position-1.

Name Type Default Description
Return int   1 Action successful, 0 otherwise
li List - List to which the append to be made
val int - Value to be appended
pos int - Insert point. 0 = list start, Value < 0 or >= length = append

list::insert (li, 3, 0);


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

append
remove
remove_pos
clear

static int remove(
  List li,
  int val,
  int rmAll = 1)

All occurrences of a value will be removed from the list. Since R1396 (26.6.2009) you can remove the first entry only by setting the new parameter rmAll to 0.

Name Type Default Description
Return int   1 action successful, 0 otherwise
li List - List to which the append is to be made
val int - Value which is to be removed from the list
rmAll int - Delete one or all entries of the given value
1 : remove all
0 : remove first (if)

The example illustrates the functioning of remove and remove_pos

int main ()
{
    int		i;
    List		li = list::alloc ();
for (i=1; i< 6; i++) list::append (li, i); list::insert (li, 2);
for (i=0; i< list::length (li); i++) { // 123452 showmessage ("1:%d", i+1, list::get (li, i)); }
list::remove_pos (li, 3); for (i=0; i< list::length (li); i++) { // 12352 showmessage ("2:%d", i+1, list::get (li, i)); }
list::remove (li, 2); for (i=0; i< list::length (li); i++) { // 135 showmessage ("3:%d", i+1, list::get (li, i)); }
list::release (li); }

Parameter rmAll since R1396, 25.6.2009

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

append
insert
remove_pos
clear

static int remove_pos(List li, int pos)

Remove a position from the list. List positions are 0-based, meaning the first element has the position 0, the last the position-1.

Name Type Default Description
Return int   1 action successful, 0 otherwise
li List - List
pos int - 0-based delete position

The example illustrates the functioning of remove and remove_pos

int main ()
{
    int		i;
    List		li = list::alloc ();
for (i=1; i< 6; i++) list::append (li, i); list::insert (li, 2);
for (i=0; i< list::length (li); i++) { // 123452 showmessage ("1:%d", i+1, list::get (li, i)); }
list::remove_pos (li, 3); for (i=0; i< list::length (li); i++) { // 12352 showmessage ("2:%d", i+1, list::get (li, i)); }
list::remove (li, 2); for (i=0; i< list::length (li); i++) { // 135 showmessage ("3:%d", i+1, list::get (li, i)); }
list::release (li); }


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

append
insert
remove
clear

static int clear(List li)

Remove all elements of the list

Name Type Default Description
Return int   1 action successful, 0 otherwise
li List - Liste

list::clear (li);


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

append
insert
remove
remove_pos

static int reload(long classid, long reloadAll = 0)

Reload the data records of a panel list. To reload the complete list, set reloadAll to 1. If you want only to update the linkbuttons of the list(s), you can use the command placeholder::update_link_states.

Name Type Default Description
Return int   0 or Error code
classid int - Palettennummer specified by Werk II
0 - update all open panels
reloadAll int 0 Reload complete list?

0 : No, only reload list entries
1 : Yes, reload the complete list

Reload the panel 'Product Pool'

err_code = placeholder::reload (3);

Parameter reloadAll neu seit Version 2.1 R 684, 25 April 2008

priint:comet InDesign® Plug-Ins, comet_pdf

placeholder::update_link_states, placeholder::reload_panel

static int classid(List li)

ClassID of the list entries. Using this class will initialise the list (list::alloc).

Name Type Default Description
Return int   0 or ClassID.
li List - Lists the class ID of which is to be ascertained


priint:comet InDesign® Plug-Ins, comet_pdf

static int index(List li)

Which IDs are contained in the list. The list is updated with this value.

Name Type Default Description
Return int   0 : Undefined
1 : ID
2 : ID2
3 : ID3
li List - List the index type of which is to be ascertained


priint:comet InDesign® Plug-Ins, comet_pdf

static int complete(List li)

Does the list contain all the IDs of the panel, or only the selected entries?

Name Type Default Description
Return int   0 : Only selected entries
1 : All entries of the panel
li List - List


priint:comet InDesign® Plug-Ins, comet_pdf

static char* gettext(
  List li,
  long index,
  char* attribute,
  char* result)

Get the value of the list element. The requestable elements are dependent on the ClassID of the list.

If the list was created as to be a panel list (alloc with ClassID) only its class id, selection type and length are used. The results are taken from panel directly, not from the current list content.

If the list was created as to be a common list, the given attribute is ignored and the result is taken from the list.

Palette ClassId Name Type
Product pool kPanelProducts ID int
ID2 int
ID3 int
StringID, STRINGID and since v3.1 R1800 with postfix 1, 2, 3 for Multi-StringIDs char*
Num char*
Name char*
Depth int
ClassID int
ImageID int
StatementID int
HasPlacement int
DocID int
Masterpage char*
Grid char*
GridElement char*
GridID int
GridElementID int
PageitemID, template of product int
Previews kPanelPreviews ID int
ID2 int
ID3 int
StringID, STRINGID and since v3.1 R1800 with postfix 1, 2, 3 for Multi-StringIDs char*
Key int
Key2 int
Key3 int
MyClassID int
ToDelete int
Width int
Height int
Resolution int
BitDepth int
Path char*
FileName char*
Format char*
Column1 char*
Column2 char*
Column3 char*
Text char*
ImageAlign int
ImageSize float
ClipIndex int
ClipFlags int
ClipToFrame int
ClipTolerance float
ClipMinPathsize float
ClipInset float
AlphaIndex int
AlphaChannel string
Templates kPanelPageitems ID int
ID2 int
ID3 int
ToDelete int
Name char*
Type char*
Mandant char*
State char*
Description char*
Left float
Top float
Right float
Bottom float
Publikationen kPanelPublications see Publications-Tags, at this point only the panel specific tags are sensfull of course. It' allowed to use parent. tags here.

Name Type Default Description
Return String or char*   (Depends on parameter result) Attribute value or empty. The result is a pointer to result. When type of result is char* the pointer must have adequate allocated memory (char[100], alloc (100)).
li List - List
index int - 0-based list index
attribute String or char* - Attributname

int and float values are converted into strings automatically. If you want get int or float values, use getint resp getfloat instead of gettext.
result String or char* - Reserved memory for the result.

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

The example shows the StringID for every product marked with the "eye".

int main ()
{
    char 	s1[512];
    List 	prod 	= list::alloc (3,1,1);
    int	i	= 0;
for (i=0; i<list::length (prod); i++) { list::gettext (prod, i, "StringID", s1);
showmessage (s1); }
return 0; }


priint:comet InDesign® Plug-Ins, comet_pdf

static int getint(
  List li,
  long index,
  char* attribute)

Get the value of a list element as an integer. The requestable elements are dependent on the ClassID of the list. If the attribute contains a text value, the result of the call is undefined.

If the list was created as to be a panel list (alloc with ClassID) only its class id, selection type and length are used. The results are taken from panel directly, not from the current list content.

If the list was created as to be a common list, the given attribute is ignored and the result is taken from the list.

Name Type Default Description
Return int   Attribute value
li List - List
index int - 0-based list index
attribute String or char* - name of attribute. You should only take values marked in the above list above list as to be int Other values may cause InDesing to crash!


priint:comet InDesign® Plug-Ins, comet_pdf

static float getfloat(
  List li,
  long index,
  char* attribute)

Get the value of a list element as a decimal. The requestable elements are dependent on the ClassID of the list. If the attribute contains a text value, the result of the call is undefined.

If the list was created as to be a panel list (alloc with ClassID) only its class id, selection type and length are used. The results are taken from panel directly, not from the current list content.

If the list was created as to be a common list, the given attribute is ignored and the result is taken from the list.

Name Type Default Description
Return float   Attribute value
li List - List
index int - 0-based list index
attribute String or char* - name of attribute. You should only take values marked in the above list above list as to be float Other values may cause InDesing to crash!

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


priint:comet InDesign® Plug-Ins, comet_pdf

static int open_tree(int panel, int depth)

Open all entries of a panel.

Name Type Default Description
Return int   0 or error code
panel int - What list to open?

kPanelProducts (=3) : Product pool

No more panels supported for now!

To get the panelIDs, use the include #include "internal/panels.h".
depth int - Maximum depth

0 : Close all entries
-1 : Open entries one level
-2 : Open entries like deepest level
-3 : Open all entries
-4 : Close all entries
othwise : Open all entries up to this level. Already opened entries of lower levels are kept open.

#include "internal/panels.h"

Version 3.1 R1977, 25.06.2010

priint:comet InDesign® Plug-Ins, comet_pdf

static int get_autoload(int classID = 3)

Is the "autoload"-Button of the requested panel activated or not? The function only supports the ProductPool panel (classID 3). Otherwise 1 is returned. Under InDesign® Server the fucntion returns 1.

Name Type Default Description
Return int   1 : Yes, the button is activated (red), classIDs not equal 3, InDesign® Server
0 : No
classID int 3 ClassID of requested panel. Only the product pool (classID 3) is supported for now.

#include "internal/panels.h"

v3.3 R3601, 5. Apr. 2013

priint:comet InDesign® Plug-Ins, comet_pdf

static int set_autoload(int classID = 3, int newState = 1)

Set the "autoload"-Button of the requested panel. The function only supports the Product Pool panel (classID 3). For all other panels and under InDesign® Server the functions does nothing.

Name Type Default Description
Return int   Old state
classID int 3 ClassID of requested panel. Only the product pool (classID 3) is supported for now.
newState int 1 new state

0 : inactive (gray)
1 : active (green)

v3.3 R3601, 5. Apr. 2013

priint:comet InDesign® Plug-Ins, comet_pdf

static char* to_xml(List list, char* rootElementName = "integers")

Generate a XML structure of a List 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 List - object
rootElementName String or char * integers name of the root element

4.0.5 R9650

static List from_xml(char* xml)

Create a List object from a xml structure.

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 List   object of type List. This list must be released using productlist::release.
xml String or char * - xml structure

4.0.5 R9650

static int add_all(
  List target,
  List 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 List - target list  
src List - source list  
deleteFromSource 0 delete elements from source  

4.0.5 R9700

static int sort(List li, int direction = 0)

Sort a list.

Name Type Default Description
Return int   0 or error code
li List - List to sort
direction int 0 sort direction

0 : ascent
1 : descent

int main ()
{
    List li = list::alloc ();
    int i;
list::insert (li, 12); list::insert (li, 20); list::insert (li, 9); list::insert (li, 3); list::insert (li, 42);
wlog ("", "sort ascent\n"); list::sort (li); for (i = 0; i < list::length (li); i++) wlog ("", "%d\t%d\n", i+1, list::get (li, i)); wlog ("", "\n\n");
wlog ("", "sort descent\n"); list::sort (li, 1); for (i = 0; i < list::length (li); i++) wlog ("", "%d\t%d\n", i+1, list::get (li, i)); wlog ("", "\n\n");
return 0; }

v4.0.5 R9955, 3. Feb 2016

priint:comet InDesign® Plug-Ins, comet_pdf

This class has no child classes.

The following example can be used for list which have no 0-entry.

int main ()
{
    List	li	= list::alloc ();
    int		i;
for (i=1; i<6; i++) list::insert (li, 3*i);
for (i=list::first (li); i; i=list::next (li)) { showmessage ("%d", i); } list::release (li); }

The following example too can be used for lists that have no 0-entry. Because the lists here are created as ID lists of the panel Product Pool, it is secured : The list plugins only contain entries the first ID of which is > 0.

int main ()
{
    List	li, li2, li3;
    int		id, id2, id3;
li = list::alloc (3, 0, 1);// All IDs li2 = list::alloc (3, 0, 2);// All ID2s li3 = list::alloc (3, 0, 3);// All ID3s
if (!li || !li2 || !li3) { showmessage ("'Product pool not opened."); return 1; }
id = list::first (li); id2 = list::first (li2); id3 = list::first (li3); while (id) { showmessage ("ID=(%d, %d, %d", id, id2, id3);
id = list::next (li); id2 = list::next (li2); id3 = list::next (li3); }
list::release (li); list::release (li2); list::release (li3); }

The third example functions for user-defined lists

int main ()
{
    List	li	= list::alloc ();
    int		i;
    int		val;
for (i = 1; i < 6; i++) list::insert (li, 3*i); for (i = 0; i < list::length (li); i++) { val = list::get (li, i) showmessage ("%d", val); } list::release (li); }

The following example illustrates the functioning of remove and remove_pos

int main ()
{
    int		i;
    List	li = list::alloc ();
for (i=1; i< 6; i++) list::append (li, i); list::insert (li, 2);
for (i=0; i< list::length (li); i++) { // 123452 showmessage ("1:%d", i+1, list::get (li, i)); }
list::remove_pos (li, 3); for (i=0; i< list::length (li); i++) { // 12352 showmessage ("2:%d", i+1, list::get (li, i)); }
list::remove (li, 2); for (i=0; i< list::length (li); i++) { // 135 showmessage ("3:%d", i+1, list::get (li, i)); }
list::release (li); }

Author
Paul Seidel
Version
09.11.2021, 08:27 Uhr
Since
Plugin Version 1.0.12

Alphabetic index HTML hierarchy of classes or Java