• <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>

persistent Variable Modifier

Format
persistent variable_type variable1ʃ, ..., variableNʅ;
Description
The persistent variable modifier is used when declaring a variable to indicate that the variable's value should retain its value from one run of an application to another.
The variable's initial value can be specified in logic. This value will be used to initialize the variable when no value exists from a previous application run. Otherwise, the variable's initial value will come from its value at the end of the previous application's run. If no initial value is given and no previous value exists, the variable starts in its initial default state (e.g., 0 for numeric variables, "" for string variables, etc.). The storage of values is case-sensitive by variable name, so a variable named x will not be initialized with a value from a variable named X.
The file from which these values are saved and loaded can can be modified by altering the CommonStore attribute of a PFF file. Because the CommonStore file is not an encrypted file, it is best not to store sensitive information using persistent variables.
If the CommonStore has a value for a persistent variable but that value is not appropriate for the variable type, a runtime error message will display and the value will not be applied. This could occur, for example, if a persistent string is modified to a persistent numeric and the previous value, while valid for a string, may not be valid for a numeric variable.
Persistent variables declared locally (not in PROC GLOBAL) are not reset upon revisiting the procedure, function, or scoped block, which is the default behavior for non-persistent variables. If using a persistent variable locally, that name cannot be reused for another persistent variable elsewhere in logic.
The persistent modifier can be used when declaring variables of types:
  • numeric
  • string, alpha
  • Array, Audio, Document, Geometry, HashMap, Image, List, SystemApp, ValueSet
Example 1
PROC EA

preproc

   
persistent string lastSelectedEA;
    EA = lastSelectedEA;

postproc

    lastSelectedEA = EA;
Example 2
do numeric ctr = 1 while ctr <= 5
   
persistent numeric baseValue = 100;
   
errmsg("%d", inc(baseValue));
enddo;

// expected output on the first run: 101, 102, 103, 104, 105
// expected output on the second run: 106, 107, 108, 109, 110
See also: config Variable Modifier, ensure Variable Modifier