forked from DonovanChan/fmfunctions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVarInvalidLoop.calc
79 lines (66 loc) · 1.97 KB
/
VarInvalidLoop.calc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
Let ( [
_line = Trim ( GetValue ( listOfVariableNames ; rep ) ) ;
_line_count = ValueCount ( listOfVariableNames ) ;
_is_multiple = PatternCount ( _line ; "|" ) ; // Multiple vars (OR option)
_value =
Case (
//-- Multiple variables (OR option)
_is_multiple ;
VarInvalidLoop ( Substitute ( _line ; "|" ; ¶ ) ; 0 ; 1 ; "" ) ;
//-- Singular variable
Left ( _line ; 1 ) = "$" ;
Evaluate ( _line ) ;
//-- Text string
_line
) ;
_result =
Case (
//-- Multiple vars failed
_is_multiple ;
_value ;
//Substitute ( _value ; ¶ ; " | " ) ;
//-- Single var failed
_value = "?" or IsEmpty ( _value ) ;
_line
) ;
_result_full = List ( previousResults ; _result )
] ;
Case (
rep ≥ _line_count ;
Case (
//-- All vars required
GetAsBoolean ( requireAll ) ;
_result_full ;
//-- Only return result if all vars failed
ValueCount ( _result_full ) ≥ _line_count ;
Substitute ( _result_full ; ¶ ; " | " )
) ;
VarInvalidLoop (
listOfVariableNames ;
requireAll ;
rep + 1 ;
_result_full
)
)
)
/* —————————————————————————————— //
NAME:
VarInvalidLoop ( listOfVariableNames ; requireAll ; rep ; previousResults )
PURPOSE:
Returns list of variables with invalid data.
USAGE:
Supply variable names as text strings (in quotes).
Each line of the parameter must evaluate to a valid value.
To require one of several vars, place them on one line separated by "|".
EXAMPLES:
Where $_table = "CONTACT", $_id_contact = "?", $_id_student = ""
VarInvalid ( "$_table" ) = ""
VarInvalid (
List ( "$_table" ; "$_id_contact | $_id_student" )
) = "$_id_contact | $_id_student"
VarInvalid (
"$_table | $_id_student" )
) = ""
HISTORY:
Created: 2010-Oct-28 08h04 PST — Donovan Chandler
*/