PSJ. - JSON Operations

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > JSON - Parser > Parser-Operations > !Node Operations >

PSJ. - JSON Operations

PSJ.ChildIDs

PreviousTopNext


SPR Script Language

 

PSJ.ChildIDs

Retrieves all child node identifiers of a parent node as a comma-separated string.

 

Intention

 

The PSJ.ChildIDs command in SPR retrieves the identifiers of all child nodes under a parent node identified by $$NODE, returning them as a comma-separated string. Optionally, it stores the result in $$RET. It’s like asking your robot to list all the branches of a tree node in your JSON structure.

 

For example, if a node with ID "100" has children with IDs "101", "102", and "103", it returns "101,102,103".

 

Illustration

📝 Get Child IDs: PSJ.ChildIDs|100 returns a string like "101,102,103" for node 100’s children.
📝 With Result: PSJ.ChildIDs|200|$$IDS stores the child IDs of node 200 in $$IDS as a comma-separated string.

 

Syntax

 

PSJ.ChildIDs|$$NODE[|$$RET]

 

Parameter Explanation

 

P1 - $$NODE - (Variable, Numeric)

The identifier of the parent node (e.g., $$NODE as "100"). Must be a valid node. Required.

 

P2 - $$RET - (Variable, String, Optional)

The variable to store the result (e.g., $$RET as "$$IDS"). Returns a comma-separated string of child node IDs or an empty string if the node has no children or is invalid. If omitted, the result is returned but not stored.

 

Examples

 

'***********************************

' Sample 1: Get Child IDs

PSJ.ChildIDs|100

' Returns a string like "101,102,103" for node 100’s children

MBX.Ready

'***********************************

' Sample 2: Store Child IDs

PSJ.ChildIDs|200|$$IDS

' Stores child IDs of node 200 in $$IDS (e.g., "201,202")

IF $$IDS <> "" THEN PRT.Child IDs: $$IDS ELSE PRT.No Children

MBX.Ready

 

Remarks

 

- $$RET returns a comma-separated string of child node IDs (e.g., "101,102") or an empty string if the node has no children or is invalid.

- Use PSJ.ErrCode for detailed error information if the operation fails.

 

Limitations

 

- $$NODE must be a valid node identifier.

 

See also:

 

PSJ.ChildAt

PSJ.ChildCount

PSJ.ErrCode