• <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
      • Code Folding
      • Debugging CSPro Applications
      • Declaration Section
        • Compiler Mode
        • Variables
        • Alias Statement
        • User-Defined Functions
        • Array Object
        • Audio Object
        • Case Object
        • Document Object
        • File Object
        • Freq Object
        • Geometry Object
        • HashMap Object
        • Image Object
        • List Object
        • Map Object
        • Pff Object
        • SystemApp Object
        • ValueSet Object
      • Procedural Sections
      • Logic
      • Language Elements
    • Data Entry Module
    • Batch Editing Applications
    • Tabulation Applications
    • Data Sources
    • CSPro Statements and Functions
    • Templated Reporting System
    • HTML and JavaScript Integration
    • Action Invoker
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataViewer>
  • <TextView>
  • <TblView>
  • <CSFreq>
  • <CSDeploy>
  • <CSPack>
  • <CSDiff>
  • <CSConcat>
  • <Excel2CSPro>
  • <CSExport>
  • <CSIndex>
  • <CSReFmt>
  • <CSSort>
  • <ParadataConcat>
  • <ParadataViewer>
  • <CSCode>
  • <CSDocument>
  • <CSView>
  • <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 object's values (similarly to accept) and returns the index of the operator's selection.
sortSorts the List object's values in ascending or descending order.
 
getLabelReturns the symbol's label.
getNameReturns the symbol's name.
getJsonReturns the symbol's metadata and value represented in JSON.
getValueJsonReturns the symbol's value represented in JSON.
updateValueFromJsonModifies the symbol based on a JSON representation of the value.
In addition to these object functions, List objects can be filled when used as arguments to functions such as dirlist, keylist, and HashMap.getKeys.
Assignments
List objects can be assigned to other List objects, which will replace the initial List with the values of the assigned List:
list_name = another_list_name;
Individual elements of List objects 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;
When a List is used as an argument to a user-defined function, it is passed by reference.
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