Integer lists.

Here you will find examples to use list64.

Version :
17.12.2024, 12:52 Uhr

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

static List64 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 list64::release.

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

Name Type Default Description
Return List64   Created list of the 0
classid int - Class ID of the panel
selection_type int kAll kAll : All datasets of the panel
kEyeMarked : Only the eye marked datasets of the panel
kSelected : Selected panel entries only
id_index int 1 Which IDs are to be fetched? 1 = ID, 2 = ID2, 3 = ID3
#include "internal/panels.h"

Create a list with the IDs of the marked products

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

v4.0.5 R9955, 3. Feb 2016

priint:comet InDesign® Plug-Ins, comet_pdf

static List64 alloc()

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

Name Type Default Description
Return List64   Created list or 0

Create a new empty list

List64 = list64::alloc ();
 	:
list64::release (li);

v4.0.5 R9955, 3. Feb 2016

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

static int release(List64 li)

Delete a created list again using list64::alloc

Name Type Default Description
Return int   -
li List64 - List64 to be deleted

v4.0.5 R9955, 3. Feb 2016

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

static int length(List64 li)

Ascertain the number of elements of a list

Name Type Default Description
Return int   Number of entries in the list
li List64 - List64
int len = list64::length (li);

v4.0.5 R9955, 3. Feb 2016

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

static int first(List64 li)

Get the first entry of a non-empty list

Name Type Default Description
Return int   First value of the list
li List64 - List64 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 ()
{
    List64		li	= list64::alloc ();
    int			i;
for (i=1; i<6; i++) list64::insert (li, 3*i); for (i=list64::first (li); i; i=list64::next (li)) { showmessage ("%d", i); } list64::release (li); }

v4.0.5 R9955, 3. Feb 2016

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

next
prev
last
get
get_pos

static int next(List64 li)

Get the next entry in a list.

