• <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
        • SystemApp Statement
        • SystemApp.setArgument Function
        • SystemApp.exec Function
        • SystemApp.getResult Function
        • SystemApp.clear Function
      • 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>

SystemApp.exec Function

Format
// Android format
b = system_app_name.exec(ʃpackage_nameʃ, activity_nameʅʅ);
// Windows format
b = system_app_name.exec(executable_name);
Description
The SystemApp.exec function executes a system application associated with the SystemApp object. Any arguments set using the SystemApp.setArgument function are passed to the system application. On Android, a system application can return results which can be queried with the SystemApp.getResult function.
Return Value
The function returns a logical value of 1 (true) if the system application is started successfully and 0 (false) otherwise.
Android Limitations
Starting with Android 11, the version of CSEntry installed using Google Play is prohibited from querying for applications not explicitly specified. Google insists that this restriction is to protect sensitive information. The following packages are explicitly specified in the version of CSEntry in Google Play:
  • Google Maps (com.google.android.apps.maps)
  • Organic Maps (app.organicmaps)
If you want to execute an application not in the above list, you can sideload a non-Google Play version of CSEntry. This version can query for all applications. To get this version, you must contact the CSPro development team. Alternatively, you can request that the developers add your desired application to the specified list.
One workaround to this limitation is to use deep links instead of a package name. If the package name cannot be resolved, CSPro will attempt to "view" the argument used for the package name. Because deep links are handled by Intent.ACTION_VIEW, you can use this to open applications not explicitly specified by CSEntry.
Android Example
On Android, the optional string expression package_name specifies the name of the Android application (package) that will be executed. An optional string expression activity_name specifies the name of the activity within the package that should be opened. If no arguments are provided, then the arguments specified using SystemApp.setArgument will be processed by the Android operating system and, if there is a way to handle these arguments, then an appropriate application will be opened.
// get directions to the U.S. Census Bureau using Google Maps
SystemApp google_maps_navigation;
google_maps_navigation.
setArgument("action", "android.intent.action.VIEW");
google_maps_navigation.
setArgument("data", "google.navigation:q=U.S.+Census+Bureau");
google_maps_navigation.
exec("com.google.android.apps.maps");
// get driving directions from the White House to the U.S. Census Bureau using an Organic Maps deep link
SystemApp organic_maps;
organic_maps.
exec(maketext("om://route?sll=%v,%v&saddr=%s&dll=%v,%v&daddr=%s&type=vehicle",
                           
38.897778, -77.036389, encode(PercentEncoding, "White House"),
                           
38.84839,  -76.931098, encode(PercentEncoding, "U.S. Census Bureau")));
Windows Example
On Windows, a system application is an executable specified by the string expression executable_name. Typically the name is the full path of the executable, but for applications that have registered their name in the Windows Registry, you only need to provide the executable file name.
// play the training video in Windows Media Player
SystemApp windows_media_player;
windows_media_player.
setArgument(pathconcat("../Videos/Census Training.mp4"));
windows_media_player.
exec("wmplayer.exe");
See also: SystemApp Object, SystemApp.setArgument Function, SystemApp.getResult Function, Interacting With Other Android Applications