TXFAJavaScriptSession.Evaluate
Unit: HPDFXFAEventScript
Declaration
function Evaluate(const Script: string; const Limits: TXFAFormScriptLimits;
out OutputText, Diagnostic: string): Boolean;
Behaviour
Executes JavaScript in the persistent engine and appends successful evaluations and returned results to the bounded journal
Returns True with OutputText after success, or False with Diagnostic on engine, replay or budget failure; a failed evaluation does not commit a journal entry
Empty, comment-only and declaration-only scripts return the native completion text undefined; internal clock and random-seed assignments do not become the script result
A genuine leading #! hashbang is recorded as an equivalent line comment, and the first caller line is separated from the internal prefix. Global lexical declarations and the bridge's existing strict-mode policy are retained without wrapping user code in another function or eval
Diagnostic source locations include the recorded internal prefix. The Session captures its own runtime dependencies during engine initialisation, so caller lexical bindings for standard global names do not replace its internal clock, replay or maintenance operations
History reconstruction retains native strict global-program evaluation. Published ReplaySince fragments still use their existing indirect-eval mode; unrestricted equivalence of strict behaviour and program declaration lifetime is not established by the intrinsic-capture repair
If rollback or a prior failed evaluation dirtied the engine, reconstructs it from committed evaluations before running the new script
Replay and new execution each get their own Limits.MaxElapsedMilliseconds, so a reconstruction never shortens the script that asked for it: every replayed entry was admitted under that budget when it was committed, and a caller may also call RebuildPending to pay for a dirtied engine before arming a deadline of its own
Direct callers checkpoint before a multi-step transaction and call Rollback when later host validation or publication fails
Related APIs
TXFAJavaScriptSession, HPDFXFAExecuteJavaScriptEvent and Interactive Dynamic XFA Widget Runtime