Jump to content
Sign in to follow this  
Werty

Help with double quotes

Recommended Posts

Werty

I have this imagemagick command where I need to put the #80008000 part in quotes like this "#80008000".

The command looks like this

$img.Convert("input.bmp","-fill","#80008000","-opaque","white","output.bmp")

But that doesnt put the #80008000 part in quotes.

Actually the command needs to be....

$img.Convert("input.bmp","-fill","#",$MyVar,"-opaque","white","output.bmp")

So the "#",$MyVar part needs to be in quotes.

So where the H do I put quotes to make it look like that ?

I end up with a gazillion """""""""" and it still fails. :blink:

Edited by Werty

Share this post


Link to post
Share on other sites
seandisanti

I have this imagemagick command where I need to put the #80008000 part in quotes like this "#80008000".

The command looks like this

$img.Convert("input.bmp","-fill","#80008000","-opaque","white","output.bmp")

But that doesnt put the #80008000 part in quotes.

Actually the command needs to be....

$img.Convert("input.bmp","-fill","#",$MyVar,"-opaque","white","output.bmp")

So the "#",$MyVar part needs to be in quotes.

So where the H do I put quotes to make it look like that ?

I end up with a gazillion """""""""" and it still fails. :blink:

looks like you have an extra comma after your "#" that will probably cause you some issues

Share this post


Link to post
Share on other sites
Werty

looks like you have an extra comma after your "#" that will probably cause you some issues

lol, you're right, still need it in quotes though.

Looks like this now...

$img.Convert("input.bmp","-fill","#" & Hex($color,8),"-opaque","white","g:/result.png")

...where the quotes are missing.

Share this post


Link to post
Share on other sites
Tvern

There are two main ways to do this:

1. Escape the quotes you want to appear in the string like this: "unquoted part of the string, ""quoted part of the string""".

The red quotes are the opening and closing quotes for the string, while the green ones will show up in the string. by using two double quotes the interpeter knows these are not meant to be closing quotes for the string, but part of the string.

This would look like: """#" & Hex($color,8) & """"

2. Use single quotes to contain the string, and double quotes where you need them in the string like this: 'unquoted part of the string, "quoted part of the string"'.

Again the red quotes delimit the string, while the green ones show up. Because the string is opened with a single quote, the interpeter won't think the double quote is meant to close it.

This would look like: '"#' & Hex($color,8) & '"'

P.s. If you need to format a string containing both double and single quotes you need to combine both methods, or form the different parts of the string first, then concatenate them.

edit: If you are having trouble formatting a string it usually helps to test it by consolewriting to the console in addition, or instead of trying to run it right away.

Edited by Tvern

Share this post


Link to post
Share on other sites
cueclub

the way I do it is.. something like this.. Msgbox(0, "test", " you're message 'HERE' ")

but my eyes are bad and i dont want to look at all those quotes :blink: .

Edited by cueclub

Share this post


Link to post
Share on other sites
Werty

Thanks, got it.

Nice explanation.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×