[texworks] Scripts: Naming script files, some nomenculture

Stefan Löffler st.loeffler at gmail.com
Sun Oct 31 14:21:29 CET 2010


Am 2010-10-29 00:21, schrieb Paul A Norman:
> In assigning names to scripts, I have assumed that all alpha-numerics
> are ok, is that correct?

Are you talking about the "Title" header field, or about filenames? For
filenames, all characters supported by the OS are valid, naturally. In
the string, basically anything should be allowed (depending on the
encoding you use).

> Are there other "safe" characters?

I assume filenames here. In that case, I'd strongly recommend keeping to
alpha-numerics, plus probably "-" and "_". Other characters may cause
problems, or at least confusion. For example, "/" and "\" are naturally
bad. Other characters, such as ">" (redirect output), "<" (redirect
input), "&" (run in background on *nix), "*", "?", ... often have a
system-specific special meaning. While the could normally be escaped
(usually by "\"), things are getting more difficult and possibly not
portable. As far as spaces are concerned, I believe they shouldn't be a
problem, but if you can avoid them it's certainly better. Non-ASCII
characters naturally depend on the encoding used and as such might turn
out differently on different OSs.

> Is this OS dependent?

As far as filenames are concerned, yes (see above). As far as
header-fields are concerned, it shouldn't be.

> I have found that also the & can be incorporated in the Script file
> name, giving it a hot key on the Script menu - is that a safe
> practice?

This is not a feature, it's a coincidence. Qt uses "&" in menus to
denote hotkeys, so if a "&" is found in the string that is displayed,
it's used. Tw has nothing to do with that, it's a Qt thing.

> If & is put at the front of the script filename this moves the Script
> on the menu ahead of the alphabet listings and of course underlines
> the first following letter, so &White Space.js would appear ahead of
> Apple Script Function.js, is that safe practice - will it remain
> thorugh Tw revisions?

I'd avoid that, mainly because "&" is a special character on some
platforms. Besides, the filename is not actually intended to be
displayed in the menu - a title should be assigned in the header fields.
The filename is used only as a fallback mechanism since it naturally
exists for all scripts.
As far as sorting is concerned, right now I think scripts are sorted by
title, so there is no need to use "&" in filenames. I wouldn't count on
the "&" to be included in sorting in the future, though, as I think it's
confusing to the user.

> "I have found that also the & can be incorporated in the Script sub-  F&older
> name, giving it a hot key on the Script menu - is that a safe
> practice across OS-es?

Hm..., maybe, though I'd prefer to avoid it. Right now, there are no
alternatives, though, I think.

> Files are done (QtScript) in script header //Title:
>  - but same question there please, are only alpha numerics (apart from
> &) to be used there?

In the header, you should be able to use everything that is allowed in
the comment/string/encoding.


More information about the texworks mailing list