objectscript-loop-patterns

Generate ObjectScript loop patterns for For, While, and $Order traversal.

27|10|Updated Apr 21, 2026
One-click install
npx skills add https://github.com/intersystems-community/iris-dev --skill objectscript-loop-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: objectscript-loop-patterns
Source: https://github.com/intersystems-community/iris-dev/tree/main/light-skills/skills/objectscript-loop-patterns
Command: npx skills add https://github.com/intersystems-community/iris-dev --skill objectscript-loop-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

ObjectScript developers often struggle to implement loops that behave consistently, leading to subtle defects when quitting from inside loops or iterating globals with $Order.

Core Features & Use Cases

  • Clear guidance on Quit vs Return semantics inside For/While loops to ensure the entire method flow remains correct.
  • Patterns for safe iteration over lists, arrays, and globals using $Order, including forward and reverse traversal and in-loop removals.
  • Real-world use cases showing how to implement stable loops in methods and global structures.

Quick Start

Ask the AI to generate and explain ObjectScript loop patterns for a given list, global, or collection using For, While, and $Order, highlighting Quit vs Return behavior.

Frequently Asked Questions about objectscript-loop-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I iterate over an ObjectScript global using $Order safely?

ObjectScript global iteration using $Order requires a While loop that checks for empty string termination, ensuring forward and reverse traversal patterns handle undefined nodes and multi-level structures predictably.

What is the difference between Quit and Return inside an ObjectScript loop?

In ObjectScript loop semantics, Quit exits only the current loop block, whereas Return exits the entire method or routine immediately, fundamentally altering the remaining method execution flow.

How do I remove elements from an ObjectScript list while iterating through it?

Safe in-loop removals in ObjectScript require careful loop pattern design, typically by iterating backwards or collecting target indices first, preventing index shifting from corrupting the active traversal.

Can I traverse multi-level global structures in ObjectScript without skipping nodes?

Yes, robust multi-level global iteration in ObjectScript uses nested $Order loops, ensuring each sublevel is fully traversed before advancing the parent key, preventing skipped nodes during complex hierarchical scans.

Why does my ObjectScript For loop return unexpected results when exiting early?

Unexpected results during early ObjectScript loop exits often stem from misusing Quit versus Return semantics, where Quit only breaks the loop but Return leaves the method entirely, skipping downstream logic.