SetFormScriptHostActionMode
Forms, JavaScript safety
Description
Chooses how the bounded form-script runtime treats host actions such as app.alert, this.submitForm and getField(...).setFocus, which the library never performs itself
Syntax
Delphi
Function TPDFlib.SetFormScriptHostActionMode(Mode: Integer): Integer;
ActiveX
Function PDFlib::SetFormScriptHostActionMode(Mode As Long) As Long
Available on IPDFlibrary4 from type library version 3.5
DLL
int DLSetFormScriptHostActionMode(int InstanceID, int Mode);
Parameters
| Mode | 0 (default) rejects: a script that reaches a host action stops as unsupported with LastErrorCode 706. 1 defers: the action and its evaluated arguments are recorded and the script continues |
|---|
Return values
Returns 1 when the mode is accepted, or 0 with LastErrorCode 708 for any other value
Remarks
Recognised host actions are app.alert, app.beep, app.launchURL, app.mailMsg, this.print, this.submitForm, this.mailDoc, this.resetForm and getField(...).setFocus used as statements. Arguments can be expressions or flat object literals such as {cMsg: "Text", nIcon: 1}
Both modes list the host actions the script reached in the hostRequests array of GetFormScriptDiagnostics; in reject mode the list ends with the action that stopped the script. Actions in branches that do not run are not recorded
In defer mode the application decides whether to show the alert, submit the form or move the focus after execution. One execution records at most 64 requests; more exceed the resource budget with LastErrorCode 709
Calls that need an answer from the host, such as app.response(...) or a host action used as a value, and dynamic code such as eval, new Function or app.setTimeOut, remain unsupported in both modes
The mode applies to direct field-event execution, edit-session commits and recalculation
Example
Lib.SetFormScriptHostActionMode(1);
if Lib.ExecuteFormFieldScript(Index, fsaValidateField, '25', Output) = 0 then
Writeln(Lib.GetFormScriptDiagnostics); // hostRequests lists app.alert
See also
GetFormScriptHostActionMode, GetFormScriptDiagnostics, ExecuteFormFieldScriptEvent, SetFormScriptLimits