Tinderbox Forum

Commenting Code

When writing rules etc is there a recognized way of adding comments to the various code items? I couldn’t find any comments about comments in acrobatfaq.com


Yes. Code commenting is new to v9 (so won’t work if run in older versions); see Action Code comments.


1 Like

I used commenting in this post.

I couldn’t get the action code to work until I used // at the beginning and at the end of a comment line.


Tinderbox comments end at the [Return] character, rather than at wherever the text of the line breaks in the window.

I understand the design intent. I read the documentation before trying to comment code.

See the sample tbx at the link in my post above. Here’s what the code within one of the stamps in it looks like.

With the nice enlargeable inspector windows we have now, does this look like a case of “wherever the text of the line breaks in the window”?

As I wrote, I found I couldn’t get the code to work unless I started each comment line with // and ended it with // (and, yes, added return characters). It took me a lot of debugging time to stumble on that fix. Since I posted the tbx with the code, it should be easy to test my assertion. Just try removing the trailing // and see if the code still works.

I’m fine with the // at both ends of a comment; in fact I think I prefer that. I thought it would be helpful, though, to give a heads up to others trying this that, at least on my machine (Big Sur 11.4, Tinderbox 9.0), the documentation currently seems to be inconsistent with the usage that actually works.

Curious! This rule works without the trailing //

// comment

And my code above? Without the trailing // does that work on machines other than mine?

I think I got it, if you are writing code in some other app and pasting into a stamp ensure you paste plain text. If the text of the code is already styled, it appears Tinderbox does not re-colour it. I don’t know if that is intended or not (I’d assume not).

I opened @sumnerg 's ‘Excerpt’s demo.tbx’ and looked the doc’s stamps and noticed the abnormal colouring. So I cut the code out (i.e. so no saved code in the stamp. pasted it info a blank BBEdit window that cut and pasted back into the stamp’s code window and the correct action code colouring was seen.

My hunch here is pasting into Inspector code input boxes may be reading clipboard styled text rather than plain text (though I’m sure under the hood it’s more complex than that).

Sorry, meant to add, the correct result can be seen here. Note the colouring still works even after removing the original closing // for the comments.

Document Inspector: Excerpts demo 2021-07-18 14-10-36

Didn’t pick up on the color cue.

I composed the code right in that nice new expandable box in the inspector, not in some other app. But I did do some copy-pasting both within the code for a stamp and between stamps (cloning the first one and then modifying to make the others). No special clipboard utilities installed. Just select, command-c, click, command-v. But maybe going through the clipboard throws the coloring off?

Despite the abnormal coloring the code runs fine on my machine if I do include the trailing // but fails silently if I do not include the trailing //. Is that the case on other machines as well?

After much tinkering, it is only comments preceding a line starting var that need a closure. There may be other instances of edge cases in other scenarios.

Also just doing a select-all/cut/Return/paste/return, fixed the stamp formatting. Perhaps originally made in a beta?

1 Like

Thanks for that tinkering! I did quite a bit of that myself before I discovered adding a trailing // worked in that particular context.

I didn’t do my copy-pasting in a beta, but rather in Tinderbox 9.0.0 (b523) running under Big Sur 11.4.

I think I now like the trailing // Could be useful for situations where a return is not present.

Anyway, it’s great to be able to add comments now.

1 Like