Jump to content
thatguy

Special chars in vars...?

Recommended Posts

Hello all -- 

I’m noticing a very odd behavior in a script I’m writing, and have it narrowed down to a Variable-Set command.

I’ll read a row from a client table (Passwords) with Get-DataSet, then Fetch the values into sql_var.  The value appears correctly in the debugger, but the next step is a simple Variable-Set, Type Constant, Parameter @sql_var@, Variable Name: stvar.  In testing, when sql_var starts with an exclamation point, stvar is assigned -9999; when I remove the leading exclamation point, the value is assigned correctly.

Is it possible that the script is reading the exclamation point as a Not character?  Do I have to enclose the Variable-Set Parameter in single/double quotes?   Very confused.
Thanks
 

Share this post


Link to post
Share on other sites

So as a followup to this sad, empty post: I opened a ticket with CW support, and apparently, even the higher tiered folks are confused about how variable's characters are handled.

I created a very simple two-line script to test/prove the issue:
Step 1)
- Variable-Set;
- Constant;
- Parameter: ‘!!P@ssw0rD#!!’   (I include quotes here, but in the orig script, the plaintext password is pulled from a table via Fetch)
- Variable Name: stvar
Step 2)
- Variable-Set;
- Constant;
- Parameter: @stvar@
- Variable Name: newvar

In this test, newvar will get assigned -9999;  but when @stvar@ is quoted in step2 (either single or double quotes), the value gets assigned correctly.  So at least from that test, some form of quotes around the Parameter seems necessary.  In response to that, I was told that every non-alpha/non-numeric char would need to be escaped in @stvar@, but even that's incorrect, per my testing.

To be honest, it's rather disconcerting that I can't get a straight and conclusive answer to this, even from higher-tiered tech support.  At any rate, it seems that adding quotes in step2 accomplishes what I needed, but apparently, coder-beware, be sure to test exhaustively! 
 

Share this post


Link to post
Share on other sites

confusing clarification from support:   That is only going to apply if the variable starts with special characters. You will need to either escape out the special characters so they get read appropriately or you will need to use the single quotes around the variable that you are trying to pull so that it is read in full as a single item rather than it trying to interpret the special characters for their respective action items in MySQL.

That's about where I'm going to leave this, as I seem to have reached bedrock for helpful advice from support.  Maybe someday, a developer will divulge the full secrets behind special chars in CW, but it doesn't look like it will be this day. 

I hope someone out there benefits from this semi-nonsense. 

Share this post


Link to post
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.

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