Tip: See also the IDL_String::StartsWith, IDL_String::EndsWith, and IDL_String::Contains methods, which provide similar functionality but with an object-oriented interface.

The STRCMP function performs string comparisons between its two String arguments, returning True (1) for those that match and False (0) for those that do not. Normally, the IDL equality operator (EQ) is used for such comparisons, but STRCMP can optionally perform case-insensitive comparisons and can be limited to compare only the first N characters of the two strings, both of which require extra steps using the EQ operator.


Compare two strings in a case-insensitive manner, considering only the first 3 characters:

Result = STRCMP('Moose', 'moo', 3, /FOLD_CASE)
PRINT, Result

IDL prints:



Result = STRCMP( String1, String2 [, N], /FOLD_CASE )

Return Value

If all of the arguments are scalar, the result is scalar. If one of the arguments is an array, the result is an integer with the same structure. If more than one argument is an array, the result has the structure of the smallest array. Each element of the result contains True (1) if the corresponding elements of String1 and String2 are the same, and False (0) otherwise.


String1, String2

The strings to be compared.


Normally String1 and String2 are compared in their entirety. If N is specified, the comparison is made on at most the first N characters of each string.



String comparison is normally a case sensitive operation. Set FOLD_CASE to perform case insensitive comparisons instead.

Version History



See Also

String Operations, String Processing, STREGEX, STRJOIN, STRMATCH, STRMID, STRPOS, STRSPLIT, IDL_String


This information is not subject to the controls of the International Traffic in Arms Regulations (ITAR) or the Export Administration Regulations (EAR). However, it may be restricted from transfer to various embargoed countries under U.S. laws and regulations.
© 2017 Exelis Visual Information Solutions, Inc., a subsidiary of Harris Corporation