• <Helps for GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
      • Introduction to CSPro Language
      • Data Requirements
      • CSPro Program Structure
      • Programming Standards
      • Debugging CSPro Applications
      • Declaration Section
        • Compiler Mode
        • Variables
        • Alias Statement
        • Ensure Statement
        • User-Defined Functions
        • Array Object
        • Audio Object
        • File Object
        • Freq Object
        • HashMap Object
        • List Object
        • Map Object
        • Pff Object
        • SystemApp Object
        • ValueSet Object
      • Procedural Sections
      • Logic
      • Language Elements
    • Data Entry Module
    • Batch Editing Applications
    • Tabulation Applications
    • CSPro Statements and Functions
    • Templated Reporting System
    • Appendix
  • <Helps for CSEntry>
  • <Helps for CSBatch>
  • <Helps for CSTab>
  • <Helps for DataViewer>
  • <Helps for TextView>
  • <Helps for TblView>
  • <Helps for TRSWin>
  • <Helps for CSDeploy>
  • <Helps for CSPack>
  • <Helps for CSFreq>
  • <Helps for CSSort>
  • <Helps for CSExport>
  • <Helps for CSReFmt>
  • <Helps for CSDiff>
  • <Helps for CSConcat>
  • <Helps for TRSSetup>
  • <Helps for ParadataViewer>
  • <Helps for ParadataConcat>
  • <Helps for CSIndex>
  • <Helps for Excel2CSPro>
  • <Helps for CSWeb>

List Object

In logic, a list is similar to an one-dimensional array but without a defined size. That is, a list is a collection of values, either numeric or string, that can grow or shrink in size.
Functionality
A list is a CSPro logic object and the following functions can be called via dot notation:
FunctionDescription
addAdds a single value, or a list of values, to the end of a list.
clearRemoves all values from the list.
insertInserts a single value, or a list of values, at a given position in the list.
lengthReturns the size of the list.
removeRemoves the value at a given position from the list.
removeDuplicatesRemoves duplicate values from the list.
removeInRemoves values from the list that are specified in an in list.
seekReturns the index of a specified value.
showDisplays the list's values (similarly to accept) and returns the index of the operator's selection.
sortSorts the list's values in ascending or descending order.
In addition to these object functions, lists can be filled when used as arguments to functions such as dirlist, keylist, and hashmap.getKeys.
Lists can be assigned to other lists, which will replace the initial list with the values of the assigned list:
list_name = another_list_name;
Individual elements of lists can also be modified or added by using a one-based index:
list_name(index) = modify_value;
list_name(list_name.length() +
1) = add_value;
Example
list string respondent_query;

do numeric counter = 1 while counter <= count(NAME)
    respondent_query.add(NAME(counter));
enddo;

numeric respondent_index = respondent_query.show("Who in the household is responding to questions?");
See also: Array Object, HashMap Object, ValueSet Object