• <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 Values
      • String Values
      • 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
      • StringWriter 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
    • Text Templates
    • Templated Reporting System
    • HTML, Markdown, and JavaScript Integration
    • Action Invoker
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataManager>
  • <TextView>
  • <TblView>
  • <CSFreq>
  • <CSDeploy>
  • <CSPack>
  • <CSDiff>
  • <CSConcat>
  • <Excel2CSPro>
  • <CSExport>
  • <CSIndex>
  • <CSReFmt>
  • <CSSort>
  • <ParadataConcat>
  • <ParadataViewer>
  • <CSCode>
  • <CSDocument>
  • <CSView>
  • <CSWeb>

Alphabetical List of Functions and Statements

The following table lists functions and statements that can be used in logic. Listings that are marked (CS) are part of the Action Invoker. In addition, some CSPro objects have functions that can be invoked on the object. A list of such functions can be found in the summary pages for each of these objects:
  • Array
  • Audio
  • Case
  • Document
  • File
  • Freq
  • Geometry
  • HashMap
  • Image
  • List
  • Map
  • Pff
  • Report
  • StringWriter
  • SystemApp
  • ValueSet
Function/StatementDescription
absReturns the absolute value of a numeric expression.
acceptReturns the number of a choice from a list made by the data entry operator.
adjlbaAdjusts the lower bound of the CMC of an event based on an age.
adjlbiAdjusts the lower bound of the CMC of an event offset by a number of months.
adjubaAdjusts the upper bound of the CMC of an event based on an age.
adjubiAdjusts the upper bound of the CMC of an event offset by a number of months.
advanceMoves forward field by field to a specified field during data entry.
aliasCreates an aliased name for a dictionary item, typically to shorten or standardize names.
alphaDeclares alphanumeric variables used in the application.
Application.getFormFile (CS)Returns a form file associated with an application or loaded from the disk.
Application.getQuestionnaireContent (CS)Returns the questionnaire content associated with an application, form file, or dictionary.
Application.getQuestionText (CS)Returns the question text associated with an application or loaded from the disk.
ArrayDeclares an Array object for storing a collection of numbers or strings.
askConditionally jumps forward to the next field during data entry.
AudioDeclares an Audio object for recording or playing audio.
averageReturns the average of an item that occurs multiple times.
 
Barcode.readReads a barcode and returns its value as a string.
breakExits a do, while, or for loop early and continues execution with the first statement after the enddo.
 
changekeyboardModifies the keyboard input associated with certain fields.
clearInitializes the memory values of data items defined in external files to zero or blank.
Clipboard.getText (CS)Gets the text on the clipboard.
Clipboard.putText (CS)Puts text onto the clipboard.
closeCloses a previously opened file.
cmcodeReturns the number of months since the year 1900 given a month and year.
compareReturns the alphabetical order (i.e., collating sequence) of two strings using a case-sensitive comparison.
compareNoCaseReturns the alphabetical order of two strings using a case-insensitive comparison.
compressCompresses some number of files into a single ZIP file.
concatJoins two or more strings into one string.
configDeclares string variables prefilled with values defined in the configuration settings.
connectionDetermines whether the device has access to the Internet.
countReturns the number of occurrences for a repeating form or roster.
countcasesReturns the number of cases in an external file that meet a certain criterion.
countnonspecialReturns the number of non-special values in a group of data items.
curoccReturns the current occurrence number for a repeating form, roster, or record.
currentkeyReturns the key (ID string) comprised of the case's current IDs.
 
Data.getCase (CS)Returns a specific case, or the current case, associated with a dictionary.
dateaddCalculates a new date from a starting date and a period of elapsed time.
datediffCalculates the difference between two dates.
datevalidDetermines whether a date in the format YYYYMMDD is valid.
declareDeclares a variable, allowing it to be used in logic prior to it being defined.
decompressDecompresses a ZIP file, extracting some number of files.
delcaseMarks a case for deletion in an external file based on a key.
deleteRemoves a record or item occurrence from the current case.
demodeReturns the current data entry mode.
diagnosticsReturns troubleshooting information about CSPro.
Dictionary.getDictionary (CS)Returns a dictionary associated with an application or loaded from the disk.
dircreateCreates a new directory with the given directory name.
dirdeleteDeletes an empty directory or group of empty directories.
direxistDetermines whether a directory exists.
dirlistReturns a list containing the file and directory listing of the specified directory.
displayDisplays a message (this function has been superceded by errmsg).
doExecutes one or more statements repeatedly while a logical condition remains true or until a logical condition is no longer true.
DocumentDeclares a Document object for storing text or binary files.
 
editConverts a number to a string.
editnoteDisplays the data entry note box for adding or changing.
encodeEncodes special characters to facilitate writing to HTML or CSV files and writing to other formats.
endcaseEnds batch editing for the current case (but outputs the case to file).
endgroupEnds data entry for the current record or group/roster.
endlevelEnds data entry for the current level.
enterEnters data from a secondary form file.
errmsgDisplays or writes a message.
ensureConditionally declares numeric variables used in the application.
execpffStarts another CSPro application.
execsystemStarts another application or process.
execute (CS)Executes an action with the action name specified as an argument.
exitEnds a procedure before normal processing is expected to end.
expReturns the value of e raised to a given power.
exportWrites a record to an export file.
 
FileDeclares one or more File objects used in the application.
File.copy (CS)Copies one or more files.
File.readBytes (CS)Reads a file as binary, returning the entire file's content as bytes.
File.readLines (CS)Reads a file as text, returning the entire file's content as an array of strings.
File.readText (CS)Reads a file as text, returning the entire file's content as a string.
File.writeBytes (CS)Writes bytes as a binary file.
File.writeLines (CS)Writes an array of strings as lines to a text file.
File.writeText (CS)Writes a string as a text file.
fileconcatConcatenates a list of files or a set of files described by a wildcard specification.
filecopyCopies a file to another file.
filecreateCreates a new file with the given file name.
filedeleteDeletes a file or group of files.
fileemptyDetermines whether a file exists but is empty.
fileexistDetermines whether a file exists.
filenameReturns the file name currently associated with a dictionary or a File.
filereadReads a text line from a File into an item or variable.
filerenameChanges the name of a file.
filesizeReturns the size of a file in bytes.
filetimeReturns the last modification date/time of a file or a directory.
filewriteWrites a line of text to a File.
findDetermines the existence of a case in a data file that matches a condition.
forLoops through multiple records or items.
for (dictionary)Loops through the cases selected during a selcase operation.
forcaseLoops through the cases in an external file.
FreqDeclares a Freq object that allows for the creation of frequencies.
functionDeclares a user-defined function.
 
GeometryDeclares a Geometry object for storing vector geometry.
getbluetoothnameReturns the name of the device as broadcast to other Bluetooth devices.
getbufferReturns a string containing the contents of a data item.
getcapturetypeReturns the capture type associated with a field.
getcaselabelReturns a string containing a case's label (the text that appears in a case listing).
getdeckRetrieves a value from a DeckArray used for editing data.
getdeviceidReturns a string that contains a unique value that identifies the device.
getimageReturns the filename of a value set image.
getlabelReturns the label of a dictionary symbol or text associated to symbol's value.
getlanguageReturns the current language being used while in data entry mode.
getnoteReturns a field or case note.
getocclabelReturns an occurrence label associated with a repeating dictionary item or a roster.
getoperatoridReturns the text entered in the operator ID.
getorientationReturns the display orientation.
getosReturns information about the operating system, including whether it is running Android or Windows.
getpropertyReturns information about an application or field property.
getrecordReturns the name of the record containing a particular item.
getsymbolReturns the name of the current procedure being executed.
getusernameReturns the name of the user logged into Windows or the Android device account.
getvalueReturns the value of a numeric variable whose identity is only known at runtime.
getvaluealphaReturns the value of a alpha variable whose identity is only known at runtime.
getvaluenumericReturns the value of a numeric variable whose identity is only known at runtime.
gpsControls and returns values from a GPS receiver.
 
hasDetermines whether any of a group of repeating items is within a range of values.
hashCalculates the hash value of a string.
Hash.createHash (CS)Creates a hash value based on the contents of a file, text, or bytes.
Hash.createMd5 (CS)Creates a MD5 hash based on the contents of a file, text, or bytes.
HashMapDeclares a HashMap object for storing a collection of numbers or strings in an associative array.
hideoccVisually hides an occurrence row in a roster.
highReturns the maximum value in a group of numeric expressions.
highlightedReturns whether a field is on path or reached during data entry.
htmldialogDisplays a custom dialog designed in HTML and JavaScript.
 
