• <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
      • 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
        • SyncConnect Function
        • SyncConnect Function (CSWeb)
        • SyncConnect Function (Bluetooth)
        • SyncConnect Function (Dropbox)
        • SyncConnect Function (LocalDropbox)
        • SyncConnect Function (LocalFiles)
        • SyncConnect Function (FTP)
        • SyncServer Function
        • SyncDisconnect Function
        • SyncData Function
        • SyncFile Function
        • SyncMessage Function
        • SyncParadata Function
        • SyncApp Function
        • SyncTime Function
        • GetBluetoothName Function
        • SetBluetoothName Function
    • 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>

SyncMessage Function

Format
// Bluetooth client
s = syncmessage(message_nameʃ, message_valueʅ);

// Bluetooth server
function string OnSyncMessage(string message_name, string message_value)
   
exit message_response;
end;
Description
The syncmessage function sends a string message from one device to another device that is acting as a Bluetooth server. The string expression message_name identifies the message, and an optional string expression message_value defines a value associated with the message. The client device sends this message to a Bluetooth server.
The application running on the Bluetooth server must have a user-defined function with the name OnSyncMessage that has two string parameters and returns a string. While the syncserver function is running, the OnSyncMessage function is called anytime a message is received and the return value of that function is returned to the Bluetooth client.
Return Value
The function returns the message returned by the OnSyncMessage function running on the Bluetooth server. If no message is returned, a blank string is returned.
Example
// on the client...
syncmessage("STAFF_CODE", STAFF_CODE);

if syncmessage("TRAINING_MODE") <> maketext("%d", TRAINING_MODE) then
   
errmsg("You cannot sync with a device that is not in the same training mode as your device");
   
syncdisconnect();
endif;


// on the server
PROC GLOBAL

function string OnSyncMessage(string message_name, string message_value)

   
// store information about the sync in the paradata log
    if message_name = "STAFF_CODE" then
       
logtext("Syncing with %s at %s", message_value, timestring());

   
// return the training mode
    elseif message_name = "TRAINING_MODE" then
       
exit maketext("%d", TRAINING_MODE);

   
endif;

end;
See also: Synchronization Overview, SyncConnect Function (Bluetooth), SyncServer Function