|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > JSON - Parser > Parser-Operations > !Document Operations > PSJ. - JSON Operations |
SPR Script Language
PSJ.DupDoc
Creates a duplicate of a JSON document and returns its handle.
Intention
The PSJ.DupDoc command in SPR creates a complete copy of a JSON document identified by $$DOC). Optionally, it stores the handle of the new document in $$RET. It’s like telling your robot to photocopy an entire JSON file for you to work with separately.
For example, duplicating document 100 creates a new, independent document with a unique handle.
Illustration
📝 Duplicate Document: PSJ.DupDoc|100 creates a copy of document 100.
📝 With Result: PSJ.DupDoc|200|$$NEW duplicates document 200 and stores the new handle in $$NEW.
Syntax
PSJ.DupDoc|$$DOC[|$$RET]
Parameter Explanation
P1 - $$DOC - (Variable, Numeric)
The identifier of the JSON document to duplicate (e.g., $$DOC as "100"). Must be a valid document. Required.
P2 - $$RET - (Variable, Numeric, Optional)
The variable to store the handle of the new document (e.g., $$RET as "$$NEW"). Returns the new handle or 0 if duplication fails. If omitted, the result is returned but not stored.
Examples
'***********************************
' Sample 1: Duplicate Document
PSJ.DupDoc|100
' Creates a duplicate of document 100
MBX.Ready
'***********************************
' Sample 2: Duplicate and Store Handle
PSJ.DupDoc|200|$$NEW
' Duplicates document 200 and stores the new handle in $$NEW
IF $$NEW > 0 THEN PRT.New Handle: $$NEW ELSE PRT.Error
MBX.Ready
Remarks
- $$RET returns the handle of the new document (a positive value) or 0 if the duplication fails.
- Use PSJ.ErrCode for detailed error information if $$RET is 0.
Limitations
- $$DOC must be a valid JSON document identifier.
See also: