• <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
    • Templated Reporting System
    • HTML and JavaScript Integration
    • Action Invoker
      • Overview
      • Execution Environments
      • Security and Formatting Options
      • Base Actions
      • Application Namespace
      • Clipboard Namespace
      • Data Namespace
      • Dictionary Namespace
      • File Namespace
      • Hash Namespace
      • Localhost Namespace
      • Logic Namespace
      • Message Namespace
      • Path Namespace
      • Settings Namespace
      • Sqlite Namespace
      • System Namespace
        • System Action Invoker Namespace
        • System.getSharableUri Action
        • System.selectDocument Action
        • Sharable URI
      • UI Namespace
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataViewer>
  • <TextView>
  • <TblView>
  • <CSFreq>
  • <CSDeploy>
  • <CSPack>
  • <CSDiff>
  • <CSConcat>
  • <Excel2CSPro>
  • <CSExport>
  • <CSIndex>
  • <CSReFmt>
  • <CSSort>
  • <ParadataConcat>
  • <ParadataViewer>
  • <CSCode>
  • <CSDocument>
  • <CSView>
  • <CSWeb>

System.selectDocument Action

Format
s = CS.System.selectDocument(ʃcontentType := ...ʅʃ, multiple := ...ʅ)
ArgumentDescriptionTypes / Required
contentTypeThe MIME type, or types, of documents displayed.
The default value is "*/*".
string, array
not required
multipleIf true, the operator can select multiple documents.
The default value is false.
boolean
not required
Description
The System.selectDocument action displays a dialog that allows the operator to select one or more documents shared by the system, returning a sharable URI that provides access to these documents. This action is primarily for use in applications run on Android when you may want to access files created by other applications or media such as photos taken by the device. On Android, such files are not available to CSPro directly, so this action provides a framework for accessing system documents.
The contentType argument allows you to specify the content from which you would like the operator to select. For example, specfiying "image/*" would only allow the operator to select image files. When specified as an array, it is possible to specify multiple types (e.g., "image/jpeg" and "image/png").
The multiple argument indicates whether the operator can select multiple documents.
Return Value
If no documents are selected, the action returns undefined. Otherwise the action returns an object with two properties:
PropertyValue
"path"The path, or sharable URI, of the document.
"name"The filename of the document, which may not necessarily be part of the path.
For example, on Android, this object, represented in JSON, may look like this:
{
 
"path": "content://com.android.providers.media.documents/document/image%03A1000002937",
 
"name": "carn03.jpg"
}
If multiple is true, an array of objects is returned, even if the operator only selects one document.
Exceptions
The action throws an exception if any of its arguments are not specified in a valid form.
Example (CSPro Logic)
// query for an image
string selectDocumentJson = CS.System.selectDocument(contentType := "image/*");

if selectDocumentJson <> "" then
   
// convert the JSON into a CSPro-usable format using a HashMap
    HashMap string selectDocumentResult;
    selectDocumentResult.
updateValueFromJson(selectDocumentJson);

   
// create the new image path, using the original filename
    dircreate("Images");
   
string imagePath = Path.concat("Images", selectDocumentResult("name"));

   
// copy the document to the Images directory
    CS.File.copy(source := selectDocumentResult("path"),
                 
destination := imagePath);
endif;
See also: System Action Invoker Namespace, System.getSharableUri Action, Sharable URI