Jump to content

Cannot concatenate '&' ampersand in a string


GioPet

Recommended Posts

Hi Dieter,

yes I tried that..

What turned out is that the & was actually concatenated in the string, but for some reason vs.AlrtDialog does not display it.

as I was using vs.AlrtDialog to check the string, it took me a while to figure out that actually & was there..

and thanks once more for your TIP, it's all very appreciated as I've still got so much to learn about Python!

G

Link to comment

Hi Dieter,

yes, I have tried vs.Chr(38) but it behaves in the same way:

The following displays correctly:

amp = vs.Chr(38)
vs.AlrtDialog(vs.Concat('ampersand = ', amp))

but when i use concatenation (either vs.Concat or python native +) AlrtDialog doesn't display the ampersand.

Bu then I used the concatenated string to make a http call I realised that all my ampersand were there as expected...

Link to comment
  • 5 months later...

Giovanni,

It's been 5 months, and you may already have the answer, but for those that don't...

This is not a Python problem, but rather a quirk of the AlrtDialog() call, and possibly its Modern Dialog underpinnings.

Use two ampersands '&&' to show a single ampersand in an Alert Dialog string.

Use a single ampersand '&' in Message() command strings and in normal string use.

This holds true for both Python and VectorScript when using AlrtDialog().

Examples:

1)

vs.AlrtDialog('Watch out for Alligators && Snakes!!!')
vs.Message('Good luck avoiding Death & Taxes!!!')

2)

forAlrt = True
S = "Your Appetizer: {} {} {}".format('Cheese', '&&' if forAlrt else '&' , 'Crackers')
vs.AlrtDialog(S)

forAlrt = False
S = "Your Appetizer: {} {} {}".format('Cheese', '&&' if forAlrt else '&' , 'Crackers')
vs.Message(S)

HTH,

Raymond

  • Like 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...