ifExecutes statements conditionally.
ImageDeclares an Image object for storing and manipulating images.
imputeAssigns a value to a data item and logs the frequency of assignments.
inDetermines whether a variable is within a range of values.
inadvanceIndicates if an advance is in progress.
incIncrements a numeric item.
insertCreates a record or item occurrence in the current case.
intReturns the integer portion of a numeric expression.
invaluesetDetermines whether a data item's value is within the item's value set.
invokeExecutes a user-defined function using runtime binding.
ischeckedReturns whether a code is checked as part of a check box field's selections.
ispartialDetermines whether a case was opened from a partial case or not.
isverifiedDetermines whether a case was verified by double-keying.
 
JS.evalEvaluates JavaScript in the global execution context.
JS.getValueConverts a JavaScript variable or property to its CSPro equivalent.
JS.getValueJsonReturns the JSON representation of a JavaScript variable or property.
JS.hasValueReturns whether a JavaScript variable or property is defined (not undefined).
JS.invokeExecutes a JavaScript function that exists in the global execution context with any CSPro arguments converted to their JavaScript equivalents.
JS.setValueConverts a CSPro variable to its JavaScript equivalent and adds this as a variable to the global scope, or sets an object's property.
JS.setValueFromJsonCreate a JavaScript variable using JSON and adds it as a variable to the global scope, or sets an object's property.
 
keyReturns the key (ID string) of the case's IDs as they existed when the case was last loaded or written.
keylistReturns a list containing the keys (ID strings) of cases in a file.
killfocusDeclares that the following statements are executed after the object stops being active.
 
lengthReturns the length of a dictionary item or a string.
ListDeclares a List object for storing a collection of numbers or strings.
loadcaseReads a case from an external file into memory (usually based on a key).
loadsettingReturns a string containing a setting saved using the savesetting function.
locateFinds but does not load a case in an external file that matches a condition.
Localhost.mapActionResult (CS)Creates a localhost URL that provides access to the result of an Action Invoker action.
Localhost.mapFile (CS)Creates a localhost URL to access a file on the local file system.
Localhost.mapSymbol (CS)Creates a localhost URL that provides access to a binary symbol's data.
Localhost.mapText (CS)Creates a localhost URL that provides access to supplied text.
logReturns the base-10 logarithm of a numeric expression.
Logic.eval (CS)Evaluates and runs one or more logic statements.
Logic.getSymbol (CS)Returns a symbol's metadata and value.
Logic.getSymbolMetadata (CS)Returns a symbol's metadata.
Logic.getSymbolValue (CS)Returns a symbol's value.
Logic.invoke (CS)Executes a user-defined function using runtime binding.
Logic.setSymbolValue (CS)Modifies a symbol based on a JSON representation of the value.
logtextWrites a user-defined message to the paradata log file.
lowReturns the minimum value in a group of numeric expressions.
 
maketextReturns a formatted string with inserted values.
MapDeclare a Map variable that can be used to display interactive maps.
maxReturns the maximum value of an item that occurs multiple times.
maxoccReturns the maximum number of occurrences of a multiply occurring object.
maxvalueReturns the maximum value in an item's range of acceptable values.
Message.formatText (CS)Creates a formatted string with inserted values using base text specified by a message number or text.
Message.getText (CS)Returns the base (unformatted) text for a message.
minReturns the minimum value of an item that occurs multiple times.
minvalueReturns the minimum value in an item's range of acceptable values.
moveMoves backwards or forwards to a specified field during data entry.
 
nextEnds a do, while, or for loop early and continues execution with the next iteration of the loop.
nmembersReturns the number of cases selected during a selcase operation.
noccursReturns the number of occurrences for a repeating form or roster.
noinputPrevents input for the current field during data entry.
numericDeclares numeric variables used in the application.
 
OnActionInvokerResultProvides a way to process a result from the Action Invoker when called from CSPro logic.
OnChangeLanguageProvides control over actions to occur after a user has changed the language.
OnCharAllows users to trap characters in order to perform special actions or to change the action of the character.
onfocusDeclares that the following statements are executed just before an object becomes active.
OnKeyAllows users to trap keystrokes in order to perform special actions or to change the action of the key.
onoccchangeDeclares that the following statements are executed when the group's current occurrence changes.
OnRefusedProvides a way to override the selection of a refused value.
OnStopProvides control over stopping or exiting data entry.
OnSyncMessageAllows users to respond to a message sent by a Bluetooth client using syncmessage.
OnSystemMessageProvides a way to override the displaying of system error messages.
OnViewQuestionnaireProvides a way to override the displaying of the questionnaire view.
openOpens a dictionary or external file.
 
