Jump to content

Double Quotes In Hscript


Recommended Posts

Hello all,

I've been having a reoccuring problem with hscript when it comes to double quotes. I am trying to do a simple operation where I copy a string field to another field, be it string, vector, or float.

Here is an example:

String Field: param = $TX+ch("../add1/pt0x")

I try to do:

set VALUE = `chsraw("./param")`

opparm . new_param ( $VALUE )

and I get this in the new field:

$TX+ch(../add1/pt0x)

I loose the double quotes.

I've tried everything I can think of to preserve the double quotes, but no luck. Is there an answer I am not seeing?

Thanks

Link to comment
Share on other sites

After the backticks get expanded using the expression parser, the double quotes are there. However, this result is then expanded using the hscript parser, thus loosing the quotes. In your particular example, I'm assuming that you actually have backticks in the opparm line. The simplest way to preserve the doube-quotes is to escape chsraw()'s result before assigning to VALUE. However, you have to be careful to not pass it again through the hscript parser or else they will be lost again. One way to do the escaping is something like this: `strreplace(chsraw("./param"), "\"", "\\\"")`

Link to comment
Share on other sites

Thanks so much edward. I ended up not doing exactly what you suggested, but what you wrote help me out big time. Here is what I acually had to do...

set Q = "\"" ## Had to make a variable that was a quote. :)

set VALUE = `strreplace(chsraw("./"+$script_parm),"$Q","KFIRGLLA")` ## Changed all double quotes to some wakey name. Using "\"" instead of "$Q" did not work.

Then I could do all the hscript I wanted to do with no issues.

chkey -t 0 -v 0 -m 0 -A 0 -F `strreplace($XVAL,"KFIRGLLA","\"")` `$script_parm`vx ## Then I was able to push this into a channel by nesting the strreplace inside the chkey and change the wakey string back to a quote. If I tried set TEMP = `strreplace($XVAL,"KFIRGLLA","\"")` , then uset $TEMP in the chkey, it didn't work.

Sounds CRAZY... but it acually works.

Thanks again edward for the help.

Link to comment
Share on other sites

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.   Paste as plain text instead

  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...