[texworks] Scripting: Empty message box

Paul A Norman paul.a.norman at gmail.com
Tue Sep 6 13:11:10 CEST 2011


Hi,

This behaviour has got me foxed. Any one spot what I'm doing wrong please?

This'll generate a drop-down choice, then process the result and show
the text of item chosen, accept in  special cases like  "<SPAN ""<SPAN
QQ=\"aaa\">"  where there is correctly a space in the text. It comes
out with a blank message box!

While "<DIVzz=\"xx\">"  (no space)  works fine.

Paul

   var xx = TW.getItem(null, "Choice", "Choice", ["<DIVzz=\"xx\">",
"<SPAN QQ=\"aaa\">", "normal", "cool", "Other Stuff"]) + '';
                                                    // + '' is a cast
to force undefined (User cancels) to be a testable string

         // if not + '' cast  then...
         // if (typeof x == "undefined"){xx = "undefined"};

         switch (xx[0])
               {
               case "<":
                       TW.information(null, "< object chosen", xx);
                       break;

               case "n":
                       TW.information(null, "Normal", xx);
                       break;

               case "c":
                              TW.information(null, "Cool", xx);
                       break;

               case "u": TW.information(null, "Cancelled", "Cancelled");
                              break;

                    default:
                           TW.information(null, "Something Else", xx);
                              break;
               }


More information about the texworks mailing list