Sheerpower®
A Guide to the Sheerpower Language


Previous Contents Index

6.5.6 SCAN(str_expr1, str_expr2 [, int_expr])

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-136 SCAN Function

  let a$ = 'Cameron Whitehorn' 
  let b$ = 'amr Wtor' 
  let position = scan(a$, b$) 
  print position
  end
 
 
2 

6.5.7 SKIP(str_expr1 [, str_expr2] [, int_expr])

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-137 SKIP Function

  a$ = '31415 hello' 
  z  = skip(a$, '1234567890 ') 
  print mid(a$, z) 
  end
 
 
hello 

6.6 User Interface Functions

The following are end user interface system functions that Sheerpower performs:

6.6.1 _BACK

_BACK returns a TRUE or FALSE value. TRUE if the [esc]or the UP ARROW was pressed at the last prompt.

Example 6-138 _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 

6.6.2 _EXIT

_EXIT returns a TRUE or FALSE value. TRUE if EXIT was entered at the last prompt.

Example 6-139 _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 

6.6.3 _HELP

_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-140 _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 

6.6.4 _REPLY

_REPLY returns the user's reply to the last prompt. The reply is returned as a string.

Example 6-141 _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

6.6.5 _TERMINATOR

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-142 _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 

6.6.6 VALID(text_str, rule_str)

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-143 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 


  • DISALLOW text1, text2, text3 [to text4]
    DISALLOW returns TRUE if text_str cannot be found on the rule_str list.
  • Example 6-144 Validation Rules - DISALLOW

      number$ = '10' 
      vrules$ = 'disallow 01, 03, 05; minlength 2' 
      if  valid(number$, vrules$) & 
        then print 'true' 
      end
     
     
    true 
    

  • MINLENGTH nn
    Minimum of nn characters long.
  • Example 6-145 Validation Rules - MINLENGTH

      text$  = 'Hello there' 
      vrule$ = 'minlength 5' 
      if  valid(text$, vrule$) & 
        then print 'true' 
      end
      
      
    true 
    

  • MAXLENGTH nn
    Maximum of nn characters long.
  • Example 6-146 Validation rules - MAXLENGTH

      text$  = 'Hello' 
      vrule$ = 'maxlength 5' 
      if  valid(text$, vrule$) & 
        then print 'true' 
      end
      
                                  
    true 
    

  • LENGTH nn
    Exactly nn characters long.
  • Example 6-147 Validation Rules - LENGTH

      text$  = 'abcdefghijklmnopqrstuvwxyz' 
      vrule$ = 'length 26' 
      if  valid(text$, vrule$) & 
        then print 'true' 
      end
      
      
    true 
    

  • CHARACTERS "ccc"
    Returns TRUE if the given characters (letters or numbers) are on the rule_str list.
  • Example 6-148 Validation Rules - CHARACTERS

      text$  = 'abc123' 
      vrule$ = 'characters "abc123"' 
      if  valid(text$, vrule$) & 
        then print 'true' 
      end
      
      
    true 
    

  • NOCHARACTERS "ccc"
    Returns TRUE if the given characters are not on the rule_str list.
  • Example 6-149 Validation Rules - NOCHARACTERS

      text$  = 'abc123' 
      vrule$ = 'nocharacters "def456"' 
      if  valid(text$, vrule$) & 
        then print 'true' 
      end
      
      
    true 
    

  • LETTERS
    Returns TRUE if given text_str consists only of A - Z, a - z or space.
  • Example 6-150 Validation Rules - LETTERS

      text$   = 'It is a sunny day today' 
      vrules$ = 'letters' 
      if  valid(text$, vrules$) & 
        then print 'true' 
      end
      
      
    true 
    

  • LCASE
    Returns TRUE if given text_str consists of lowercase letters.
  • Example 6-151 Validation Rules - LCASE

      text$   = 'hi there' 
      vrules$ = 'lcase' 
      if  valid(text$, vrules$) & 
        then print 'true' 
      end
      
      
    true 
    

  • UCASE
    Returns TRUE if given text_str consists of uppercase characters.
  • Example 6-152 Validation Rules - UCASE

      text$   = 'HI THERE' 
      vrules$ = 'ucase' 
      if  valid(text$, vrules$) & 
        then print 'true' 
      end
      
      
    true 
    

  • DIGITS
    Returns TRUE if text_str consists of the numbers 0 - 9.
  • Example 6-153 Validation Rules - DIGITS

      text$   = '983745' 
      vrules$ = 'digits' 
      if  valid(text$, vrules$) & 
        then print 'true' 
      end
      
      
    true 
    

  • DECIMALS nn
    Specifies the maximum number of decimal places.
  • Example 6-154 Validation Rules - DECIMALS

      text$   = '9837.45' 
      vrules$ = 'decimals 2' 
      if  valid(text$, vrules$) & 
        then print 'true' 
      end
      
      
    true 
    

  • NUMBER
    Indicates that text_str is numeric (validates that number).
  • Example 6-155 Validation Rules - NUMBER

      text$   = '100' 
      vrules$ = 'number' 
      if  valid(text$, vrules$) & 
        then print 'true' 
      end
      
      
    true 
    

  • INTEGER
    Returns TRUE if given integer number is up to 32 bits long (i.e. 2147483647).
  • Example 6-156 Validation Rules - INTEGER

      text$   = '2147483647' 
      vrules$ = 'integer' 
      if  valid(text$, vrules$) & 
        then print 'true' 
      end
      
      
    true 
    

  • INTEGER WORD
    Returns TRUE if given integer number is up to 16 bits long (i.e. 32767).
  • Example 6-157 Validation rules - INTEGER WORD

      text$   = '32767' 
      vrules$ = 'integer word' 
      if  valid(text$, vrules$) & 
        then print 'true' 
      end
      
      
    true 
    

  • DATE
    Validates a given date in: YYMMDD or CCYYMMDD format.
      DATE YMD YYMMDD format
      DATE DMY DDMMYY format
      DATE MDY MMDDYY format
      DATE MDCY MMDDCCYY format


  • Previous Next Contents Index