Sheerpower®
A Guide to the Sheerpower Language


Previous Contents Index

Important Note

For all dates, use 'LENGTH nn' to control whether a 6- or 8-character date is required.

  • DATE DMONY
    Checks if text_str is a legal date in DD-Mon-YY format and returns TRUE (1) or FALSE (0).
  • Example 6-158 Validation Rules - DATE DMONY

      text$  = '01-Jan-99' 
      vrule$ = 'date dmony' 
      print valid(text$, vrule$) 
      end
     
     
    1 
    

  • DATE DMONCY
    Checks if text_str is a legal date in DD-Mon-CCYY format and returns TRUE (1) or FALSE (0).
  • Example 6-159 Validation Rules - DATE DMONCY

      text$  = '01-Jan-2000' 
      vrule$ = 'date dmoncy' 
      print valid(text$, vrule$) 
      end
     
     
    1 
    

  • FULLTIME
    Checks if text_str is a legal date and time in CCYYMMDD HHMMSS or YYMMDD HHMMSS format and returns TRUE (1) or FALSE (2).
  • Example 6-160 Validation Rules - FULLTIME

      text$  = '20000122 010101' 
      text2$ = '990122 010101' 
      vrule$ = 'fulltime' 
      print valid(text$, vrule$) 
      print valid(text2$, vrule$) 
      end
     
     
    1 
    1 
    

  • PATTERN
    Matches text_str with PATTERN's rule_str. For details see Section 6.5.4, PATTERN(str_expr1, str_expr2).
  • REQUIRED
    Returns TRUE if text_str is not null or space(s).
  • Example 6-161 Validation Rules - REQUIRED

      text$   = 'a b c d' 
      text2$  = ' '  
      vrule$  = 'required' 
      print valid(text$, vrule$) 
      print valid(text2$, vrule$)  
      end
     
     
    1 
    0 
    

  • YES/NO
    Returns TRUE if text_str consists only of the following: YES, NO, Y or N.
  • Example 6-162 Validation Rules - REQUIRED

      text$   = 'yes' 
      text2$  = 'n' 
      text3$  = 'a'    
      vrule$  = 'yes/no' 
      print valid(text$, vrule$) 
      print valid(text2$, vrule$) 
      print valid(text3$, vrule$)    
      end
     
     
    1 
    1 
    0 
    

  • VRULES
    Checks if a text_str is a legal set of validation rules, and returns TRUE (1) or FALSE (0).
  • Example 6-163 Validation Rules - VRULES

      print valid('integer', 'vrules') 
      end
            
     
    1 
    

  • PRINTMASK
    PRINTMASK checks the format of text_str and returns TRUE (1) if it is legal or FALSE (0) otherwise.
  • Example 6-164 Validation Rules - PRINTMASK

      text_str$ = '##.##' 
      vrule$    = 'printmask' 
      print valid(text_str$, vrule$) 
      end
     
     
    1     
    

  • EXPRESSION
    EXPRESSION validates a text_str and returns TRUE (1) if it is a legal Sheerpower expression or FALSE (0) otherwise.
  • Example 6-165 Validation Rules - EXPRESSION

      text_str$  = 'total = a% + 30' 
      text_str2$ = '##~-###' 
      vrule$     = 'expression' 
      print valid(text_str$, vrule$) 
      print valid(text_str2$, vrule$) 
      end
     
     
    1 
    0 
    

  • CODE
    CODE checks for VALID Sheerpower code syntax.
  • Example 6-166 Validation Rules - CODE

      a$ = "print 'hello, ' name$" 
      if  not valid(a$, 'code')  then print 'false' 
      end
      
      
    false 
    

  • MENU
    MENU validates a text_str and returns TRUE (1) if it is a legal menu description for an INPUT MENU statement, or FALSE (0) otherwise.
  • Example 6-167 Validation Rules - MENU

      text_str$ = '%multi,a,b,c' 
      vrule$    = 'menu' 
      print valid(text_str$, vrule$) 
      end
     
     
    1     
    

  • ROUTINE
    ROUTINE checks to see if the given routine name exists or not. TRUE (1) is returned if the routine name exists and FALSE (0) is returned if it does not exist.
  • Example 6-168 Validation Rules - ROUTINE

      text$  = 'do_totals' 
      text2$ = 'test_nos' 
      vrule$ = 'routine' 
      
      print valid(text$, vrule$) 
      print valid(text2$, vrule$) 
      end
     
      routine do_totals: private mytotal, desc$ 
        mytotal = 15 
        desc$ = 'Test Totals' 
        print desc$; mytotal 
      end routine
     
     
    1 
    0 
    


  • FILTER
    Filters the text_str before the validation. The following filters are allowed:
    • LTRIM$ - Removes leading spaces.
    • RTRIM$ - Removes trailing spaces.
    • TRIM$ - Removes both leading and trailing spaces.
    • UCASE$ - Converts to uppercase characters.
    • LCASE$ - Converts to lowercase characters.
    • REPLACE - If text_str contains a few 'old_t1' characters, all of them will be replaced by 'new_t1'.


              old_t1=new_t1, old_t2=new_t2, .... 
      

    • REMOVE - Removes any characters from the text_str.
    • CHANGE - Changes specified characters. For details see the CHANGE$ function.
  • Example 6-169 Validation Rules - FILTER - CHANGE

      text$    = 'abcd10' 
      vrules$  = 'filter remove "10"; letters'  
      text2$   = 'ab1cd1' 
      vrules2$ = "filter replace '1'='e';letters" 
      text3$   = ' 1234  '  
      vrules3$ = "filter trim; number" 
      
      if  valid(text$, vrules$)  then print 'true' 
      if  valid(text2$, vrules2$)  then print 'true' 
      if  valid(text3$, vrules3$)  then print 'true' 
      end  
     
     
    true 
    true 
    true 
    

  • RESTORE - Restores data to pre-filtered state for further validations. Can be used for multiple validation rules.

  • Example 6-170 Validation Rules - FILTER - RESTORE

      text$  = "123" 
      vrule$ = "filter replace '1'='a';restore; number" 
      
      if  valid(text$, vrule$)  then print 'true' 
      end
     
     
    true 
    

    6.7 File and Structure Access Functions

    The following are file and table access functions that Sheerpower performs:

    6.7.1 _CHANNEL

    _CHANNEL returns the next available channel number.

    Note on the following example:

    In the following example, the text 'This is a test.' will be printed out to a new file called 'test.txt' created in your Sheerpower folder. To view the results of this example, open 'test.txt' in SPDEV after running it.

    Example 6-171 _CHANNEL System Function

      out_ch = _channel
      open #out_ch: name 'sheerpower:test.txt', access output 
      print #out_ch: 'This is a test.' 
      close #out_ch 
      end
    

    6.7.2 _EXTRACTED

    _EXTRACTED tells how many records were extracted in the last extract.

    Example 6-172 _EXTRACTED System Function

      open table cl: name 'sheerpower:samples\client' 
      extract table cl 
        include cl(state) = 'CA' 
      end extract
      print 'Number of Californians:'; _extracted
      end
      
      
    Number of Californians: 7 
    

    6.7.3 FILEINFO$(str_expr1 [, str_expr2 [, str_expr3]])

    FILEINFO$ parses a file specification and returns either a full file specification or specific file specification fields.

    str_expr1 is the file specification to be parsed. If no file specification is given, the device and directory you are currently running from are returned.

    str_expr2 is a list of field names, separated by commas, which are to be returned. The field names are:

    CONTENTS file contents
    DEVICE drive name
    DIRECTORY directory name
    NAME file name
    TYPE type or extension name
    LOCATION device and directory names
    BACKUP_DATE last file backup date
    CREATION_DATE date file was created
    EXPIRATION_DATE file expiration date
    REVISION_DATE date file was last modified
    REVISION the number of times a given file has been revised (given that the underlying OS supports this)
    SIZE the size of the file in bytes
    ALL or "" full file specification

    str_expr3 is the default file specification. This parameter is optional.

    FILEINFO$ can be used in various formats.

    Example 6-173 FILEINFO$ Function

      print fileinfo$('x.y', 'ALL') 
      print fileinfo$('', 'ALL') 
      end
     
     
    c:\sheerpower\x.y 
    c:\sheerpower 
    

    Example 6-174 FILEINFO$ Function

      x$ = 'sheerpower:samples\client' 
      print fileinfo$(x$, 'ALL', '.ars') 
      end
     
     
    c:\sheerpower\samples\client.ars 
    

    Example 6-175 FILEINFO$ Function

      print fileinfo$('sheerpower:\samples\client', 'all', '.ars') 
      print fileinfo$('sheerpower:\samples\client', 'location') 
      print fileinfo$('sheerpower:\samples\client', 'location, name') 
      print fileinfo$('sheerpower:\samples\client.ars') 
      end
     
     
    c:\sheerpower\samples\client.ars 
    c:\sheerpower\samples\ 
    c:\sheerpower\samples\client 
    c:\sheerpower\samples\client.ars 
    


    Previous Next Contents Index