1828355 Members
3017 Online
109976 Solutions
New Discussion

String comparision

 
SOLVED
Go to solution
ram_47
Frequent Advisor

String comparision

Any string ‘case-insensitive’ comparison function available on Alpha?
7 REPLIES 7
Volker Halle
Honored Contributor
Solution

Re: String comparision

Ram,

there is strncasecmp ( see $ HELP CRTL ) and there is also STR$CASE_BLIND_COMPARE ( see $ HELP LIB STR$ )

The CRTL routines may depend on your version of OpenVMS, the STR$ routines are always available.

Volker.
Martin Vorlaender
Honored Contributor

Re: String comparision

ram,

this heavily depends on your VMS version. More recent versions of the C runtime library (that comes with the OS!) know the str(n)casecmp function.

And then there's the VMS String manipulation library with its STR$CASE_BLIND_COMPARE , see http://h71000.www7.hp.com/doc/73final/5936/5936pro_003.html#5936case_blind_compare_4

cu,
Martin
Jan van den Ende
Honored Contributor

Re: String comparision

ram,

if this question is about functions within a compiled language, see Volker & Martin.

It it is about DCL, then the default comparison is case-sensitive.
For case-blind, use:
$ f$edit(string_a,"upcase") .eqs. f$edit(string_b,"upcase")

of course, instead of .eqs. (EQualString) you can also use .nes. (NotEqualString), .gts. (GreaterThenString), .ges. (Greater or Equal String), .lts. or .les.

hth

Proost.

Have one on me.

jpe
Don't rust yours pelled jacker to fine doll missed aches.
ram_47
Frequent Advisor

Re: String comparision

what header do we need to include for these routines?
Martin Vorlaender
Honored Contributor

Re: String comparision

$ HELP CC RUN-TIME strncasecmp

says it's

cu,
Martin
Antoniov.
Honored Contributor

Re: String comparision

Hi Ram,
the best practise to use case insensitive function in c language is use of strcasecmp and strncasecmp.
Type
$ HELP CC RUN STRCASECMP
$ HELP CC RUN STRNCASECMP

Antonio Vigliotti
Antonio Maria Vigliotti
Antoniov.
Honored Contributor

Re: String comparision

I use these definition to keep compatibility with other platform:
#define stricmp STRCASECMP
#define strnicmp STRNCASECMP

Warning: strcasecmp and strncasecomp are avaiable only from V7.0 of VMS. If you want to compile with V6 compatibility you can't use these function.

Antonio Vigliotti
Antonio Maria Vigliotti