• <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
      • Procedural Sections
      • Logic
      • Language Elements
        • Version
        • Delimiters
        • Comments
        • Preprocessor
        • Variables and Constants
        • Expressions
        • Operators
        • Files
        • Miscellaneous
    • 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>

Logic Version

Overview
CSPro has two logic versions, and the version you select (using Logic Settings) controls several aspects of how logic is compiled and executed. The primary differences are summarized in the following table, and then described in more detail.
FeatureOriginal VersionCSPro 8.0+ Version
Multiline comments{ }/* */
Verbatim string literals✗supported
Escape sequences in string literals✗supported
String comparisonsIgnores trailing spacesExact string comparison
Multiline Comments
The original style of multiline comments uses braces: { commented code }.
When using logic version CSPro 8.0+, multiline comments start with /* and end with */: /* ... commented code ... */.
String Literals
The original version of string literals does not allow for escape sequences. A few functions have special processing for characters following backslashes; for example, "\n" introduces a new line in an errmsg; "\f" introduces a form feed by filewrite. However, this can lead to unintended results; for example, it is not possible to display the error message "eight\nine\ten" on a single line because the backspace character preceding "nine" would be interpreted as a newline character.
With logic version CSPro 8.0+, escape sequences are processed. An escape sequence begins with a backslash character and is followed by a valid character. Because a backslash begins an escape sequence, if taking an older CSPro application and using a newer logic version, look throughout the code for backslash characters and escape them accordingly. For example, a string like "a\b\c" would be rewritten as "a\\b\\c". Note that the text editor colors escape sequences slightly differently than the other characters in a string literal.
Because escape sequences allow characters to exist in CSPro that were previously not allowed, review how CSPro handles newline characters.
In addition to escape sequences, with logic version CSPro 8.0+, you can use verbatim string literals, which are useful for specifying text that may contain many backslash characters. For example, these two strings are identical:
 "C:\\Program Files (x86)\\CSPro 8.0\\html\\images\\cspro-logo-medium.png" // string literal
@"C:\Program Files (x86)\CSPro 8.0\html\images\cspro-logo-medium.png"      // verbatim string literal
String Comparisons
The original routine to compare strings right-pads strings with space (blank) characters as necessary so that the length of the string does not factor into the comparison. This applies to comparisons using:
  • String comparison functions: compare and compareNoCase
  • String operators: =, <>, <, <=, >=, >, in, and has
  • Statements that can compare strings: recode and when
  • Other functions: List.removeIn
With logic version CSPro 8.0+, strings are compared without any padding. This is desirable for most strings, but when comparing strings against alphanumeric dictionary items, which are right-padded to match the dictionary item length, you will likely want to use the strip function when comparing strings; for example:
if BIRD_NAME = "Bobolink" then        // Original logic version
if strip(BIRD_NAME) = "Bobolink" then // CSPro 8.0+ logic version
Additional Differences
  • The hash function returns the hash value in uppercase when using the original logic version, but in lowercase with logic version CSPro 8.0+.
See also: Logic Settings