Upcoming Games

(UTC times)


Full list
Add a game

Upcoming Events

No events to display

Ampersands Not supported on timetable description

You are here: Home > Forum > General > General questions, comments, and issues > Ampersands Not supported on timetable description

Page 1 of 1

Ampersands Not supported on timetable description 04/05/2014 at 12:41 #60026
jc92
Avatar
3701 posts
first of all, I feel silly for not having mentioned this over a year ago when I first noticed it.

ampersands (&give an output of _ when used on a timetable description, e.g. Elephant_castle rather than elephant & castle.

is there any particular reason for this as + doesn't look right; elephant + Castle.

"We don't stop camborne wednesdays"
Log in to reply
Ampersands Not supported on timetable description 04/05/2014 at 13:08 #60027
TimTamToe
Avatar
664 posts
" said:
first of all, I feel silly for not having mentioned this over a year ago when I first noticed it.

ampersands (&give an output of _ when used on a timetable description, e.g. Elephant_castle rather than elephant & castle.

is there any particular reason for this as + doesn't look right; elephant + Castle.
type it as && and it will show as Elephant & Castle in the timetable description (although it will show as Elephant && Castle on the F2)

Gareth

Log in to reply
The following users said thank you: jc92, maxand
Ampersands Not supported on timetable description 04/05/2014 at 13:09 #60028
jc92
Avatar
3701 posts
thanks Gareth!

I'm still curious as to what causes that behaviour though...

"We don't stop camborne wednesdays"
Log in to reply
Ampersands Not supported on timetable description 04/05/2014 at 13:11 #60029
Muzer
Avatar
718 posts
I know why it's happening. Normally in Windows applications, & represents a hotkey, I believe it's called - so "File" in most applications is represented internally as "&File" (because pressing Alt+F opens the file menu) and rendered as "File" in some circumstances. Windows is doing this to the SimSig timetable, assuming the & marks the hotkey - so "Elephant & Castle" is turning into "Elephant _Castle". I can't remember exactly how it works (I'm not a Windows programmer), but someone either needs to escape the ampersands or turn off this feature for that text area.
Last edited: 04/05/2014 at 13:12 by Muzer
Log in to reply
The following user said thank you: TimTamToe
Ampersands Not supported on timetable description 04/05/2014 at 13:38 #60032
maxand
Avatar
1637 posts
In programming, certain characters are reserved by the programming language, i.e., have a special meaning within the code compared with their normal (literal) meaning. For example, if you create a button for the screen which has a title and also a hotkey, the language may require you to prefix that hotkey with an ampersand (&). For example, if you have a button labelled "OK" and want to trigger it by pressing Alt+K, the language might insist that you code its title not as "OK" but "O&K". The button does not display the ampersand in its title.

What if you want the ampersand (or any other reserved character such as "<"to be part of the title? The language reserves another character as an escape character, i.e., use it to escape its special use and display it as a literal character. In this instance, "&" is not just a reserved character but also the escape character.

Thus, to display the reserved character ">" you would type it as "&>".
To display the reserved character "&" you would type it as "&&".

"Elephant & Castle" becomes "Elephant && Castle".

Reserved and escape characters vary from language to language but the ampersand is a popular choice of escape character.

Last edited: 04/05/2014 at 13:42 by maxand
Log in to reply
Ampersands Not supported on timetable description 04/05/2014 at 16:02 #60037
Peter Bennet
Avatar
5419 posts
Online
Developers used to have to code apostrophes as '' to get a ' to appear. That seems to have been resolved as I've had to go back and delete one in more current builds.

Peter

I identify as half man half biscuit - crumbs!
Log in to reply
Ampersands Not supported on timetable description 04/05/2014 at 16:07 #60038
Forest Pines
Avatar
525 posts
This has been a feature of Windows for over 20 years I think!

(incidentally, Max, it's not a language feature. It's an API feature. Very different concepts)

In Windows Forms development there's a Control.ShowKeyboardCues property that I assume turns this on and off (I've never had to fiddle with it). Whether it's exposed in Delphi or not , I couldn't say.

Log in to reply
The following user said thank you: maxand
Ampersands Not supported on timetable description 04/05/2014 at 19:12 #60044
Finger
Avatar
220 posts
Indeed Forest Pines, well over 20 years!

Quoting the relevant MSDN page:
Quote:

By default, the window text for a static control, as for other controls, can contain an ampersand that defines the following character as the shortcut key for the control (or, in the case of most static controls, for the control that it labels, which is the next control in the tab order). If you wish to display ampersands in the text rather than using them to define shortcuts, include the SS_NOPREFIX style.
I believe that in Delphi, you would just design the dialogs using the IDE and there would just be a checkbox for turning this bit on (which you should do for controls displaying a basically user-provided text, you don't want that to mess up with keyboard navigation). Although I'm not a Delphi programmer either.

BTW Control.ShowKeyboardCues is something different - that only controls (or indicates) whether the shortcuts are shown - ie. they will still be there (and respond to Alt+key etc.), just not underlined. In the .NET world, to display the ampersands as-is, you should look at the Label.UseMnemonic property

Last edited: 04/05/2014 at 19:23 by Finger
Log in to reply
The following user said thank you: Forest Pines
Ampersands Not supported on timetable description 04/05/2014 at 21:37 #60049
Forest Pines
Avatar
525 posts
" said:

BTW Control.ShowKeyboardCues is something different - that only controls (or indicates) whether the shortcuts are shown - ie. they will still be there (and respond to Alt+key etc.), just not underlined. In the .NET world, to display the ampersands as-is, you should look at the Label.UseMnemonic property
Bah! Well, as I said, I've never tried it myself!

Log in to reply