| Previous | Contents | Index |
and
PIECE$ returns an element from str_expr1 specified by num_expr. str_expr1 contains a list of elements. The separator can be indicated by str_expr2. The default separator is a carriage-return line-feed pair.
These two functions are similar to the ELEMENTS() and ELEMENT$() functions except that:
| Example 6-81 PIECE$ function |
|---|
message 'Enter in a long line of text to be rewrapped. Then click DONE'
line input area 5, 10, 8, 60: text$
print at 10, 1: 'Rewrapped text'
wt$ = wrap$(text$, 1, 30)
print 'Number of lines: '; pieces(wt$)
print wt$
print
print 'First line was: '; piece$(wt$, 1)
end
+------------------------------------------+
|This line of text is long enough to be |
|rewrapped into more than one line. |
| |
| |
+------------------------------------------+
Done Back Exit Help
Enter in a long line of text to be rewrapped. Then click DONE.
This line of text is long enough to be rewrapped into
more than one line.
Rewrapped text
Number of lines: 3
This text is long
enough to be rewrapped into
more than one line.
First line was: This text is long
|
PRETTY$ converts text so that the text displays on any terminal. Named control characters show up with their names. Other control characters show up as {X} where "X" is the letter to press or as {XX} where "XX" is the hexadecimal value of the character.
| Example 6-82 PRETTY$ function |
|---|
a$ = 'Hello' + chr$(5) + chr$(161) + chr$(7)
print pretty$(a$)
end
Hello{^E}{A1}{bel}
|
The QUOTE$ function encloses a string expression in double quotes. If the string expression is already enclosed in double quotes, QUOTE$ leaves it alone. If the string expression is already wrapped in single quotes, QUOTE$ replaces them with double quotes. Elements double-quoted within the string expression are given another pair of double quotes (see following example). Elements single-quoted within the string expression are ignored.
| Example 6-83 QUOTE$ function |
|---|
do
clear
print at 1,1:
message 'Enter a line of text to be quoted'
print 'Text:'
input '', length 30: line$
if _back or _exit then exit do
if line$ = '' then repeat do
print
print 'Quoted text using the QUOTE$ function...'
print quote$(line$)
delay
loop
end
Text:
? The little boy cried "wolf!"
Quoted text using the QUOTE$ function...
"The little boy cried ""wolf!"""
|
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?
|
| Previous | Next | Contents | Index |