John Hawkinson wrote:
The problem is that it is often fairly subtle "when you really need it," and you don't notice until you've been bitten by it.
Everyone is pretty much always better off with ===.
I actually came across a situation where === was problematic, but I don't remember the details. There's no replacement for properly learning a language you use. (Whether it's a spoken language or computer one...) ![]()
John Hawkinson wrote:
Crockford.
Oops. Never nice to bollix up someone's name... ![]()
I actually came across a situation where === was problematic, but I don't remember the details.
I think a common case is confusion between null and undefined. For instance:
var v;
...
if (v==0) { v="now initialized!"; }
will "work" and initialize v, because v is undefined, and "undefined==0" returns true. So if you just changed it to
var v;
...
if (v===0) { v="now initialized"; }
then v would never get initialized. Of course, this is bad code because you should have initialized v in the var line anyhow, or you should have tested it against "undefined" and not "0" or "null," or halfadozen other reasons.
Anyhow, I feel like your exception proves the rule. Use '===' always, unless you learn the language well enough to require truthiness promotion, because if you don't, you are likely to make an assumption about whether something is false versus null versus undefined, and that assumption will come back and hurt you later.
John Hawkinson wrote:
Anyhow, I feel like your exception proves the rule. Use '===' always, unless you learn the language well enough to require truthiness promotion, because if you don't, you are likely to make an assumption about whether something is false versus null versus undefined, and that assumption will come back and hurt you later.
This is a bit like philosophy. You can argue both sides until you're blue in the face. Just about anyone coming from a C background would probably disagree. There's quite a lot of people who look at 0 and false as synonymous...
Whatever; I have bigger fish to fry... ![]()
Harbs
Juergen:
One question is still open: Is there a chance to create KeyboardShortcuts for a custom menu that will work even after a ShutDown & Restart of InDesign?
They should just work. Did you try them?
Please note that you cannot create KBSCs in the scripting interface, you must do so by hand in the UI. (well, I suppose you could edit InDesign's xml file that stores this information, but that wouldn't be very...clean.)
JuMayr wrote:
Hi Marc,
i tried your MenuLoader and it works like a charm.
One question is still open: Is there a chance to create KeyboardShortcuts for a custom menu that will work even after a ShutDown & Restart of InDesign?
Cheers
Juergen
Hi Juergen,
Thanks for your feedback. I haven't seriously studied keyboard shortcuts issues but I know this is a very complicated topic to scripters. What we can guess is that temporarily removing/refreshing menu actions—as my script does—does not preserve the existing KB shortcuts, because InDesign dynamically clears them as soon as the 'link' is broken between a shortcut and a custom action—I suppose. So we need to restore removed shortcuts, but AFAIK the scripting DOM does not provide any interface do do that. I don't even know if rewriting on the fly the 'indk' file could actually work. Maybe other people here have already investigated this point.
@+
Marc
Yes. Menu Actions are saved cross-session. They are cleared out on shutdown only if there's no associated menu item.
If you remove it and create a new one, keyboard shortcuts are lost.
I'm pretty sure you should be able to add and remove menu items without issues. The keyboard shortcuts are associated with the actions.
Harbs
North America
Europe, Middle East and Africa
Asia Pacific