| Previous | Contents | Index |
For all dates, use 'LENGTH nn' to control whether a 6- or 8-character date is required. |
| Example 6-158 Validation Rules - DATE DMONY |
|---|
text$ = '01-Jan-99' vrule$ = 'date dmony' print valid(text$, vrule$) end 1 |
| Example 6-159 Validation Rules - DATE DMONCY |
|---|
text$ = '01-Jan-2000' vrule$ = 'date dmoncy' print valid(text$, vrule$) end 1 |
| 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 |
| 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 |
| 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 |
| Example 6-163 Validation Rules - VRULES |
|---|
print valid('integer', 'vrules')
end
1
|
| Example 6-164 Validation Rules - PRINTMASK |
|---|
text_str$ = '##.##' vrule$ = 'printmask' print valid(text_str$, vrule$) end 1 |
| 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 |
| Example 6-166 Validation Rules - CODE |
|---|
a$ = "print 'hello, ' name$" if not valid(a$, 'code') then print 'false' end false |
| Example 6-167 Validation Rules - MENU |
|---|
text_str$ = '%multi,a,b,c' vrule$ = 'menu' print valid(text_str$, vrule$) end 1 |
| 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
|
old_t1=new_t1, old_t2=new_t2, ....
|
| 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 |
| 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 |
The following are file and table access functions that Sheerpower performs:
_CHANNEL returns the next available channel number.
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 |
_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
|
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 |