Can comments be added to variables?

Started by fincire, July 10, 2023, 08:09:42 PM

Previous topic - Next topic

fincire

Is it possible to add comments to variable expressions, and what's the syntax if it can be done? I know variables aren't quite the same thing as a scripting or coding language, but it would be really helpful to add notes-to-self or even comment out some elements (to test other bits, etc.), especially for complex variable expressions.

I can do something similar in VarToy by just typing outside the boundaries of any variable constructs; it usually just renders that stuff as text and disregards it unless it interferes with actual "code." But I don't know if it's possible elsewhere; for example in a data-driven category's variable- and/or regex-containing fields or custom template fields in the Layout Editor. 

Now that I've asked, I'm also wondering if it's possible when writing Formulas.

Another, possibly more naive question: is there a best practice for copy/pasting formulas and variable commands? I often start typing them in Notepad++, Word, the Imatch notes app, or even Windows sticky notes, to organize and tinker before pasting them in. It works, but pasted-in linebreaks often cause unpredictable behavior. CTRL+Enter works as a linebreak in Imatch about 99% of the time, which is great, but CTRL-Enter doesn't "copy" (also it means other things in some apps) so I have to manually remove any linebreaks before pasting, so the final expression loses its readability in those outside venues.

I imagine the best practice Mario suggests will be "don't do that," or possibly "type them in VarToy," which I can understand, but odd as it is, this little element of my workflow is really helpful to me, so I'm hoping there's a trick to creating linebreaks that can copy over with everything else.

Thank you!

Mario

#1
No comments for variables. The syntax would this make very messy to look at. Most users use very simple variables only, if at all.

Variables are also about performance. It's not uncommon for a variable to be parsed and executed 100,000 times, e.g. for a data-driven category. Or hundreds of times in a File Window.

I, and I know many IMatch users do so too, use the IMatch Notepad to store lists of complex and frequently used variables, with comments and formatting etc. The same works fine for category formulas.

Most of the time, I enter a variable only once. For File Window layouts, data-driven categories etc.
But for other variables I reuse for Design & Print, I keep them in the IMatch Notepad.

Note that the VarToy also allows you to store and recall variable expressions.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

fincire

That's too bad but not surprising. Formatting would be difficult since variables don't need to be laid out line-by-line the way code usually is, so where would these comments go.

The truth is my variables probably aren't that complicated, but I'm not exactly fluent in the syntax and structure, so stringing two or three arguments together inevitably means I'm using a comma where it's supposed to be a semicolon and putting curly braces in the wrong spots and struggling to visually parse it. Hence my love of breaking lines with CTRL+Enter.

So using IMatch Notepad, I could just use the traditional markdown space-space at the end of a line and it will carry over when I paste it? That would be great. I use the notepad, but I don't know that I've ever tried it as a repository for variable snippets. I think I had a vague feeling that markdown and some variable syntax would get in each others' way.


Mario

It's standard markdown, including ``` to indicate code etc.
The syntax is described on IMatch Notepad and the links provided there.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook