ASK - Not displaying '&' correctly.

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
BrianM
Newbie
Posts: 7
Joined: Sat Feb 09, 2013 2:17 am

ASK - Not displaying '&' correctly.

Post by BrianM » Mon Feb 11, 2013 6:20 pm

Has this issue been brought up before or anyone else notice this?

let>myString="Hello & World"

MessageModal>Did you say %myString%
OUTPUT: Did you say "Hello & World"

ASK>Did you say %myString%,r1
OUTPUT: Did you say "Hello_World"

It drops the & and replaces it with a _

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Feb 11, 2013 6:56 pm

It drops the & and replaces it with a _
Actually it repaces it with _. If you look carefully you'll see the first space is still there.

The ampersand is special within the Ask> prompt. It lets you underscore the character following the ampersand. If you want to see the ampersand in the prompt, put in two of them.

Ask>Hello && World,res

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Mon Feb 11, 2013 8:22 pm

Hi BrianM and JRL,

You also have to watch out for the special properties of the Ampersand & char when creating Label text in dialogs... and with label text you place on a Button in a dialog and other objects... its just a Windows thing.
A out-take from [url]http://en.wikipedia.org/wiki/Ampersand[/url] wrote:In Microsoft Windows menus, labels and other captions, the ampersand is used to denote the keyboard shortcut for that option (Alt + that letter, which appears underlined). A double ampersand is needed in order to display a real ampersand. This convention originated in the first WIN32 api, and is used in Windows Forms,[21] and is also copied into many other tookits on multiple operating systems.
See dialog demo below:

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  Left = 251
  Top = 97
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 144
  ClientWidth = 300
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
  object Label1: TLabel
    Left = 35
    Top = 33
    Width = 32
    Height = 13
    Caption = 'Label1'
  end
  object Label2: TLabel
    Left = 35
    Top = 89
    Width = 32
    Height = 13
    Caption = 'Label2'
  end
  object MSButton1: tMSButton
    Left = 163
    Top = 27
    Width = 89
    Height = 25
    Caption = 'MSButton1'
    DoubleBuffered = True
    ParentDoubleBuffered = False
    TabOrder = 0
    DoBrowse = False
    BrowseStyle = fbOpen
  end
  object MSButton2: tMSButton
    Left = 163
    Top = 83
    Width = 89
    Height = 25
    Caption = 'MSButton2'
    DoubleBuffered = True
    ParentDoubleBuffered = False
    TabOrder = 1
    DoBrowse = False
    BrowseStyle = fbOpen
  end
end
EndDialog>Dialog1


Let>Var1=Hello&Goodbye
Let>Var2=Hello&&Goodbye

SetDialogProperty>Dialog1,Label1,Caption,Var1
SetDialogProperty>Dialog1,Label2,Caption,Var2

SetDialogProperty>Dialog1,MSButton1,Caption,Var1
SetDialogProperty>Dialog1,MSButton2,Caption,Var2


Show>Dialog1

Wait>10
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts