Previous | Contents | Index |
The BASE64DECODE$ function allows you to take Base64 encoded data and decode it into plain text. To encode text into Base64, see Section 6.4.2, BASE64ENCODE$(str_expr,[boolean]).
Example 6-55 BASE64DECODE$ Function |
---|
print base64decode$('V2hlbiBvbmUgZG9vciBjbG9zZXMsIGFub3RoZXIgb3BlbnM7IGJ1dCB3ZSBvZnRlbiBsb29rIHNv' + 'IGxvbmcgYW5kIHNvIHJlZ3JldGZ1bGx5IHVwb24gdGhlIGNsb3NlZCBkb29yIHRoYXQgd2UgZG8g' + 'bm90IHNlZSB0aGUgb25lIHdoaWNoIGhhcyBvcGVuZWQgZm9yIHVzLiAtQWxleGFuZGVyIEdyYWhh' + 'bSBCZWxs') end When one door closes, another opens; but we often look so long and so regretfull y upon the closed door that we do not see the one which has opened for us. -Alex ander Graham Bell |
Example 6-56 BASE64DECODE$ Function#2 |
---|
a$ = 'c3VyZQ==' b$ = base64decode$(a$) print b$ end sure |
CHANGE$ changes specified characters in str_expr1. str_expr1 is the source string. str_expr2 contains the target characters, and str_expr3 specifies the substitution characters. CHANGE$ returns the changed string.
CHANGE$ searches for the target characters within the source string and replaces these characters with the substitution characters. The substitution characters are mapped onto the target characters.
Example 6-57 CHANGE$ Function |
---|
let a$ = 'bdbdbdbd' let b$ = 'b' let c$ = 'c' let changed$ = change$(a$, b$, c$) print a$ print changed$ end bdbdbdbd cdcdcdcd |
CHARSET$ returns the character set specified. The optional string expression can be used to specify the character set to return. The available character sets are:
UCASE | all upper-case letters (A-Z) | |
LCASE | all lower-case letters (a-z) | |
CONTROL | all control characters (ASCII 0-31) | |
ASCII | the ASCII character set, in order (0-255) |
ASCII is the default character set for CHARSET$.
Example 6-58 CHARSET$ Function |
---|
line input 'Enter your text': text$ // change upper-case to lower-case ct$ = change$(text$, & charset$('ucase'), & charset$('lcase')) print 'Lower-case version is:'; ct$ end Enter your text? TESTER Lower-case version is: tester |
CHR$ returns a string with the specified ASCII value (int_expr1) repeated the specified number of times (int_expr2). If no count is specified, a default count of one is used.
Example 6-59 CHR$ Function |
---|
x = 65 print chr$(x) // prints A -- the 65th ASCII character end A |
Given an integer (int_expr1) and an optional length (int_expr2), which defaults to four, the CONVERT$ function returns a string mapping of the integer.
If the optional data type (int_expr3) is 17, the returned string will be a packed floating (PF).
The following data types are supported:
Data Type | Conversion Result |
---|---|
1 | Integer (2 or 4 byte) |
7 | COBOL comp-3 (C3 packed decimal) |
17 | Packed floating (PF) |
Example 6-60 CONVERT$ Function: Supported Data Types |
---|
a$ = convert$(16961) print a$ end AB |
Given a string containing a mapped integer, the CONVERT function returns the integer value.
Example 6-61 CONVERT Function |
---|
a$ = 'AB' b = convert(a$) print b end 16961 |
The CONVERT and CONVERT$ functions can be used in situations such as building segmented keys consisting of multiple data types.
CPAD$ returns a new string, padded on the left and on the right with pad characters. text_str is the string to be centered, size is the size of the new string. The default pad character is a space.
Example 6-62 CPAD$ Function |
---|
print cpad$('123', 9, '0') end 000123000 |
EDIT$ performs one or more editing operations on the supplied string argument, depending on the value of the integer expression. The integer expression is one of the integers below, or a sum of integers below for the desired edit functions:
Value | Edit Operation |
---|---|
1 | Trim parity bits. |
2 | Discard all spaces and tabs. |
4 | Discard characters: CR, LF, FF, ESC, RUBOUT and NULL. |
8 | Discard leading spaces and tabs. |
16 | Reduce spaces and tabs to One space. |
32 | Convert lower case to upper case. |
64 | Convert "[" to "(" and "]" to ")". |
128 | Discard trailing spaces and tabs. |
256 | Do not alter characters inside quotes. |
Example 6-63 EDIT$ Function |
---|
print edit$('hi there, how are you today?' , 32) HI THERE, HOW ARE YOU TODAY? |
The ELEMENTS function returns the number of elements in a string expression that contains a list of elements. str_expr1 is the string containing the list of elements. str_expr2 is the separator. A comma is the default separator.
A given element is considered quoted only if the first non-blank character of the element is a single or double quote mark.
Example 6-64 ELEMENTS Function |
---|
alphabet$ = 'a;b;c;d;e;f;g;h;i;j;k;l;m;n;o;p;q;r;s;t;u;v;w;x;y;z' print elements(alphabet$, ';') end 26 |
ELEMENT$ returns the element from str_expr1 which is specified by the num_expr. str_expr1 contains a set of elements with separators between them. The default separator is a comma:
Example 6-65 ELEMENT$ Function |
---|
let a$ = element$('ADD,DEL,EXIT',2) print a$ end DEL |
Example 6-66 ELEMENT$ Function: Separators |
---|
let sentence$ = 'This is a test.' let a$ = element$(sentence$,2,' ') print a$ end is |
The following example shows how having two commas [the default separator] in a row will cause the result to be nothing [null] for that particular element. |
Example 6-67 ELEMENT$ Function: Separators |
---|
let sentence$ = 'This,, is, a, test' print element$(sentence$, 2) end |
Previous | Next | Contents | Index |