mglib

Personal IDL library for M. Galloy

single page | use frames     summary     class     fields     routine details     file attributes

strings/

mg_string__define.pro


Class representing a string and an example of using operator overloading available in IDL 8.0. This class does not require IDL 8.0 to compile because an IDL_Object class (which this class inherits from) is provided. Operator overloading will not be available when using IDL versions before 8.0, but the methods could be called directly.

Class description for mg_string

Inheritance

Properties

Properties in mg_string

format init
length get

length of the string

Routines

Methods inherited from idl_object

Routines from mg_string__define.pro

mg_string::getProperty, length=length

Get properties.

result = mg_string::toString()

Returns the underlying IDL string.

result = mg_string::_overloadBracketsRightSide(isRange, ss1 [, ss2] [, ss3] [, ss4] [, ss5] [, ss6] [, ss7] [, ss8])

Called when a string object is accessed with the square brackets, i.e., [].

result = mg_string::_overloadPound(left, right)

Called when the two strings or string objects are joined using a format code by the # operator.

result = mg_string::_overloadPlus(left, right)

Called when two strings or strings objects are concatenated with the + operator.

result = mg_string::_overloadHelp(varname)

Called by the HELP routine when information about this object is required.

result = mg_string::_overloadPrint()

Called by the PRINT routine when this object is printed.

result = mg_string::_overloadForeach(value [, key])

Called by the FOREACH routine when this object is looped over.

result = mg_string::init(str [, format=string])

Initialize the object.

mg_string__define

Define instance variables.

Routine details

top mg_string::getProperty

mg_string::getProperty, length=length

Get properties.

Keywords

length

length of the string

Examples

Properties can be access with . in IDL 8.0:

IDL> s = mg_string('Hello, World!') IDL> print, s.length 13

top mg_string::toString

result = mg_string::toString()

Returns the underlying IDL string.

Return value

string

top mg_string::_overloadBracketsRightSide

result = mg_string::_overloadBracketsRightSide(isRange, ss1 [, ss2] [, ss3] [, ss4] [, ss5] [, ss6] [, ss7] [, ss8])

Called when a string object is accessed with the square brackets, i.e., [].

Return value

IDL string

Parameters

isRange in required type=lonarr(1..8)

array of the same length as the number of dimensions indexed in the bracket expression

ss1 in required type=long or lonarr(3)

index or range of characters to extract

ss2 in optional type=long or lonarr(3)

not used for strings

ss3 in optional type=long or lonarr(3)

not used for strings

ss4 in optional type=long or lonarr(3)

not used for strings

ss5 in optional type=long or lonarr(3)

not used for strings

ss6 in optional type=long or lonarr(3)

not used for strings

ss7 in optional type=long or lonarr(3)

not used for strings

ss8 in optional type=long or lonarr(3)

not used for strings

Examples

For example:

IDL> s = mg_string('Hello, World!') IDL> print, s[0] H IDL> print, s[0:4] Hello

top mg_string::_overloadPound

result = mg_string::_overloadPound(left, right)

Called when the two strings or string objects are joined using a format code by the # operator.

Return value

string object

Parameters

left in required type=string or string object

string on the left of the # operator

right in required type=string or string object

string on the right of the # operator

Examples

For example:

IDL> print, mg_string('Location: %s') # 'Boulder, CO' Location: Boulder, CO IDL> print, 'Location: %s' # mg_string('Boulder, CO') Location: Boulder, CO

top mg_string::_overloadPlus

result = mg_string::_overloadPlus(left, right)

Called when two strings or strings objects are concatenated with the + operator.

Return value

string object

Parameters

left in required type=string or string object

string on the left of the + operator

right in required type=string or string object

string on the right of the + operator

Examples

For example:

IDL> s1 = mg_string('Hello') IDL> s2 = mg_string('World!') IDL> print, s1 + s2 HelloWorld! IDL> print, s1 + ", " + s2 Hello, World!

top mg_string::_overloadHelp

result = mg_string::_overloadHelp(varname)

Called by the HELP routine when information about this object is required.

Return value

string

Parameters

varname in required type=string

name of the variable at the level where HELP was called

Examples

For example:

IDL> s = mg_string('Hello, World!') IDL> help, s S MG_STRING = 'Hello, World!'

top mg_string::_overloadPrint

result = mg_string::_overloadPrint()

Called by the PRINT routine when this object is printed.

Return value

string

Examples

For example:

IDL> s = mg_string('Hello, World!') IDL> print, s Hello, World!

top mg_string::_overloadForeach

result = mg_string::_overloadForeach(value [, key])

Called by the FOREACH routine when this object is looped over.

Return value

1 if there are more characters in the string, 0 if not

Parameters

value out required type=string

character returned as the next character in the string

key in out optional type=undefined/long

index of current position in the string; undefined for starting

Examples

For example:

top mg_string::init

result = mg_string::init(str [, format=string])

Initialize the object.

Return value

1 if successful, 0 if not

Parameters

str in required type=string

IDL string to represent

Keywords

format in optional type=string

format string as expected by STRING routine

top mg_string__define

mg_string__define

Define instance variables.

File attributes

Modification date: Wed May 14 15:07:14 2014
Lines: 54
Docformat: rst rst
Personal library of Michael Galloy
Contact me if you have enhancement requests or bug fixes.