Jump to content

Help with double quotes


 Share

Recommended Posts

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

Some guy's script + some other guy's script = my script!

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Some guy's script + some other guy's script = my script!

Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...