Institut für Astronomie und AstrophysikAbteilung AstronomieSand 1, D-72076 Tübingen, Germany |
IDL_VALIDNAME()
Modify a string if necessary, so that it can used as a IDL variable name.
Duplicates the intrinsic V6.0 function IDL_VALIDNAME() with the CONVERT_ALL keyword, for pre-V6.0 compatibility IDL_VALIDNAME performs the following: (1) All non-alphanumeric characters (except '_' and '$') are converted to underscores (2) If the first character is not alphabetic or a '_' or a '!' then an underscore is preprended to the string (3) If the string is an IDL reserved word (e.g. 'endif') then an underscore is preprended to the string.
result = IDL_VALIDNAME( str, /Convert_all )
str - Scalar string to be converted to a valid variable name.
result - the input string modified, if necessary, according to the 3 rules above, so that it can be used as a valid IDL variable.
/CONVERT_ALL -- Does nothing, but ensures compatibility with V6.0 intrinsic call IDL_VALIDNAME(/CONVERT_ALL)
None.
(1) IDL> print,idl_validname('switch',/convert_all) _switch ;IDL reserved keyword (2) IDL> print,idl_validname('2mass',/convert_all) _2mass ;1st character must be alphabetic (3) IDL> print,idl_validname('date$',/convert_all) date$ ;no change, input string already valid
Written by W. Landsman SSAI October 2003
[Home Page] [Software, Documentation] [IDL Documentation] [Quick Reference] [Feedback]