βοΈ CR Set Value on String
Route different output depending on a text match
- STRING
- BOOLEAN
- show_help
This is a string-driven if/else. CR Set Value on String checks whether your input text matches a test string, and outputs one value if it does, another if it doesn't - plus a boolean of the match itself. It's the text equivalent of a light switch: the workflow reads a word and reacts to it.
Where it earns its keep is in template and batch workflows driven by text. A wildcard or a label says "portrait," and this node flips the workflow into portrait settings; it says "landscape," and you get the other branch. One text field decides the fork.
How it works
You give it the text to check and a test string to compare against. If they match, it emits value_if_true; otherwise value_if_false. It also emits a boolean - true on a match - which you can wire into other logic (or into a switch node) to route more than just a string. No model, instant, deterministic.
The inputs and outputs that matter
text(STRING) - the input being tested. Wire this from whatever produces the label (a wildcard, a parameter extractor, a loader).test_string(STRING) - what to match against.value_if_true/value_if_false(STRING) - the two possible outputs.
(In the schema the last three are marked optional, but they're the whole point - set them.)
Outputs:
STRING- the selected value.BOOLEAN- true if the text matched. Feed it into a switch or another conditional to branch beyond a string.show_help- the wiki-link string, ignore it.
Installing it
CR Set Value on String is part of Comfyroll Studio (Suzie1 / RockOfFire), a large, established utility pack. Install via ComfyUI Manager (search "Comfyroll Studio," install, restart) or clone it:
cd ComfyUI/custom_nodes
git clone https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes.git
then restart. No models, no dependencies.
Common issues
The match is exact, so the usual failure is a near-miss you can't see: trailing spaces, a capital letter, Portrait vs portrait. If a match "should" be happening and isn't, wire the source text into a display node and look at it character for character. Normalize upstream (a text-operation node to lowercase and trim) if your labels come from somewhere messy.
Remember the output is a string - if you need a number for the branch, pair this with a converter, or use the BOOLEAN output to drive CR Set Value On Boolean instead, which emits numeric types directly. And the standing pack note: if Comfyroll fails to load at startup with a NameError traceback, that's a broken install rather than this node - reinstall cleanly through Manager and do a full restart.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | β | |
| test_stringopt | STRING | β | |
| value_if_trueopt | STRING | β | |
| value_if_falseopt | STRING | β |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| STRING | * | β |
| BOOLEAN | BOOLEAN | β |
| show_help | STRING | β |