Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending a character variable including quotation marks 2

Status
Not open for further replies.

grahamrhind

Technical User
Jul 8, 2003
99
A1
Hi all,

I want to be able to send a character variable as a parameter. That's easy enough, as I send the string surrounded by quotation marks.

However, the string being sent in this case may include different types of quotation marks (single or double) and in different quantities (including odd number quantities). For example:

'I said, "Let's go home"'
"This isn't correct"

and so on. The procedure itself is designed to remove the quotation mark sets, so no processing of the string may take place before being sent as a parameter.

Can anybody tell me how to send that character variable without using quotation marks?
 
lcVariable = [I said, "Let's go home"]

use brackets.

boyd.gif

 
Thanks Craig and Olaf,

I confess ignorance to whatever a "shellexe" is.

I'm trying to send the string to a VFP dll. Within the dll is a method which processes quotation marks in a very specific way.

If I try Craig's method and send the string in this way:

GRCReturnedString=oTemp.quotat(["He said, "Let's do it""])

I note with debugger that the square brackets themselves become double quotation marks within the process (which causes problems for the process as they are processed instead of the other quotation marks). This is also the same if I store the string first to a variable and then send the variable. The second problem is that the variable is being returned as a logical variable (.t.) instead of the character variable it is being initialised as.

Any ideas?
 
How is the foxpro dll defined? Do you have that source code? Maybe you must pass the variable by reference?
Code:
lcString = [He said, "Let's do it"]
oTemp.quotat(&lcString)
? lcString
The quotation marks you see in the debugger are not within the variable, they are merely delimiters for display. If you store "SOME STRING" to a varible it's value is SOME STRING only, without the quotation marks. But the debugger will display "SOME STRING", even if you stored [SOME STRING] to the variable.

The outer quotation marks are merely delimiters for the real value, if you want to store a string literal (o string constant) to a variable in code you need them for defining begin and end of the string literal, the compiler must somehow know, where the string begins and ends.

So by the way: if you really stored ["He said, "Let's do it""] to a variable then the value of the variable should be "He said, "Let's do it"" and the debugger displays this as ""He said, "Let's do it""".

Bye, Olaf.
 
Hi Olaf,

I had tried that, without success. However, after some fiddling I've found out that I had a bad RETURN line in the dll. With that resolved, the squash brackets work a treat. Many thanks!
 
FoxPro has 3 delimiters that handle all situations I've encountered and can be nested within one another: [ ], " ", and ' '.

Example: ? [Mr. O'Toole said, "Where's my ham and eggs?"]
 
Geoff,
Actually Chr(34) is nothing but a double-quote ("), so there are still only three string delimiter sets.

Rick
 
And, just to round out this discussion, any combination of the three delimiters can exist as the actual value of a variable, though it is slightly challenging to get them that way:

Code:
myVar = [Mr. O'Toole said, "Where's my ham and eggs?" ]+"[footnote 3]"
?myVar
prints on the screen:
Code:
Mr. O'Toole said, "Where's my ham and eggs?" [footnote 3]

- Bill

Get the best answers to your questions -- See FAQ481-4875.
 
What Rick meant is that CHR(34) is the same as ["], or '"'.

So, for your example:
test = chr(34) + "['x']" + chr(34)

You could use this instead:
test = ["] + "['x']" + ["]

Actually seeing the " character is a little more "self-documenting" than having to lookup what chr(34) is.

- Bill

Get the best answers to your questions -- See FAQ481-4875.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top