Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com)
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi
Tinderbox Users >> Questions and Answers >> $Color, color swatch, note color all different!
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi?num=1475257691

Message started by james a. foster on Sep 30th, 2016, 1:48pm

Title: $Color, color swatch, note color all different!
Post by james a. foster on Sep 30th, 2016, 1:48pm

How can this possibly be? I have a code note (prototype Code) with $Text set to

$Color=“green”;

and

$Rule("/Prototypes/ProtoOutput")=$Text

And I have a prototype, /Prototypes/ProtoOutput, with $Rule set to
$Color=“green”;

Now, the prototype note itself is "red", the $Color attribute is "green", and the color swatch is "red"! (at one point, all were different).


Title: Re: $Color, color swatch, note color all different!
Post by Mark Anderson on Sep 30th, 2016, 2:32pm

This may be an forum typo but this code won't work as it uses typographic ('curly') quotes:


Quote:
$Color=“green”;


Quotes around strings must be 'straight' in action code:

$Color="green";

If you see a brick-red colour, it is likely the 'undefined ' value which (for reasons I don't know) renders as something like a red-ish '#d5847f'.


Quote:
the prototype note itself is "red", the $Color attribute is "green"


Do you mean "green" or “green”? The former will show red (as above) and the latter green.

Title: Re: $Color, color swatch, note color all different!
Post by james a. foster on Sep 30th, 2016, 3:28pm

Ah! They are the "two upside down, two rightside up" double quotes. They were from the $Text field of the code note. I typed them in as the double quotes on my macbook keyboad so I don't know how they got converted. any ideas?

When I go back to my "not green" note, and set $Color to "green" (with the right quotes), it stays the redish color--which it would make sense to be undefined.

When I enter green, without quotes, the note changes color (to green!)

When I enter $Color=green; (without ANY quotes) in the code note, it works! So, the quotes are definitely the problem.

Thanks!

Title: Re: $Color, color swatch, note color all different!
Post by Mark Anderson on Sep 30th, 2016, 5:06pm

The reason the code works without quotes is for legacy purposes for those who can't be bothered to update their code. I strongly advise using this legacy [sic] method as at some point legacy support tends to drop away. It's better to fix the problem and then not have to worry about the code mysteriously stopping working one day.

As to the changed quote type, in v6, due to the underlying Apple frameworks the rich-type text part of the note ($Text) 'auto-corrects' quotes from straight to typographic. Generally this is considered helpful - most user seem to want this - but it's no help where you want to type code.

In v6, you either need to turn off auto-correction of quotes, or apply the build-in 'Code' prototype to your code notes. I'd suggest you make new code notes, using that prototype, as you're earlier experiment probably has other glitches in it. Starting over with a clean, correctly configured note will help.  If copying $Text from existing notes, use paste-and-match-style instead of paste and ensure you've not imported any unintended curly quotes.  In a Code-prototyped note, correcting these back to straight will not then result in auto-correct back to curly.

Title: Re: $Color, color swatch, note color all different!
Post by Mark Bernstein on Oct 1st, 2016, 11:54am

Turn off “Smart Quotes” for a note by toggling Format ▸ Text ▸ SmartQuotes.

There’s an attribute $SmartQuotes that controls smart quotes on a note-by-note basis. Change the default value to false, or change the value of $SmartQuotes in the prototype to false, to disable Smart Quotes more widely.

Title: Re: $Color, color swatch, note color all different!
Post by james a. foster on Oct 3rd, 2016, 12:35pm

since this is a Code note, the prototype is $Code, which is build-in prototype. I recommend making this a default for that prototype.

In the meantime... I will set it myself.

Thanks!!

Title: Re: $Color, color swatch, note color all different!
Post by Mark Anderson on Oct 3rd, 2016, 1:26pm

The concept of a 'code note' is an informal one, which started as a means -  in older versions of TB - to work on longer sections of action code. The built-in prototype 'Code' is baked into the app but like all built-in codes is added to a document, as required, by the user. Once added it is likewise applied to notes, by the user as the app has no way to know what a code note is (and only a few users need such structure - I'm one such).

A convention I've come to use is to add a root-level folder 'Codes', or a similar explanatory name, which houses my code notes. Having added the 'Code' prototype to the document I set the 'Codes' container's $OnAdd to:

$Prototype = "Code";

If, like me, you tend to export document data, I generally also set - via the Export Inspector - the container both to not export and not export children. This is because the code ($Text) in the notes is only used internally.

Title: Re: $Color, color swatch, note color all different!
Post by james a. foster on Oct 3rd, 2016, 1:30pm

Nice. Thanks, Mark

Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com) » Powered by YaBB 2.2.1!
YaBB © 2000-2008. All Rights Reserved.