paradataPerforms an action on the paradata log.
Path.concatCombines multiple strings into one string representing a file path.
Path.createDirectory (CS)Creates a directory if it does not already exist.
Path.getDirectoryListing (CS)Returns information about the paths in a directory.
Path.getDirectoryNameExtracts the directory name from a file path.
Path.getExtensionExtracts the file extension from a file path.
Path.getFileNameExtracts the file name from a file path.
Path.getFileNameWithoutExtensionExtracts the file name without its extension from a file path.
Path.getPathInfo (CS)Returns information about a directory or file path.
Path.getRelativePathReturns a relative path based on a path's location relative to a directory.
Path.getSpecialPaths (CS)Returns special paths, including the download and temp directories.
Path.selectFile (CS)Shows the operator a visual listing of the file system and returns the path of the file the operator selected.
Path.selectFileShows the operator a visual listing of the file system and returns the path of the file the operator selected.
Path.showFileDialog (CS)Displays a dialog with a visual listing of the file system, allowing the user to select a file to open or to create a file to save.
pathconcatCombines multiple strings into one string representing a file path.
pathnameReturns the path of various special directories.
PffDeclares a Pff object that can be used to dynamically modify the way other CSPro applications are executed.
posReturns the position of a string within another string.
poscharReturns the position of any of a series of characters within another string.
preprocDeclares that the following statements are executed at the beginning of a block.
PROCDeclares the beginning of a new procedure.
promptPrompts the operator to enter an alphanumeric string, also supporting a password masking option.
protectModifies the protected property of a field.
postprocDeclares that the following statements are executed at the end of a block.
publishdateReturns the date and time that the code was compiled (which can be used to determine when a .pen file was created).
putdeckPuts a value in a DeckArray used for editing data.
putnotePuts the contents of string to a field or case note.
 
QSFGives access to the StringWriter in use when processing question text as a text template.
 
randomReturns a pseudo-random integer in a given range.
randominReturns a pseudo-random integer in a non-continuous range, or using a value set.
randomizevsRandomizes the order of a value set.
recodeAssigns a value to a variable based on the value of one or more other variables.
reenterForces the data entry operator to reenter a previous entered field.
regexmatchReturns whether a string matches the regular expression.
registerAccessToken (CS)Registers an access token to provide access to the Action Invoker from external callers.
replaceReturns a string with one of more instances of a substring replaced with new text.
ReportDeclares a Report object as a user-defined function parameter that can refer to templated reports.
retrieveLoads a case from the current position of an external file.
roundReturns a value rounded to the nearest integer.
 
