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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

escaping ' within a String 1

Status
Not open for further replies.

kaeserea

Programmer
Feb 26, 2003
164
DE
Hi!

I have to set a variable. The value of the variable should be

IF HVNL EQ 'S'

With -SET I have a problem:

-SET &IF_HVNL = 'IF HVNL EQ 'S''

The problem is the '' within the ''. How can I create the above outcome?

Thanx
Eva
 
Hello Eva,

Use double ' :

-SET &IF_HVNL = ' IF HVNL EQ ''S'' ' ;


Hope this helps
Grzegorz
 
Hi Eva,

You can try this as well:
Code:
-SET &IF_HVNL = 'IF HVNL EQ ' | '''' | 'S' | '''';
By using 4 quotes you provide 1 quote in the code. This is a normal standard in several languages. Frank van de Kant
 
Or maybe you can use a define somewhere or a compute;
HELP/I1=IF HVNL EQ 'S' THEN 1 ELSE 0 and use that check. Using this kind of assisting fields is useful in cases you have multiple IF factors and you need to figure out if all of them are true or one is. Also as sortfields if you need multiple subfoots or something like that.

In some cases I've noticed that comparing alpha fields causes some major headaches. Usually if you haven't used nodata commands and the database pops out a null value (usually after the DA has sworn there are no null values in that field).


Cheers,
Hank W.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top