xojoScript example project doesn’t work

The XojoScript example project doesn’t work anymore on OSX. The reason is that the textFields are too helpful and they replace all the quotes you try to type with smart quotes which the compiler chokes on. The print “hello world” that is the default in the field is fine, but as soon as you try to type another line yourself you just get an error.

The compiler either needs to be updated to recognize those for what they are or we need further options on the text fields to turn those substitutions off.

I’ve run into the same problem with compiling applescripts and javascripts on OSX. We just need flags for the NSTextView underneath to be able to turn off it’s “AutomaticQuoteSubstitution” property. And while you’re in there we also need the AutomaticDashSubstitution, DataDetection, LinkDetection, and TextReplacement properties. You’ve already got a switch for spell checking.

Got burnt by them cuties curly things in JavaScript not that long ago…

Go into the Keyboard preferences Text Tab and uncheck “Use smart quotes and dashes”. It is a system wide setting.

For the rest -and quotes too, who know there may be ways- you should file a Feature Request.

if you’re not using any complex characters, you could convert the encoding to ascii.

I’m not using any complex characters :wink: Indeed as a programmer I instinctually avoid them because I know what they do to things. However many users insist on using the strange characters and diacriticals that their non-english language includes and get very testy with me is they can’t use the proper accents in the names of things in the code :wink: I suppose I could test, but what are the implications of converting a string of French diacriticals to just ascii? I feel like you used to be able to include at least those even back in the dark ages before UTF came around.

All solutions in pure ASCII involved replacing for instance left brace by é as in the Apple II. It is a mess.

I rather make sure quotes are quotes by disengaging the automatic curly quotes. And if ever I need to write a book, I will reinstate the pesky keyboard feature.

I can do that for me, but I can’t very well suggest that my users turn off a global text formatting option before writing a script in my program :wink: I have had a hell of a time with multi-byte characters with applescript lately. If you cut and paste a block of example code off my own programs website into my program you’ll get curly quotes as well as probably multi-byte tab like characters that don’t even show up as anything other than white space but that blow up the applescript compile. You can’t even see them and they won’t compile. How applescript can insist on using forced multi-byte UTF16 characters for everything and then refuse to accept anything that is ACTUALLY a multi-byte character I have no idea, but it does. Thats not Xojo’s problem :wink: I just need better options for dealing with such things. At the moment I’ve used plugins to turn those options off in my app and if a script won’t compile I scan the text for multi-byte characters and underline them while popping up an error suggesting that the script may contain multi-byte characters and to delete or re-type anything that is underlined. Today I’m going to see if I can set a background color to those characters as people aren’t seeing the underline or it’s carrying through as they keep typing and such making things more complicated.

I did not get you needed to suppress the curly quotes in the app.

If it is possible to change that by declare, hopefully some guru will show up.

Maybe I would try a set of ReplaceAll to feed a variable that will contain the script text sent to the app. I tried to replace curlies directly in TextArea.Text, no luck.

It is possible to suppress it
Its slightly different declares for a text field vs text area as they are quite different underlying controls

Have you checked if MacOSLib already has this included as its quite different for text fields vs text areas and even between single line text fields vs multiline ones

I’ve done it currently through the MBS plugins which give me all the NSTextView functions. As much as I love those plugins, it shouldn’t be a requirement to own them in order to type in a xojo script. I haven’t looked in MacOSLib but it shouldn’t be too complicated to do via declares.

Its kind of ugly via declares as text views are different than editable text areas (blarghhhh)
And text areas you have to worry about whether its a single line one or styled vs not as the required declares are different for them
So there’s at least 3 different code paths for this

It’d be nice IF the Apps plist could just override the global setting but I dont see that as a possibility in any apple docs
Then you could set the app plist and be done and it would only affect your app

The easiest way to handle this problem is to include something like the following to take the script (which is a string, which in my case is collected from the editfield or textfield containing the script) to one in which all the curly quotes are converted to straight quotes. I do it this way because I do not want to force my users to turn the curly quote option off if they wish to use it for other applications.

  // fix all curly quotes both single and double
  script = replaceall(script,&u2018,"'") // single left curly quote
  script =replaceall(script,&u2019,"'") // single right curly quote, apostrophe
  script =replaceall(script,&u201C,chr(34)) // left curly quote
  script =replaceall(script,&u201D,chr(34)) // right curly quote