• <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
      • Map Object
      • Path
      • Pff Object
      • SystemApp Object
      • ValueSet Object
        • ValueSet Statement
        • ValueSet.add Function
        • ValueSet.remove Function
        • ValueSet.clear Function
        • ValueSet.length Function
        • ValueSet.randomize Function
        • ValueSet.show Function
        • ValueSet.sort Function
      • 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>

ValueSet.add Function

Format
i = valueset_name.add(label, from_codeʃ, to_code ‖ special_valueʅ
                     
ʃ, image := image_filenameʅ
                     
ʃ, textColor := colorʅ);
i = valueset_name.add(valueset_nameʃ, from_codeʅʃ, to_codeʅ);
Description
The ValueSet.add function adds one or more values to the end of a ValueSet object. The type of the added code or value set must match the type of the receiving value set.
In the first version, you provide a string expression label and either a numeric or string expression from_code, which must match the type of the value set. For numeric value sets, it is possible to specify a numeric expression to_code, which creates a range, or a special_value, which is then associated with the from_code. Using named arguments, you can provide a string expression, image_filename, to specify the filename of an image to be shown as a value set image. You can also specify the text color of the value by providing a string expression color that contains a HTML color name (like "red") or a hex color code (like "#ff0000").
In the second version, you provide a valueset_name. This adds all of the values from that value set to the receiving value set. If you specify a from_code or to_code, then only the values in that range will be added to the receiving value set.
Return Value
The function returns the number of the values added to the value set. If the value set is read-only, the function returns default.
Example 1
PROC SUPERVISOR_MENU

onfocus

   
ValueSet string menu_valueset = SUPERVISOR_MENU_VS;

   
if CAN_SYNC = 1 then
        menu_valueset.
add(SYNC_MENU_VS);
   
endif;

   
forcase HOUSEHOLD_DICT do
        menu_valueset.
add("Review " + getcaselabel(HOUSEHOLD_DICT), key(HOUSEHOLD_DICT));
   
endfor;

   
setvalueset(SUPERVISOR_MENU, menu_valueset);
Example 2
PROC OCCUPATION_MINOR

onfocus

   
numeric first_occupation_code = OCCUPATION_MAJOR * 100;
   
numeric last_occupation_code = first_occupation_code + 99;

   
ValueSet occupation_minor_valueset;
    occupation_minor_valueset.
add(OCCUPATION_MINOR_VS1, first_occupation_code, last_occupation_code);
   
setvalueset(OCCUPATION_MINOR, occupation_minor_valueset);
See also: ValueSet Object