Name Type Default Description
Return int   Next value of the list
li List64 - List64 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 ()
{
    List64		li	= list64::alloc ();
    int			i;
for (i=1; i<6; i++) list64::insert (li, 3*i); for (i=list64::first (li); i; i=list64::next (li)) { showmessage ("%d", i); } list64::release (li);

v4.0.5 R9955, 3. Feb 2016

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

first
prev
last
get
get_pos

static int prev(List64 li)

Get the previous entry in the list.

Name Type Default Description
Return int   Value of the preceding entry in the list
li List64 - List64 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 ()
{
    List64		li	= list64::alloc ();
    int			i;
for (i=1; i<6; i++) list64::insert (li, 3*i); for (i=list64::last (li); i; i=list64::prev (li)) { showmessage ("%d", i); } list64::release (li); }

v4.0.5 R9955, 3. Feb 2016

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

first
next
last
get
get_pos

static int last(List64 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 List64 - List64 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 ()
{
    List64		li	= list64::alloc ();
    int			i;
for (i=1; i<6; i++) list64::insert (li, 3*i); for (i=list64::last (li); i; i=list64::prev (li)) { showmessage ("%d", i); } list64::release (li);

v4.0.5 R9955, 3. Feb 2016

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

first
next
prev
get
get_pos

static int get_pos(
  List64 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. List64 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 List64 - List64 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	= list64::get_pos (li, val [, setPos]);

v4.0.5 R9955, 3. Feb 2016

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

get

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

Get the i-te element of the list. List64 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 List64 - List64 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	= list64::get (li, pos [, setPos]);

v4.0.5 R9955, 3. Feb 2016

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

get_pos

static int append(List64 li, int val)

Append elements to the list

Name Type Default Description
Return int   1 action successful, 0 otherwise
li List64 - List64 to which the append to be made
val int - Value to be appended
list64::append (li, k);

v4.0.5 R9955, 3. Feb 2016

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

insert
remove
remove_pos
clear

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

Insert element in the list. List64 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 List64 - List64 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
list64::insert (li, 3, 0);

v4.0.5 R9955, 3. Feb 2016

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

append
remove
remove_pos
clear

static int remove(
  List64 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 List64 - List64 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;
    List64		li = list64::alloc ();
for (i=1; i< 6; i++) list64::append (li, i); list64::insert (li, 2);
for (i=0; i< list64::length (li); i++) { // 123452 showmessage ("1:%d", i+1, list64::get (li, i)); }
list64::remove_pos (li, 3); for (i=0; i< list64::length (li); i++) { // 12352 showmessage ("2:%d", i+1, list64::get (li, i)); }
list64::remove (li, 2); for (i=0; i< list64::length (li); i++) { // 135 showmessage ("3:%d", i+1, list64::get (li, i)); }
list64::release (li); }

v4.0.5 R9955, 3. Feb 2016

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

append
insert
remove_pos
clear

static int remove_pos(List64 li, int pos)

Remove a position from the list. List64 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 List64 - List64
pos int - 0-based delete position

The example illustrates the functioning of remove and remove_pos

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

v4.0.5 R9955, 3. Feb 2016

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

append
insert
remove
clear

static int clear(List64 li)

Remove all elements of the list

Name Type Default Description
Return int   1 action successful, 0 otherwise
li List64 - Liste
list64::clear (li);

v4.0.5 R9955, 3. Feb 2016

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 ErrorCode
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 Poll'

err_code = list::reload (3);

v4.0.5 R9955, 3. Feb 2016

priint:comet InDesign® Plug-Ins, comet_pdf

placeholder::update_link_states
placeholder::reload_panel

static int classid(List64 li)

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

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

v4.0.5 R9955, 3. Feb 2016

priint:comet InDesign® Plug-Ins, comet_pdf

static int index(List64 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 List64 - List64 the index type of which is to be ascertained

v4.0.5 R9955, 3. Feb 2016

priint:comet InDesign® Plug-Ins, comet_pdf

static int complete(List64 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 List64 - List64

v4.0.5 R9955, 3. Feb 2016

priint:comet InDesign® Plug-Ins, comet_pdf

static char* gettext(
  List64 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
Perennials kPanelFlowers ID int
ID2 int
ID3 int
StringID, STRINGID and since v3.1 R1800 with postfix 1, 2, 3 for Multi-StringIDs char*
LatinName char*
GermanName char*
FamilyName char*
ImagePath char*
Transmission planning kPanelTV ID int
ID2 int
ID3 int
StringID, STRINGID and since v3.1 R1800 with postfix 1, 2, 3 for Multi-StringIDs char*
Start char*
StartTime char*
StartDate char*
End char*
EndTime char*
EndDate char*
State int
ToDelete int
Sender char*
Title char*
Assessment char*
Module char*
Info1 char*
Info2 char*
Info3 char*
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
Elements kPanelElements ID int
ID2 int
ID3 int
StringID, STRINGID and since v3.1 R1800 with postfix 1, 2, 3 for Multi-StringIDs char*
ProductID int
ProductID2 int
ProductID3 int
Name char*
Value char*
Selfloader char*
ToDelete int
RelatedToID int
Scribble kPanelTVRecherche ID int
ID2 int
ID3 int
StringID, STRINGID and since v3.1 R1800 with postfix 1, 2, 3 for Multi-StringIDs char*
Start char*
StartTime char*
StartDate char*
End char*
EndTime char*
EndDate char*
State int
ToDelete int
Sender char*
Title char*
Bewertung char*
Module char*
Info1 char*
Info2 char*
Info3 char*
Selfloader char*
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
Export groups kPanelExportgroups ID int
ID2 int
ID3 int
StringID, STRINGID and since v3.1 R1800 with postfix 1, 2, 3 for Multi-StringIDs char*
Label char*
Sender char*
Selfloader char*
ToDelete char*
LabelID int
SenderID int
Panel '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 result is of type char*, the pointer must have adequate allocated memory (char[100], alloc (100)).
li List64 - List64
index int - 0-based list index
attribute String or char* - Attributname

int and float values are converted into strings automatically. If yoiu want get int or float values, use getint resp getfloat instead of gettext.
result String or char* - Reserved memory for the result.
#include "internal/panels.h"

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

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

v4.0.5 R9955, 3. Feb 2016

priint:comet InDesign® Plug-Ins, comet_pdf

static int getint(
  List64 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 List64 - List64
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 InDesign to crash!

v4.0.5 R9955, 3. Feb 2016

priint:comet InDesign® Plug-Ins, comet_pdf

static float getfloat(
  List64 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 List64 - List64
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 InDesign to crash!

v4.0.5 R9955, 3. Feb 2016

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 ErrorCode
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"

v4.0.5 R9955, 3. Feb 2016

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 (green), 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.

v4.0.5 R9955, 3. Feb 2016

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)

v4.0.5 R9955, 3. Feb 2016

priint:comet InDesign® Plug-Ins, comet_pdf

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

Sort a list.

Name Type Default Description
Return int   0 or ErrorCode
li List64 - List64 to sort
direction int 0 sort direction

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

v4.0.5 R9955, 3. Feb 2016

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

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

int main ()
{
    List64		li	= list64::alloc ();
    int			i;
for (i=1; i<6; i++) list64::insert (li, 3*i);
for (i=list64::first (li); i; i=list64::next (li)) { showmessage ("%d", i); } list64::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 ()
{
    List64		li, li2, li3;
    int			id, id2, id3;
li = list64::alloc (1, 0, 1);// All IDs li2 = list64::alloc (1, 0, 2);// All ID2s li3 = list64::alloc (1, 0, 3);// All ID3s
if (!li || !li2 || !li3) { showmessage ("'Shrub not opened."); return 1; }
id = list64::first (li); id2 = list64::first (li2); id3 = list64::first (li3); while (id) { showmessage ("ID=(%d, %d, %d", id, id2, id3);
id = list64::next (li); id2 = list64::next (li2); id3 = list64::next (li3); }
list64::release (li); list64::release (li2); list64::release (li3); }

The third example functions for user-defined lists

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

The following example illustrates the functioning of remove and remove_pos

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

Playing with big data:

int main ()
{
    List64			li = list64::alloc ();
    int 			i;
list64::insert (li, 6917529027641081856); list64::insert (li, 6917529027641081860); list64::insert (li, 234); list64::insert (li, 6917529027641081444); list64::insert (li, 9223372036854775807);
wlog ("", "List step 1\n"); for (i = list64::first (li); i; i = list64::next (li)) wlog ("", "step 1 : %d\n", i); wlog ("", "\n\n"); wlog ("", "get_pos ('6917529027641081444') == %d\n", list64::get_pos (li, 6917529027641081444));
list64::insert (li, 7777777777777777777); list64::insert (li, -8888888888888888888, 2); wlog ("", "List step 2\n"); for (i = list64::first (li); i; i = list64::next (li)) wlog ("", "step 2 : %d\n", i); wlog ("", "\n\n");
wlog ("", "List step 2 (reverse)\n"); for (i = list64::last (li); i; i = list64::prev (li)) wlog ("", "step 2r : %d\n", i); wlog ("", "\n\n");
list64::remove (li, 7777777777777777777); list64::remove_pos (li, 2);
wlog ("", "List step 3\n"); for (i = list64::first (li); i; i = list64::next (li)) wlog ("", "step 3 : %d\n", i); wlog ("", "\n\n");
wlog ("", "\n\n"); wlog ("", "sort ascent\n"); list64::sort (li); for (i = 0; i < list64::length (li); i++) wlog ("", "%d\t%d\n", i+1, list64::get (li, i)); wlog ("", "\n\n");
wlog ("", "sort descent\n"); list64::sort (li, 1); for (i = 0; i < list64::length (li); i++) wlog ("", "%d\t%d\n", i+1, list64::get (li, i)); wlog ("", "\n\n");
return 0; }

Author
Matthias Paul Seidel
Version
17.12.2024, 12:52 Uhr
Since
v4.0.5 R9955, 3. Feb 2016

Alphabetic index HTML hierarchy of classes or Java