• <GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
    • Data Entry Module
    • Batch Editing Applications
    • Tabulation Applications
    • Data Sources
    • Synchronization
    • 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
        • SyncConnect Function
        • SyncServer Function
        • SyncDisconnect Function
        • SyncData Function
        • SyncFile Function
        • SyncMessage Function
        • SyncParadata Function
        • SyncApp Function
        • SyncTime Function
        • GetBluetoothName Function
        • SetBluetoothName Function
    • 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>

SyncConnect Function

Format
b = syncconnect(connection_string);
Description
The syncconnect function connects to a synchronization service, initiating a synchronization session. Once a session is created, you can synchronize:
  • Applications using syncapp.
  • Case data using syncdata.
  • Files using syncfile.
  • Messages using syncmessage.
  • Paradata using syncparadata.
The session is active until it is closed using syncdisconnect.
The string argument connection_string is a synchronization connection string, generally a server URL or text identifying the service. This string contains information about the resource that CSPro will connect to, and any additional parameters (such as a username and password). Details about properties specific to each synchronization service are available on the documentation describing each of the services that CSPro supports:
Synchronization ServiceExample Connection String
Bluetooth"Bluetooth"
CSWeb"https://example.org/csweb/api"
Dropbox"Dropbox"
FTP"ftpes://example.org"
Local Files"file:///C:/surveys/ftp-server"
This is a CSPro logic function. Similar functionality is available using the Sync.connect action. When using actions, multiple synchronization sessions can be created, whereas using CSPro logic, there is only one session per call to syncconnect.
Note: If the attempt to establish an Internet connection is unsuccessful, CSPro displays an error message. If you wish to preempt this error message in order to handle this situation on your own, use the connection function to determine if Internet access is available.
Return Value
The function returns a logical value of 1 (true) if the connection was successful and 0 (false) otherwise.
Example
// connect to the CSWeb server
if syncconnect(CSWeb, "https://example.org/csweb/api") then

   
// upload the latest cases
    syncdata(PUT, SURVEY_DICT);

   
// disconnect from the server when complete
    syncdisconnect();

endif;
Deprecated Syntax
Prior to CSPro 8.1, the syncconnect function required as the first argument the specification of the type of synchronization service. This old syntax is still accepted but may not be supported in the future.
// Bluetooth
b = syncconnect(Bluetoothʃ, server_device_nameʅ);

// CSWeb
b = syncconnect(CSWeb, csweb_urlʃ, usernameʃ, passwordʅʅ);

// Dropbox
b = syncconnect(Dropbox);
b = 
syncconnect(LocalDropbox);

// FTP
b = syncconnect(FTP, ftp_urlʃ, usernameʃ, passwordʅʅ);

// Local Files
b = syncconnect(LocalFiles, directory_path);
See also: Synchronization Overview, SyncDisconnect Function, Sync.connect Action