-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathComparableStringProcedure.yml
67 lines (59 loc) · 2.16 KB
/
ComparableStringProcedure.yml
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
################################################################################
#
# TypeMatch Procedure script
#
# This is used in the pack edit command to check if the user supplys the
# correct value type
#
# Use this to compare 2 values. Check if they are one of NUMBER, DECIMAL,
# DURATION, BOOLEAN, or any other STRING.
#
# usage:
# - define YourValue "Some string"
# - define ComparedToValue "5.2"
# - define TypeMatch '<proc[TypeMatch].context[%YourValue%|%ComparedToValue%]>'
# - if <def[TypeMatch].get[1]> {
# - narrate "YourValue and ComparedToValue are both <def[TypeMatch].get[2]> strings."
# }
# else {
# - narrate "YourValue and ComparedToValue Do not Match!"
# - narrate "YourValue Type<&co> <def[TypeMatch].get[2]>"
# - narrate "ComparedToValue Type<&co> <def[TypeMatch].get[3]>"
# }
#
TypeMatch:
type: procedure
debug: false
definitions: YourValue|ComparedToValue
script:
# Get the comparable type for your value
- if <def[YourValue].is[MATCHES].to[number]> {
- define YourValueType 'number'
}
else if <def[YourValue].is[MATCHES].to[decimal]> {
- define YourValueType 'decimal'
}
else if <def[YourValue].is[MATCHES].to[duration]> {
- define YourValueType 'duration'
}
else if <def[YourValue].is[MATCHES].to[boolean]> {
- define YourValueType 'boolean'
}
else define YourValueType 'STRING'
# Get the comparable type of the string you're comparing against
- if <def[ComparedToValue].is[MATCHES].to[number]> {
- define CompareValueType 'number'
}
else if <def[ComparedToValue].is[MATCHES].to[decimal]> {
- define CompareValueType 'decimal'
}
else if <def[ComparedToValue].is[MATCHES].to[duration]> {
- define CompareValueType 'duration'
}
else if <def[ComparedToValue].is[MATCHES].to[boolean]> {
- define CompareValueType 'boolean'
}
else define CompareValueType 'STRING'
# Return determination
- if <def[YourValueType].is[==].to[%CompareValueType%]> determine "li@true|%CompareValueType%"
else determine "li@false|%YourValueType%|%CompareValueType%"