• <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
        • Numeric Statement
        • String Statement
        • Alpha Statement
        • config Variable Modifier
        • ensure Variable Modifier
        • persistent Variable Modifier
        • Visual Values for Numeric Fields
        • Relation Statement
        • Function Named Arguments
        • Function Statement
        • Optional Function Parameters
        • Passing Function Arguments by Reference
        • Additional Examples of User-Defined Functions
        • Dot Notation, Logic Objects, and Namespaces
      • 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
      • 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>

Dot Notation, Logic Objects, and Namespaces

Object Dot Notation
A CSPro logic object is a variable that is similar to the objects that exist in other programming languages that are object-oriented. CSPro logic is not fully object-oriented, but some variables have functions—sometimes called methods—that can be called by using both the variable name as well as the function name.
variable_name.function_name();
The following objects have functions that can be called on the object:
  • Array
  • Audio
  • Case
  • Document
  • File
  • Freq
  • Geometry
  • HashMap
  • Image
  • List
  • Map
  • Pff
  • Report
  • SystemApp
  • ValueSet
A list of available functions can be found in each of those summary pages.
One way to understand dot notation is to think of it as a shorthand way to specify what variable should be used when performing an operation. For example, here are two ways to work through the elements of a list:
List string household_members;

// CSPro 7.2 and earlier:
do numeric counter = 1 while counter <= length(household_members)

// CSPro 7.3 and later:
do numeric counter = 1 while counter <= household_members.length()
Unlike other CSPro functions, the functions that are associated with an object will not show as blue and they are not reserved words.
Using a dot specifies that you are accessing a function or variable (property) of the object. For example, a value set object contains two internal variables, codes and labels, both of which are lists, that can be accessed as in:
List string province_labels = PROVINCE_VS.labels;
numeric selected_province = province_labels.show("Select a province");
This could also be written using multiple dots:
numeric selected_province = PROVINCE_VS.labels.show("Select a province");
Namespace Dot Notation
When using dot notation on objects, the function generally operates on the properties of the object. Some functions, called static in many programming languages, do not require an instance of an object to run but still require using dot notation.
Similarly, many programming languages have the concept of namespaces, often used to group related functionality. In CSPro logic, some functions are defined in namespaces, and the Action Invoker makes heavy use of namespaces. To execute functions within a namespace, you must use dot notation. For example:
// function in the logic's Barcode namespace
BLOOD_SAMPLE = Barcode.read("Scan the blood sample barcode");

// action in the Action Invoker's File namespace
string manualText = CS.File.readText(path := "manual.txt");
See also: Variables