• <GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
    • Data Entry Module
    • Batch Editing Applications
    • Tabulation Applications
    • Data Sources
    • CSPro Statements and Functions
      • Statement Format Symbols
      • Alphabetical List of Functions and Statements
      • List of Reserved Words
      • Deprecated Features
      • Declaration Statements
      • Symbol Functions
      • Item Functions
      • Array Object
      • Audio Object
      • Barcode and QR Codes
      • Case Object
      • Document Object
      • File Object
      • Freq Object
      • Geometry Object
      • HashMap Object
      • Image Object
      • List Object
        • List Statement
        • List.add Function
        • List.insert Function
        • List.seek Function
        • List.remove Function
        • List.removeDuplicates Function
        • List.removeIn Function
        • List.clear Function
        • List.length Function
        • List.show Function
        • List.sort Function
      • Map Object
      • Path
      • Pff Object
      • SystemApp Object
      • ValueSet Object
      • Program Control Statements
      • Assignment Statements
      • Data Entry Statements and Functions
      • Batch Edit Statements
      • Numeric Functions
      • String Functions
      • Multiple Occurrence Functions
      • General Functions
      • Date and Time Functions
      • External File Functions
      • Synchronization 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.insert Function

Format
i = list_name.insert(index, value ‖ list_name);
Description
The List.insert function inserts a single value (the numeric or string expression value) or a List of values (list_name) at the position in the List referenced by the numeric expression index. The type of the inserted value or List must match the type of the receiving List. List index values are one-based, so the index must be between 1 and one past the length of the List. If the index is 1, the values are inserted at the beginning of the List. If the value is List.length() + 1, the values are inserted at the end of the List (as would happen with the List.add function).
Return Value
The function returns the number of the values inserted into the List. The function returns 0 if the index is not valid. If the List is read-only, the function returns default.
Example
List string eligible_head_names;

do numeric counter = 1 while counter <= count(PERSON_REC)

   
if AGE(counter) >= 15 and USUAL_MEMBER(counter) = 1 then

       
// insert the names in sorted order
        numeric insert_index;

       
do insert_index = 1 while insert_index <= eligible_head_names.length()
           
and eligible_head_names(insert_index) <= NAME(counter)
       
enddo;

        eligible_head_names.
insert(insert_index, NAME(counter));

   
endif;

enddo;
See also: List Object, List.add Function