AppDownload Method (CLIENT)


PLB Web Only, 9.9

 

The AppDownload method transfers a file from the PWS server to the client application. The method uses the following format:

 

[label]

{object}.AppDownload

[GIVING {return}] USING [*url=]{url}[:

 

 

[*FileName=](filename}][,[*Options=]{options}]

 

Where:

label

Optional. A Program Execution Label.

object

Required. A CLIENT object.

return

Optional. A Numeric Variable that returns the success or failure of the method.

url

Required. A Character String Variable or string literal giving the URL of the file to download from the PWS server.

filename

Required. A Character String Variable or string literal giving the file name to use on the client mobile device 'Local Application Area'.

options

Optional. A Character String Variable or string literal that specifies a JSON object that is passed directly to the Cordova routine used for this method.

Flags Affected: OVER, ZERO

Note the following:

  1. This method is only used for a Sunbelt PL/B Web Client App using Cordova\PhoneGap operations. See the following link for details on the Cordova plugin used:

  2.  

         https://www.npmjs.com/package/cordova-plugin-file-transfer

     

  3. The ZERO flag is set when the {return} value is zero.

  4. The OVER flag is set if the value returned is too large to be stored into the {return} variable.

  5. The {options} parameter controls the behavior of the Cordova plugin when the AppDownload method operation is being performed. The {options} parameter is passed directly as a JSON object to the Cordova routine. The {options} parameter currently only supports headers (such as Authorization (Basic Authentication), etc). See the plugin documentation for more information.

  6.  

  7. This method starts an asynchronous download of a file from the PWS server to the client and store in the 'Local Application Area' on the mobile device. The return result for the 'AppEventDoDownload' event data is returned in ARG1 in JSON notation.

  8.  

    The event number used in EVENTREG is:

     

    AppEventDoDownload EQU 105 //Event number for EVENTREG.

     

    The event result is defined as follows:

    Alert Dialog

    Field

    Description

    ARG1

    No data returned on event.

    Modifier

    The button number (always 1)

    Confirm Dialog

    Field

    Description

    ARG1

    No data returned on event.

    Modifier

    The button number

    Prompt Dialog

    Field

    Description

    ARG1

    Prompt edit text data returned as plain text (i.e., not JSON).

    Modifier

    The button number

Example Code

 

Bnum FORM 3 //Expect value from 1 to N.

FullData DIM 200 //Plain data returned for event.

.

          EventReg Client,AppEventDialog,DialogEvent:

                   Modifier=Bnum,ARG1=FullData

.

          Client.AppDialog Using "How much should be added?":

                   "Numbers","One;Two"

 

 

See Also: CLIENT, Client Methods, Method Syntax



PL/B Language Reference AppDirGet Method (CLIENT AppExtendedError Method (CLIENT)