-
Notifications
You must be signed in to change notification settings - Fork 2
/
BasicTernary.pbi
134 lines (114 loc) · 2.69 KB
/
BasicTernary.pbi
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
;{- Code Header
; ==- Basic Info -================================
; Name: BasicTernary.pbi
; Version: 1.0.0
; Author: Herwin Bozet
; Create date: 22 October 2017, 04:37:04
;
; Description: Gives a procedure that acts like the ternary operator in other languages.
;
; ==- Compatibility -=============================
; Compiler version: PureBasic 5.62-5.70 (x86/x64)
; Operating system: Windows (Other platforms untested)
;
; ==- Links & License -===========================
; Github: https://github.com/aziascreations/PB-Utils
; Doc.: https://github.com/aziascreations/PB-Utils/Documentation/BasicTernary
; License: WTFPL
;
;}
;- Notes
;{
; The inside of the procedures could be simplified by removing the else part since it is kinda useless.
;}
;- Procedures
;{
Procedure.a IfA(Condition.b, TrueValue.a, FalseValue.a)
If Condition
ProcedureReturn TrueValue
Else
ProcedureReturn FalseValue
EndIf
EndProcedure
Procedure.b IfB(Condition.b, TrueValue.b, FalseValue.b)
If Condition
ProcedureReturn TrueValue
Else
ProcedureReturn FalseValue
EndIf
EndProcedure
Procedure.c IfC(Condition.b, TrueValue.c, FalseValue.c)
If Condition
ProcedureReturn TrueValue
Else
ProcedureReturn FalseValue
EndIf
EndProcedure
Procedure.d IfD(Condition.b, TrueValue.d, FalseValue.d)
If Condition
ProcedureReturn TrueValue
Else
ProcedureReturn FalseValue
EndIf
EndProcedure
Procedure.f IfF(Condition.b, TrueValue.f, FalseValue.f)
If Condition
ProcedureReturn TrueValue
Else
ProcedureReturn FalseValue
EndIf
EndProcedure
Procedure.i IfI(Condition.b, TrueValue.i, FalseValue.i)
If Condition
ProcedureReturn TrueValue
Else
ProcedureReturn FalseValue
EndIf
EndProcedure
Procedure.l IfL(Condition.b, TrueValue.l, FalseValue.l)
If Condition
ProcedureReturn TrueValue
Else
ProcedureReturn FalseValue
EndIf
EndProcedure
Procedure IfP(Condition.b, *TrueValue, *FalseValue)
If Condition
ProcedureReturn TrueValue
Else
ProcedureReturn FalseValue
EndIf
EndProcedure
Procedure.q IfQ(Condition.b, TrueValue.q, FalseValue.q)
If Condition
ProcedureReturn TrueValue
Else
ProcedureReturn FalseValue
EndIf
EndProcedure
Procedure.s IfS(Condition.b, TrueValue.s, FalseValue.s)
If Condition
ProcedureReturn TrueValue
Else
ProcedureReturn FalseValue
EndIf
EndProcedure
Procedure.u IfU(Condition.b, TrueValue.u, FalseValue.u)
If Condition
ProcedureReturn TrueValue
Else
ProcedureReturn FalseValue
EndIf
EndProcedure
Procedure.w IfW(Condition.b, TrueValue.w, FalseValue.w)
If Condition
ProcedureReturn TrueValue
Else
ProcedureReturn FalseValue
EndIf
EndProcedure
;}
; IDE Options = PureBasic 5.70 LTS (Windows - x64)
; CursorPosition = 22
; Folding = FA5
; EnableXP