Nodes/ComfyUI-JDCN/LogicUtil_Yieldable Iterator String
ComfyUI Node

LogicUtil_Yieldable Iterator String

Cycle through your prompt variants, one per run, forever

By daxcay·Created 2 years ago·Updated about a year ago· 159
LogicUtil_Yieldable Iterator String
    • STRING
    input_stringa$b$c
    separator$
    reset0

    LogicUtil_Yieldable Iterator String walks through a list of items one per run and never stops. Give it a $-separated string like a$b$c, and each time you queue the workflow it hands you the next item, wrapping back to the start when it runs out. It's the sequential sibling of the pack's Uniform Random Choice - instead of picking randomly, it takes turns. And like the random node, it lives in the LogicUtil subpack of ComfyUI-JDCN.

    How it works

    Three inputs, one STRING output:

    • input_string - your options, separated by separator (default $). The default a$b$c is a placeholder.
    • separator - the delimiter between items.
    • reset - an INT (0 or 1) that restarts the walk from the beginning.

    The node keeps its position in memory between runs. Run once, you get one item; run again, the next; when you hit the end it wraps to the front and keeps going. That's the whole mechanism - a stateful cycle, which is exactly what you want for iterating prompt variants, LoRA names, or filename suffixes across a batch without re-rolling anything.

    The quirk you'll hit on run one

    Here's the honest part, straight from the source. The node increments its position before yielding, so on the very first run - before you've touched reset - it skips the first item and starts with the second. With a$b$c, your first run gives you b, not a.

    That's almost certainly a bug rather than intent (the reset path does start at item one), but it's been that way in the code as of the versions I checked, so plan around it: set reset to 1 on the first run if you want to start at the beginning, or just accept that your cycle begins at item two. Once the cycle is going, the wrap-around keeps the rotation consistent, so it only really bites you on the very first run.

    It's also worth remembering this node is stateful - the position persists on the node between runs. If you edit the input_string mid-cycle, the pointer doesn't reset on its own; use reset to force a clean start. And like the int iterator, it emits one item per run, so it's meant for workflows you queue repeatedly, not for splitting a list in a single pass.

    Why you'd use it

    The classic pattern: a handful of prompt variants you want to see one per run in order, not at random. Wire the output into your positive prompt, queue the workflow four times, and you've seen all four variants in sequence - with the reproducibility that a fixed rotation gives you over a random pick. It also composes with the pack's other nodes: use a Static String for a fixed prefix, this node for the rotating suffix, and join them.

    Installing it

    It's part of ComfyUI-JDCN, so one install covers the pack. ComfyUI Manager: Install Custom Nodes → search "JDCN", install, restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/daxcay/ComfyUI-JDCN.git
    cd ComfyUI-JDCN
    pip install -r requirements.txt
    

    Only dependency is piexif; no models to download. The pack is a small two-person hobbyist effort (Daxton Caylor and Jerry Davos), and the iterator nodes are where its rough edges show - useful concept, slightly unfinished implementation. Go in knowing about the first-run skip and you'll get real mileage out of it for prompt cycling.

    CategoryLogicUtil

    Inputs (3)

    NameTypeDefaultDescription
    input_stringSTRINGa$b$c
    separatorSTRING$
    resetINT00–1

    Outputs (1)

    NameTypeDescription
    STRINGSTRING