| Previous | Contents | Index |
REPEAT$ creates a string composed of the specified string repeated the specified number of times.
| Example 6-84 REPEAT$ function |
|---|
print repeat$('Hi!', 9)
Hi!Hi!Hi!Hi!Hi!Hi!Hi!Hi!Hi!
|
REPLACE$ searches for a list of patterns in the str_expr1 and replaces it with the output string from str_expr2. REPLACE$ returns the replaced string expression.
str_expr1 is a list of patterns to search for.
str_expr2 is the replacement list.
str_sep1 is the optional separator for replacement items. The default is a comma.
str_sep2 is the optional separator between the input and output text in items. Default is =.
| Example 6-85 REPLACE$ function |
|---|
text$ = '01-Mar-1989' print replace$(text$, 'r=y 8=9' , ' ') end 01-May-1999 |
RIGHT$ returns the rightmost characters from a string. int_exp is the character position of the last character to be included in the substring COUNTING FROM THE RIGHT.
| Example 6-86 RIGHT [$] function |
|---|
ans$ = right$('Daniel', 2)
print 'rightmost characters = '; ans$
end
rightmost characters = el
|
RPAD$ pads a string on the right with pad characters. The default pad character is a space.
| Example 6-87 RPAD$ function |
|---|
print rpad$('123', 6, '0')
end
123000
|
RTRIM$ returns a string without any trailing spaces (those on the right side).
| Example 6-88 RTRIM$ function |
|---|
let a$ = ' HELLO ' print '*'; a$; '*' let stripped$ = rtrim$(a$) print '*'; stripped$; '*' * HELLO * * HELLO* |
The SEG$ function uses a first and last character position to extract the substring.
| Example 6-89 SEG$ function |
|---|
print seg$('abcdefghijklmnop', 3, 8)
cdefgh
|
This function sorts the elements from a str_expr1 in ASCII value order; returns a list of the sorted elements.
str_expr1 contains the list of elements to be sorted.
str_expr2 is an optional separator. Default is a comma.
| Example 6-90 SORT$ function |
|---|
a$ = 'code area is' a_sort$ = sort$(a$, ' ') print a_sort$ end area code is |
SPACE$ returns the number of spaces indicated by num_expr.
| Example 6-91 SPACE$ function |
|---|
indent = 10
indent$ = space$(10)
print indent$; 'This text is indented'; indent; 'spaces.'
end
This text is indented 10 spaces.
|
STR$ changes a number to a numeric string. The string that is created does not have any extra leading or trailing spaces.
| Example 6-92 STR$ function |
|---|
age = 22 me$ = "I am " + str$(age) + " years old." print me$ end I am 22 years old. |
When used with the PRINT statement, the TAB function moves the cursor or print mechanism to the right to a specified column.
| Example 6-93 TAB function |
|---|
print tab(20); 'Hello there!'
Hello there!
|
TRIM$ returns the string specified stripped of any leading or trailing spaces and tabs.
| Example 6-94 TRIM$ function |
|---|
let a$ = ' HELLO ' print '*'; a$; '*' let stripped$ = trim$(a$) print '*'; stripped$; '*' * HELLO * *HELLO* |
UCASE returns a string expression with all letters in upper case. See also Section 6.4.15, LCASE$(str_expr).
| Example 6-95 UCASE$ function |
|---|
print ucase$('are you enjoying this manual so far?')
ARE YOU ENJOYING THIS MANUAL SO FAR?
|
The UNQUOTE$ function removes one set of quotes from a quoted string expression. If the string expression is not quoted, UNQUOTE$ leaves the string alone. UNQUOTE$ does not affect internally quoted elements.
| Example 6-96 UNQUOTE$ function |
|---|
do
print at 1,1:
message 'Enter a line of text to be unquoted'
print 'Text:'
input '', length 50: line$
if _back or _exit then exit do
if line$ = '' then repeat do
print
print 'Quotes removed using the UNQUOTE$ function...'
print unquote$(line$)
delay
loop
end
Text:
? "I will not take these 'things' for granted."
Quotes removed using the UNQUOTE$ function...
I will not take these 'things' for granted.
|
The URLENCODE$ function takes a string and converts it to a new string that can be used as data in a browser URL. Spaces in the string are converted to + signs, and in the example below, the ampersand & is converted to %26. To decode a converted string, see Section 6.4.44, URLDECODE$(str_expr).
| Example 6-97 URLENCODE$ function |
|---|
mydata$ = '?phrase=' + urlencode$('Dogs & cats')
print mydata$
end
?phrase=Dogs+%26+cats
|
The URLDECODE$ function takes the encoded string data in a browser URL and decodes it into plain text. In the example below, the + signs are converted to spaces, and the %26 is converted to an ampersand (&). To encode string data for use in a browser URL see Section 6.4.43, URLENCODE$(str_expr).
| Example 6-98 URLDECODE$ function |
|---|
print urldecode$('?phrase=Dogs+%26+cats ')
end
?phrase=Dogs & cats
|
VAL returns the floating-point value of a numeric string.
| Example 6-99 VAL function |
|---|
text$ = "My age is 20" z0$ = element$(text$, 4, ' ') age = val(z0$) print 'In 10 years I will be'; age + 10 end In 10 years I will be 30 |
WRAP$ returns a word-wrapped text string, given left and right margins. Each line of the string is separated with a CR/LF.
Where string_expr = text string to wrap, int_expr1 = left margin, int_expr2 = right margin.
| Example 6-100 WRAP$ function |
|---|
input 'Type in a sentence' ; text$
text$ = wrap$(text$, 5, 15)
print text$
end
Type in a sentence? This is an example of the wrap$ function.
This is an
example of
the wrap$
function.
|
The XLATE$ function translates one string to another by referencing a table you supply. For example, the XLATE$ function can translate from EBCDIC to ASCII. The first str_expr is the string to be translated. The second str_expr is the translation table.
| Example 6-101 XLATE$ function |
|---|
a$ = charset$
a$[66:66] = 'x' // change the "A" to a lowercase "x"
print xlate$('DAN', a$)
end
DxN
|
| Previous | Next | Contents | Index |