| Previous | Contents | Index |
For all dates, use 'LENGTH nn' to control whether a 6- or 8-character date is required. |
| Example 6-136 Validation rules - DATE DMONY |
|---|
text$ = '01-Jan-99' vrule$ = 'date dmony' print valid(text$, vrule$) end 1 |
| Example 6-137 Validation rules - DATE DMONCY |
|---|
text$ = '01-Jan-2000' vrule$ = 'date dmoncy' print valid(text$, vrule$) end 1 |
| Example 6-138 Validation rules - FULLTIME |
|---|
text$ = '20000122 010101' text2$ = '990122 010101' vrule$ = 'fulltime' print valid(text$, vrule$) print valid(text2$, vrule$) end 1 1 |
| Example 6-139 Validation rules - REQUIRED |
|---|
text$ = 'a b c d' text2$ = ' ' vrule$ = 'required' print valid(text$, vrule$) print valid(text2$, vrule$) end 1 0 |
| Example 6-140 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-141 Validation rules - VRULES |
|---|
print valid('integer', 'vrules')
end
1
|
| Example 6-142 Validation rules - PRINTMASK |
|---|
text_str$ = '##.##' vrule$ = 'printmask' print valid(text_str$, vrule$) end 1 |
| Example 6-143 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-144 Validation rules - CODE |
|---|
a$ = "print 'hello, ' name$" if not valid(a$, 'code') then print 'false' end false |
| Example 6-145 Validation rules - MENU |
|---|
text_str$ = '%multi,a,b,c' vrule$ = 'menu' print valid(text_str$, vrule$) end 1 |
| Example 6-146 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-147 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-148 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 structure 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-149 _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-150 _EXTRACTED system function |
|---|
open structure cl: name 'sheerpower:samples\client'
extract structure cl
include cl(state) = 'CA'
end extract
print 'Number of Californians:'; _extracted
end
Number of Californians: 7
|
| Previous | Next | Contents | Index |