RESOLVED - tbl roll Not Evaluated Until End of Script? #52
-
In order to nest tables, I would like to roll on one table and then check if the result is something specific. Depending on that first result, I might roll another table.
However, it's never getting inside the if statement because I don't think the first expand("tbl roll") actually assigns a value until the full script is finished. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Try replacing this line:
with this line (note the addition of
The shortcut "tbl roll" returns a string of the result, even if that string is a comma separated string. However, it returns it within an array. It is an array of size 1, but it's still an array. An example return value might be I recognize that this might be confusing. The explanation is a bit involved. Let me know if you're curious and I'll explain. |
Beta Was this translation helpful? Give feedback.
-
One alternative, and a nicer one imo, would be to add this right after the first line: Yet Another alternative, albeit less fool-proof, would be to use the new output-format of "array" in the roll (instead of "comma", "bullets", etc). I just added this output-format in response to this email, so it requires re-importing the library to use. Instead of outputting a string containing a formatted list of the results, it outputs a raw JavaScript array of the results. |
Beta Was this translation helpful? Give feedback.
Try replacing this line:
if (result.includes("Action") && result.includes("Theme")) {
with this line (note the addition of
[0]
):if (result[0].includes("Action") && result[0].includes("Theme")) {
The shortcut "tbl roll" returns a string of the result, even if that string is a comma separated string. However, it returns it within an array. It is an array of size 1, but it's still an array. An example return value might be
[ "monkey, dolphin, parakeet" ]
.I recognize that this might be confusing. The explanation is a bit involved. Let me know if you're curious and I'll explain.