| Previous | Contents | Index |
The '~' (quote) character looks for a pattern of text that IS an * (stands for itself).
| Example 6-110 PATTERN function - ~ |
|---|
text$ = '$4,670.00'
if pattern(text$, '$~4,670.00') > 0 then
print 'Your text is correct.'
end if
end
Your text is correct.
|
This feature lets you designate binary data for detecting patterns that are not printable text characters. The characters in the enclosed group can be individual byte values such as {|13|} or groups such as {|0,13,200|}. Since {A-Z} is the range of A through Z, the proper syntax for this same range using byte values would be {{|65|}-{|90|}}.
| Example 6-111 PATTERN function - { |nnn,nnn,nnn | } |
|---|
text$ = 'Help yourself to some ' + chr$(13) + 'food'
if pattern(text$, '{|13|}') > 0 then
print 'Carriage return found.'
end if
end
Carriage return found.
|
The {<cc|ccc|c>} looks for text in str_expr1 that matches the enclosed groups.
| Example 6-112 PATTERN function - { <cc |ccc |c > } |
|---|
text$ = 'The area code is 619'
if pattern(text$, 'is {<619|714|916>}') > 0 then
print 'Your area code is on the list.'
end if
end
Your area code is on the list.
|
(word_text) looks for a match on a word. The word text can contain an embedded "$".
| Example 6-113 PATTERN function - {(word_text) } |
|---|
a$ = 'There are dogs and cats in the house.'
b$ = 'Everyone would like to make big$bucks!'
if pattern(a$, '{(cats)}') > 0 then
print 'The word was found.'
end if
if pattern(b$, '{(big$bucks)}') > 0 then
print 'The $ word was found.'
end if
end
The word was found.
The $ word was found.
|
Directives can be used with the PATTERN function. Multiple directives can be used. Directives are processed from left to right. The valid directives are:
| nocase | can be uppercase, lowercase or a combination of the two |
| case | unless NOCASE specified, default is CASE (i.e. case-exact) |
| bol | beginning of a line |
| eol | end of a line |
| Example 6-114 PATTERN function - { |directive | } |
|---|
a$ = 'ElEpHaNtS have trunks'
b$ = 'water goes splash'
if pattern(a$, '{|bol|}{|nocase|}elephants') > 0 then
print 'elephants was found.'
end if
if pattern(b$, 'splash{|eol|}') > 0 then
print 'splash was found.'
end if
end
elephants was found.
splash was found.
|
POS searches for a substring within a string. It returns the substring's starting character position. str-exp1 is the string to be searched, str-exp2 is the substring to locate, and int-exp is the OPTIONAL character position at which to begin the search. (The default is the start of the string.) If the substring is not found, zero is returned.
| Example 6-115 POS function |
|---|
text$ = "Hello and goodbye" andpos = pos(text$, 'and') if andpos > 0 then print 'AND found at position'; andpos end AND found at position 7 |
This function scans str_expr1 for the characters in str_expr2 and returns the position at which str_expr2 begins. int_expr specifies a character position at which the search is to begin.
The characters in str_expr2 need not appear contiguously in str_expr1.
| Example 6-116 SCAN function |
|---|
let a$ = 'Cameron Whitehorn' let b$ = 'amr Wtor' let position = scan(a$, b$) print position end 2 |
SKIP returns the position of the character following the last skipped character.
str_expr1 is the text string to be searched.
str_expr2 contains the list of characters which are to be skipped. If only one argument is given, SKIP will skip over spaces, tabs and nulls.
int_expr contains the search start position. This parameter is optional.
| Example 6-117 SKIP function |
|---|
a$ = '31415 hello' z = skip(a$, '1234567890 ') print mid(a$, z) end hello |
The following are end user interface system functions that SheerPower performs:
_BACK returns a TRUE or FALSE value. TRUE if the [esc]or the UP ARROW was pressed at the last prompt.
| Example 6-118 _BACK system function |
|---|
message 'Press the Escape key or the Up Arrow key'
input 'Please enter your age' : age$
if _back then
print '_back is set to true'
end if
end
Please enter your age? [Esc] <---- press the Escape key
_back is set to true
|
_EXIT returns a TRUE or FALSE value. TRUE if EXIT was entered at the last prompt.
| Example 6-119 _EXIT system function |
|---|
do
input 'Please enter your name' : name$
if _exit then
print '_exit is set to true'
exit do
end if
loop
end
Please enter your name? [Ctrl/Z] <------ hold down the Ctrl key, then press the Z key
_exit is set to true
|
_HELP returns a TRUE or FALSE value. TRUE if HELP or a question mark (?) was entered at the last prompt.
_HELP should be checked before _BACK and/or _EXIT because, in some cases, all three are set on. For example, if "EXIT" is the default and HELP is entered, both _HELP and _EXIT are set on.
| Example 6-120 _HELP system function |
|---|
input 'Do you need help' : location$
if _help then
print '_help is set to true'
end if
end
Do you need help? help
_help is set to true
|
_REPLY returns the user's reply to the last prompt. The reply is returned as a string.
| Example 6-121 _REPLY system function |
|---|
last$ = 'Enter new text'
do
line input area 5,10,15,50, default last$: text$
if _exit then exit do
last$ = 'You said ' + _reply
loop
end
|
The _TERMINATOR function returns the name of the key that terminated the last INPUT statement. The values returned are:
| UP | Up arrow | |
| DOWN | Down arrow | |
| ENTER | Enter |
F1, F2, F3, F4, F5, F7, F8, F9, F11, F12
| Example 6-122 _TERMINATOR system function |
|---|
do
line input 'name': yourname$
if _exit then exit do
print 'Terminator was: '; _terminator
loop
end
name? [F3] <----- press the F3 key
Terminator was: F3
name? exit
|
VALID is used to validate user responses.
text_str is the text to be validated.
rule_str is the list of validation rules.
Multiple validation rules are separated by a semicolon. If given characters are NOT between quotes, they are to be uppercase.
VALID returns an error if there is an invalid validation rule.
'Illegal validation rule' (-4021)
|
VALID returns TRUE or FALSE according to the following validation rules:
| Example 6-123 Validation rules - ALLOW |
|---|
text$ = 'ann'
vrule$ = 'allow ann, dan, tom'
number$ = '10'
vrules$ = 'number; allow 1 to 6; maxlength 2'
number2$ = '12'
vrules2$ = 'number; allow 1 to 24, 99'
if valid(text$, vrule$) then print 'true'
if not valid(number$, vrules$) &
then print 'false'
if valid(number2$, vrules2$) then print 'true'
end
true
false
true
|
| Example 6-124 Validation rules - DISALLOW |
|---|
number$ = '10'
vrules$ = 'disallow 01, 03, 05; minlength 2'
if valid(number$, vrules$) &
then print 'true'
end
true
|
| Example 6-125 Validation rules - MINLENGTH |
|---|
text$ = 'Hello there'
vrule$ = 'minlength 5'
if valid(text$, vrule$) &
then print 'true'
end
true
|
| Example 6-126 Validation rules - MAXLENGTH |
|---|
text$ = 'Hello'
vrule$ = 'maxlength 5'
if valid(text$, vrule$) &
then print 'true'
end
true
|
| Example 6-127 Validation rules - LENGTH |
|---|
text$ = 'abcdefghijklmnopqrstuvwxyz'
vrule$ = 'length 26'
if valid(text$, vrule$) &
then print 'true'
end
true
|
| Example 6-128 Validation rules - CHARACTERS |
|---|
text$ = 'abc123'
vrule$ = 'characters "abc123"'
if valid(text$, vrule$) &
then print 'true'
end
true
|
| Example 6-129 Validation rules - NOCHARACTERS |
|---|
text$ = 'abc123'
vrule$ = 'nocharacters "def456"'
if valid(text$, vrule$) &
then print 'true'
end
true
|
| Example 6-130 Validation rules - LETTERS |
|---|
text$ = 'It is a sunny day today'
vrules$ = 'letters'
if valid(text$, vrules$) &
then print 'true'
end
true
|
| Example 6-131 Validation rules - LCASE |
|---|
text$ = 'hi there'
vrules$ = 'lcase'
if valid(text$, vrules$) &
then print 'true'
end
true
|
| Example 6-132 Validation rules - UCASE |
|---|
text$ = 'HI THERE'
vrules$ = 'ucase'
if valid(text$, vrules$) &
then print 'true'
end
true
|
| Example 6-133 Validation rules - DIGITS |
|---|
text$ = '983745'
vrules$ = 'digits'
if valid(text$, vrules$) &
then print 'true'
end
true
|
| Example 6-134 Validation rules - DECIMALS |
|---|
text$ = '9837.45'
vrules$ = 'decimals 2'
if valid(text$, vrules$) &
then print 'true'
end
true
|
| Example 6-135 Validation rules - NUMBER |
|---|
text$ = '100'
vrules$ = 'number'
if valid(text$, vrules$) &
then print 'true'
end
true
|
| Example 6-136 Validation rules - INTEGER |
|---|
text$ = '2147483647'
vrules$ = 'integer'
if valid(text$, vrules$) &
then print 'true'
end
true
|
| Example 6-137 Validation rules - INTEGER WORD |
|---|
text$ = '32767'
vrules$ = 'integer word'
if valid(text$, vrules$) &
then print 'true'
end
true
|
| DATE | YMD | YYMMDD format | |
| DATE | DMY | DDMMYY format | |
| DATE | MDY | MMDDYY format | |
| DATE | MDCY | MMDDCCYY format |
| Previous | Next | Contents | Index |