string ( string op string )
Comparison between two strings, returning either 0 (false) or 1 (true); op is one of the boolean operators below :
> Larger Than | < Smaller Than |
>= Larger or Equal | <= Smaller or Equal |
= Equal | <> Not Equal |
...
Smaller, greater, equal applied to strings refer to lower, higher, same alphabetical order. The comparison is case sensitive and is done using the ASCII code of each letter, hence the following expression is true (returns 1) :
...
Type man ascii at the UNIX prompt to know more about the ASCII encoding of characters.
...
string ( string & string & ... )
string ( string & number & ... )
string ( number & string & ... )
string ( string & date & ... )
string ( date & string & ... )
Returns a string equal to the concatenation of strings or strings and numbers and/or dates. If concatenating a date, the date is first converted to a string using the default string date format.
Anchor ascii ascii
string ascii( number )
Returns a string consisting of one character whose ASCII code has been provided as the single parameter to the function. For example:
linefeed = ascii (10)
Anchor length
...
length
number length( string )
This function returns the length of a string
word = "hello"
print (word, " is ", length(word), "characters long")
Anchor lowercase lowercase
string lowercase( string )
Returns a lowercase copy of the input string.
Anchor number number
number number( string )
Converts a string into a number; if a string cannot be converted into a number, then zero is returned. Example: a = number('123.4')
Anchor parse parse
list
parse( string )
list parse( string,string )list parse( string,string,string )
...
The parse()
function is useful to parse text input when reading ASCII files within a macro program. Note that for ASCII data structured in columns (such as CSV files), Metview has some specific tools available - see ASCII Tables for more information.
Anchor search
...
search
string search (string,string)
...
filename = 'z_t2m_u_v_20060717.grib'
t2m_index = search (filename, 't2m')
returns the value 3.
Anchor substring
...
substring
string substring (string,number,number)
...
substring ("Metview", 2, 4)
returns the string "
etv
"
.
Anchor string
...
string
string string( date,string )
...
yy gives 97
yyyy gives 1997
m gives 4
mm gives 04
mmm gives Apr
mmmm gives April
d gives 1
dd gives 01
ddd gives Tue
dddd gives Tuesday
D gives 91 (4th of April = julian day 91; 92 for a leap year).
DDD gives 091
H gives 2
HH gives 02
M gives 3
MM gives 03
S gives 4
SS gives 04
Any other character is copied as such.
Anchor uppercase uppercase
string
uppercase( string )
Returns an uppercase copy of the input string.
...