Semicolon in Note title causes problems?


(George Wyner) #1

Just had some strange behavior where a Note was being counted twice in a collect_if(). Turns out the problem was use of a semicolon in the note title ($Name attribute). when I removed the “;” the issue resolved and I am all set.

Not sure if this behavior is a bug or intentional, but the take away for me is to avoid using semicolon in $Name.

Aside: the other character I also avoid is the “/” - I know it can be quoted to avoid being interpreted as part of a path, but I would rather just avoid any confusion.


(James Fallows) #2

I had never tried this but not am not surprised by the results you report.

In Tinderbox, the semicolon is an important coding signal, often meaning that you have more than one value to specify, and that the different values will be separated by semicolons. Eg, if you’re populating a set-style attribute, you use semicolons to break the values up. For actions, it’s also the separator for a series of steps you want the program to take. So I imagine the collect_if operator believes that it has run into two separate $Names when it sees a semicolon.

I don’t know the full range of other tricky characters, but this is an important one. Good discovery!


(George Wyner) #4

Very interesting. Here is my code:

collect_if(siblings,$Checked,$Name).count

What happens is that the collect_if assembles a list or set consisting of names separated by semicolons. count then uses semicolons to identify the number of items in the list.

when I examine the results of:

collect_if(siblings,$Checked,$Name)

then it sure does look like the “embedded” semicolon is another separator and that the original name consists of two items. Not clear, once I look at it, what I would want TB to do instead.


(George Wyner) #6

It is a dashboard note. I am setting $Subtitle to the count of the siblings that are checked. The reason it is siblings is that I have a bunch of notes in a map and some get checked and that designation is used somewhere else and the map is big enough that I wanted to have a count of the currently checked notes so that I wouldn’t lose track of one that is outside the viewport. The code runs in a rule. The Sibling designator is what I wanted and seems to work fine. now that I am not including the “;” in any note titles the count is correct.

To give some context: the notes in this container represent possible comments that apply to student homeworks I am grading. I check the relevant ones for a given student and have a note elsewhere that collects the comments into a form suitable for pasting as a comment.

Thanks!


(Mark Anderson) #7

Generally, if you want to use actions, it is a good idea to avoid semicolons, parentheses (i.e. this sort of bracket) and forward slashes.

As stated above, Tinderbox uses semi-colons as the value delimiter in lists and there is no method for escaping literal semi-colons in names.

Forward slashes can be mis-parsed as paths, i.e. a note “car/van” can be interpreted as a note “van” which is the child of container “car”.

Round brackets in names, e.g. “Literary Machines (1991 ed.)” can confuse link testing/generating actions presumably as the parentheses are treated as back-reference regex markers.


(Martin Boycott-Brown) #8

Does the documentation have a list of “inadmissible characters” anywhere? If not, would it be a good idea to create one?

I deal with the titles of publications quite a bit, and all sorts can appear in those, as you indicate in your example. Might be useful to have a list of things that could cause problems.


(Mark Anderson) #9

Amen! I’l try to do something though it’s hard as some characters are safe in most (simple) settings but not in some others.

The semi-colon case is easy - don’t use it if you want to use anything that makes lists. The slash & parentheses seems to be more related to creating links. The problem is the cause is in the guts of 17-odd years of incremental growth. Still I’ll see if i can give better guidance. I guess there is a case for adding more tests to the Tinderbox Cookbook, which was created very much with this sort of testing in mind. Bear in mind action/export code isn’t a designed-from-scratch programming language but rather an incrementally incremented macro system.

My research often involves academic papers which manage to include pretty much every character one might problematic. One workaround is to store the ‘real’ tile in a user String attribute and edit the name to remove/substitute problem characters. Then set the display expression to use the ‘real’ title. Thus you see the expected title but under the hood Tinderbox can use ‘safe’ names. A bit of a faff, but I’ll take a pragmatic workaround if available.

HTH


(Martin Boycott-Brown) #10

That’s an interesting work-round – thanks. I hope I’ll be able to remember it when I need it!