| |
|
| Formats |
Where:
| * |
Asterisk indicates a list of
characters to strip. For example,
STP(X$,1,*"
,:")
This will strip
any trailing spaces, commas, or colons from X$.
A null string results in an Error #46: Length of
string invalid.
|
| ^ |
The caret (up arrow) indicates a
list of characters to not strip. For example,
STP(X$,3,^"0123456789.")
This will strip
any character other than the digit 0-9 or decimal
point. A null string results in an Error #46:
Length of string invalid.
Added PxPlus V10 (version
10)
|
| stp_char$ |
Characters to be stripped from
string. If omitted, blanks are stripped; e.g.,
STP(PTR$,3,$1B$)
! strips out all escape characters
STP("Hello there",3,"e")
! strips out every occurence of lower-case
"e"
|
| stp_code |
Strip code - either string or
numeric value which defines the type of strip
logic to be applied
| Numeric |
String |
Type of stripping to
perform |
| 0 |
"L" |
Strip leading |
| 1 |
"R" |
Strip trailing (default) |
| 2 |
"B" |
Strip both leading and
trailing |
| 3 |
"A" |
Strip all occurrences. |
|
| stmtref |
Program line number or statement
label to which to transfer control in case of an
error.. |
| string$ |
String expression to be processed. |
| format$ |
Format mask to be stripped out of
the string. |
|
| |
|
| Returns |
Stripped
character string. |
| |
|
| Description |
The
STP( ) function returns a character
string generated by stripping specified instances of a
character, or a mnemonic, from a string expression. |
| |
|
| Format
1 |
Strip Character from a
String
STP(string$,stp_code[,stp_char$][,ERR=stmtref])
This format strips the
character stp_char$ (spaces if omitted) from a
string expression. Depending on the stp_code
value, the data can be stripped from the beginning of the
string$, the end of the string$, or
from both the beginning and end. STP( )
can also be used to strip all occurrences of stp_char$
within the string.
ProvideX returns an Error
#41: Invalid integer encountered (range error or
noninteger)if the value you use in stp_code is
not in the range 0 to 3.
Given A$ =
" This is a
test "
| STP
function |
Returns |
| STP(A$,0)
or STP(A$,"L") |
"This
is a test " |
| STP(A$,1)
or STP(A$,"R") |
" This
is a test" |
| STP(A$,2)
or STP(A$,"B") |
"This
is a test" |
| STP(A$,3)
or STP(A$,"A") |
"Thisisatest" |
|
| |
|
| Example |
The
following code sample illustrates stripping of left,
right, both, all as well as the use of "*" to
indicate a list of characters:
0100 ! ^100 - STP
function
0110
Orig$="...Test...String...",Char$="."
0120 print 'LF',"Original String:
"+@(21)+'BR'+Orig$+'ER'+'LF'
0130 Strip=0,Strip$="L"; gosub StripIt;
print
0140 Strip=1,Strip$="R"; gosub StripIt;
print
0150 Strip=2,Strip$="B"; gosub StripIt;
print
0160 Strip=3,Strip$="A"; gosub StripIt
0170 !
0200 ! ^100 - Strip multiple characters
0210 Orig$="xxx Test.zzz String yyy"
0220 print 'LF',"Original String:
"+@(25)+'BR'+Orig$+'ER'
0230 !
0240
Char$="xyz.",Strip=3,Strip$="A"
0250 print
"STP(Orig$,"+quo+Strip$+quo+",*"+quo+Char$+quo+")
= ",
0260 print 'BR'+stp(Orig$,Strip$,*Char$)+'ER'
0270 !
0280 Orig$="(888)975-7587x107"
0290 print 'LF',"Original String:
"+@(25)+'BR'+Orig$+'ER'
0300 !
0310
char$="0123456789",strip=3,strip$="A"
0320 print
"STP(Orig$,"+quo+Strip$+quo+",^"+quo+Char$+quo+")
= ",
0330 print 'BR'+stp(Orig$,Strip$,^Char$)+'ER'
0340 !
0350 stop
0360 !
0400 ! ^100
0410 StripIt:
0420 print
"STP(Orig$,"+pad(str(Strip),3,2)+","+quo+Char$+quo+")
= ",
0430 print @(21)+'BR'+stp(Orig$,Strip,Char$)+'ER'
0440 print
"STP(Orig$,"+quo+Strip$+quo+","+quo+Char$+quo+")
= ",
0450 print @(21)+'BR'+stp(Orig$,Strip$,Char$)+'ER'
0460 return
|
| |
|
| Format
2 |
Remove Mnemonic from a
String
STP(MNEMONIC string$[,ERR=stmtref])
This format removes all
mnemonics contained within the string$. This
form of the STP function is usually used to remove
mnemonics from string that are being printed or loaded
into a LIST_BOX for display where the string itself
contains various escape sequences to control visual
attributes.
|
| |
|
| Format
3 |
Remove
Format from a String The STP( ) function also
provides the ability to remove formatting from strings.
The output of a string passed through the STR
( ) function to be formatted can passed to the STP
function with the same format specification to remove the
formatting information.
For Example:
A$ =
"123456789"
B$ = STR(A$:"00-0000-000") ! yields B$ =
"12-3456-789"
C$ = STP(B$:"00-0000-000") ! yields C$ =
"123456789"
The STP
function does not mandate that the input strictly adhere
to the format. That is to say, that the formatting
characters are stripped only if present. This means in
the above example if B$ was "12-3456789"
(missing second dash), the system would still return
"123456789". The function only strips matching
formatting characters. If the formatting character is not
in the input string then it is assumed optional.
The ability to strip
the format from a string is a +PxPlus
Exclusive
|
| |
|