Admin Production ni-theme
Current Publication

ListCreate

LabWindows/CVI

ListCreate

ListType ListCreate (size_t itemSize);

Purpose

This function creates a list that holds items of the specified size.

Parameters

Input
Name Type Description
itemSize size_t Pass the size in bytes of the items that the list will hold.

For example, to create a list of doubles:

#include "toolbox.h"
{

double value1 = 5.0;
double value2 = 7.0;
ListType newList;

newList = ListCreate(sizeof(double));

if (newList)

{
ListInsertItem(newList, &value1, END_OF_LIST);
ListInsertItem(newList, &value2, END_OF_LIST);
}

}


The size of every item in the list must be the same. If you want to have a list of items that can be different sizes, make a list of pointers to the items instead.

For example, to make a list of strings:

#include "toolbox.h"
{

char *dog = "dog";
char *cat = "cat";
ListType newList;

newList = ListCreate(sizeof(char *));

if (newList)

{
ListInsertItem(newList, &dog, END_OF_LIST);
ListInsertItem(newList, &cat, END_OF_LIST);
}

}

Return Value

Name Type Description
newList ListType Returns a new empty list.

If there is not enough memory, zero (0) is returned.

Additional Information

Library: Programmer's Toolbox

Include file: toolbox\toolbox.h

LabWindows/CVI compatibility: LabWindows/CVI 4.0 and later

Examples

Refer to the following examples that use the ListCreate function:

  • apps\uirview\uirview.cws

    Open example
  • TDM Streaming\tdmsReader.cws

    Open example
  • toolbox\list.cws

    Open example
  • userint\custctrl\cviogl\ogldemo.cws

    Open example
  • userint\custctrl\pathctrl\simple.cws

    Open example