savepartialSaves the current case as a partially added, modified, or verified case.
savesettingSaves, using an attribute-value pair, a setting retrievable with the loadsetting function.
seedInitializes the random number generator to a particular starting place.
seekSearches a multiply occurring item for an item that meets a condition.
seekmaxSearches a multiply occurring item for an item with the highest value that meets a condition.
seekminSearches a multiply occurring item for an item with the lowest value that meets a condition.
selcaseAllows a data entry operator to select and load a case from an external file.
setSets the values of various system parameters.
set accessSets the order in which cases in a data file are processed.
set attributesModifies the field properties in a data entry application.
set behaviorModifies parameters related to field validation or sets export parameters.
set firstPositions the first case in a data file as the next case to be processed.
set errmsgModifies the way that error messages are displayed on desktop CSEntry.
set lastPositions the last case in a data file as the next case to be processed.
setbluetoothnameSets the name of the device as broadcast to other Bluetooth devices.
setcaptureposAllows the manual declaration of the window coordinates of the capture type.
setcapturetypeSets the capture type associated with a field.
setcaselabelSets a case's label (the text that appears in a case listing).
setfileAssigns a new physical file to a dictionary or declared file.
setfontChanges the default display font in data entry applications.
setlanguageModifies the current language being used while in data entry mode.
setlbReturns the lower bound of the CMC of an event.
setocclabelSets the occurrence label associated with a repeating dictionary item or a roster.
setoperatoridChanges the operator ID associated with the data entry session.
setorientationModifies the display orientation, allowing dynamic rotation of the display.
setoutputChanges the output file where cases are saved in a batch application.
setpropertyModifies an application or field property.
Settings.getValue (CS)Returns a value from a settings database.
Settings.putValue (CS)Sets a value in a settings database.
setubReturns the upper bound of the CMC of an event.
setvalueAssigns a value to a variable whose identity is only known at runtime.
setvaluesetDynamically modifies the value set of an item.
setvaluesetsDynamically modifies the value sets for all items in the dictionary.
showDisplays the occurrences of one or more items from a record or multiply occurring item.
showarrayDisplays the values of one or more elements from an Array.
showoccVisually shows (or hides) an occurrence row in a roster.
skipJumps forward to a specified field during data entry.
skip caseEnds processing of the current case in a batch edit run.
soccursReturns the number of occurrences of a record.
sortSorts occurrences of records or items based on the value of an item.
specialDetermines whether a variable's value is missing, refused, notappl, or default.
Sqlite.close (CS)Closes a previously opened SQLite database.
Sqlite.exec (CS)Executes a SQL statement on a SQLite database.
Sqlite.open (CS)Opens a SQLite database and returns an ID that can be used for future operations.
Sqlite.rekey (CS)Changes, removes, or adds an encryption key to a SQLite database.
sqlqueryExecutes a query on a SQLite database and returns a result set in a variety of formats.
sqrtReturns the square root of a numeric expression.
startswithReturns whether a string begins with a specified prefix.
stopEnds a data entry session or batch edit run.
stringDeclares variable-length alphanumeric variables used in the application.
StringWriterDeclares a StringWriter object that supports building strings incrementally.
stripRemoves trailing blanks from a string.
sumReturns the sum of an item that occurs multiple times.
swapSwitches the order of two occurrences within a group.
syncappUpdates an application from a new version of the deployed package on a server.
syncconnectConnects to a CSWeb, Dropbox, or FTP server, or to another device using Bluetooth, to begin a synchronization session.
syncdataSends or receives cases between the current device and a server or another device.
syncdisconnectEnds the current synchronization session.
syncfileSends or receives files between the current device and a server or another device.
syncmessageSends and receives a string message to a Bluetooth server.
syncparadataSends or receives paradata between the current device and a server or another device.
syncserverStarts running a server on the current device, to which other devices can connect using Bluetooth.
synctimeReturns the time of the last synchronization of a data file or a specific case.
sysdateReturns the current system date.
sysparmReturns a parameter a PFF file.
System.createShortcut (CS)Creates a shortcut to a CSPro application or file.
System.getSharableUri (CS)Creates a sharable URI that can be used by external applications to reference a file.
System.selectDocument (CS)Displays a dialog that allows the selection of one or more documents shared by the system.
SystemAppDeclares a SystemApp object for interacting with external applications.
systimeReturns the current system time.
 
throwException (CS)Throws an exception in the current execution environment.
timestampReturns the current UNIX time.
timestringReturns a custom formatted date and time string.
tolowerChanges all uppercase letters in a string to lowercase.
tonumberConverts a string to a number.
totoccReturns the total occurrences for a repeating form, roster, or record.
toupperChanges all lowercase letters in a string to uppercase.
trTranslates a string literal into an appropriate string based on the application's current language.
traceControls a window or file that can contain debugging information.
 
UI.alert (CS)Displays an alert dialog.
UI.close (CS)Closes the current HTML dialog or web view, optionally returning a result to an action like UI.showDialog.
UI.enumerateWebViews (CS)Returns information about all of the web views currently showing.
UI.getDisplayOptions (CS)Returns the display options associated with the current web view.
UI.getInputData (CS)Returns the input data associated with the current web view.
UI.getMaxDisplayDimensions (CS)Returns the maximum dimensions, in display units, of HTML dialogs that CSPro can show.
UI.postWebMessage (CS)Posts a message to a web view.
UI.setDisplayOptions (CS)Sets the display options for the current web view.
UI.setWebViewOptions (CS)Sets options, including granting permissions to use resources, for the current web view.
UI.showDialog (CS)Shows a HTML dialog.
UI.view (CS)Views a file or web page in a new web view.
universeSpecifies a condition that must be true for execution of a procedure or function to continue.
userbarControls the optional display bar in a data entry application.
uuidReturns a human-readable string containing a universally unique identifier.
 
ValueSetDeclares a ValueSet object for storing the contents of a dynamic value set.
viewLaunches the system's default viewer to display a file or website.
visualvalueReturns the visual value of a numeric data item prior to its input.
 
warningDisplays a "soft check" message only when the operator is not advancing in the case.
whenExecutes a statement based on the value of one or more other variables.
whileExecutes one or more statements repeatedly while a logical condition remains true.
writeWrite to a text file.
writecaseWrites a case from memory to an external file.
See also: List of Reserved Words