ExecuteFormFieldScriptJSON

Forms, JavaScript safety

Description

Runs a field validation, calculation, formatting or keystroke action and returns the result and event state as JSON. It provides ExecuteFormFieldScriptEvent to the DLL and ActiveX interfaces

Syntax

Delphi

Function TPDFlib.ExecuteFormFieldScriptJSON(Index, Action: Integer; Const Value, Change: WideString; SelStart, SelEnd, Flags: Integer): WideString;

ActiveX

Function PDFlib::ExecuteFormFieldScriptJSON(Index As Long, Action As Long, InputValue As String, Change As String, SelStart As Long, SelEnd As Long, Flags As Long) As String

Available on IPDFlibrary4 from type library version 3.5

DLL

const wchar_t* DLExecuteFormFieldScriptJSON(int InstanceID, int Index, int Action, const wchar_t* Value, const wchar_t* Change, int SelStart, int SelEnd, int Flags);
const char* DLExecuteFormFieldScriptJSONA(int InstanceID, int Index, int Action, const char* Value, const char* Change, int SelStart, int SelEnd, int Flags);

Parameters

IndexThe one-based field index
Action0 validate, 1 calculate, 2 format or 3 keystroke
Value, ChangeThe initial event.value and event.change
SelStart, SelEndThe selection the change replaces
FlagsSum of 1 willCommit, 2 fieldFull, 4 keyDown, 8 modifier and 16 shift

Return values

A JSON object with result (the ExecuteFormFieldScriptEvent return value), value, change, rc, selStart and selEnd; an invalid Action returns {"result":0} with LastErrorCode 708

The source field is the target field. DLL strings belong to the instance return buffer and must be copied before the next call

See also

ExecuteFormFieldScriptEvent, SetFormScriptHostActionMode, GetFormScriptDiagnostics