-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInteger.au3
More file actions
195 lines (117 loc) · 4.62 KB
/
Integer.au3
File metadata and controls
195 lines (117 loc) · 4.62 KB
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.16.1
Author(s): Zvend
Discord(s): zvend
Script Functions:
_Integer_Validate($nValue, Const $nMin, Const $nMax) -> Int32 | Int64 | UInt32 | UInt64
_Integer_Int8(Const $nInt) -> Int32
_Integer_Int16(Const $nInt) -> Int32
_Integer_Int32(Const $nInt) -> Int32
_Integer_Int64(Const $nInt) -> Int64
_Integer_UInt8(Const $nInt) -> UInt32
_Integer_UInt16(Const $nInt) -> UInt32
_Integer_UInt32(Const $nInt) -> UInt32
_Integer_UInt64(Const $nInt) -> UInt64
_Integer_BYTE(Const $nInt) -> UInt32
_Integer_WORD(Const $nInt) -> UInt32
_Integer_DWORD(Const $nInt) -> UInt32
_Integer_QWORD(Const $nInt) -> UInt64
_Integer_LoBYTE(Const $nInt16) -> UInt32
_Integer_HiBYTE(Const $nInt16) -> UInt32
_Integer_LoWORD(Const $nInt32) -> UInt32
_Integer_HiWORD(Const $nInt32) -> UInt32
_Integer_LoDWORD(Const $nInt64) -> UInt32
_Integer_HiDWORD(Const $nInt64) -> UInt32
Description:
Simple and very readable Integer Utils.
#ce ----------------------------------------------------------------------------
#include-once
Func _Integer_IsInRange($nValue, Const $nMin, Const $nMax) ;-> Boolean
If Not IsInt($nValue) Then
Return SetError(1, 0, 0)
EndIf
Return $nValue <= $nMax And $nValue >= $nMin
EndFunc
Func _Integer_Validate($nValue, Const $nMin, Const $nMax) ;-> Int32 | Int64 | UInt32 | UInt64
If $nValue > $nMax Then
Return $nMax
EndIf
If $nValue < $nMin Then
Return $nMin
EndIf
Return $nValue
EndFunc
Func _Integer_Int8($nInt) ;-> Int32
$nInt = _Integer_LoBYTE($nInt)
Return $nInt - 0x100 * BitShift($nInt, 7)
EndFunc
Func _Integer_Int16($nInt) ;-> Int32
$nInt = _Integer_LoWORD($nInt)
Return $nInt - 0x10000 * BitShift($nInt, 15)
EndFunc
Func _Integer_Int32(Const $nInt) ;-> Int32
Return Int($nInt, 1)
EndFunc
Func _Integer_Int64(Const $nInt) ;-> Int64
Return Int($nInt, 2)
EndFunc
Func _Integer_UInt8(Const $nInt) ;-> UInt32
Static Local $tData = DllStructCreate('BYTE;')
DllStructSetData($tData, 1, $nInt)
Return DllStructGetData($tData, 1)
EndFunc
Func _Integer_UInt16(Const $nInt) ;-> UInt32
Static Local $tData = DllStructCreate('USHORT;')
DllStructSetData($tData, 1, $nInt)
Return DllStructGetData($tData, 1)
EndFunc
Func _Integer_UInt32(Const $nInt) ;-> UInt32
Static Local $tData = DllStructCreate('UINT;')
DllStructSetData($tData, 1, $nInt)
Return DllStructGetData($tData, 1)
EndFunc
Func _Integer_UInt64(Const $nInt) ;-> UInt64
Static Local $tData = DllStructCreate('UINT64;')
DllStructSetData($tData, 1, $nInt)
Return DllStructGetData($tData, 1)
EndFunc
Func _Integer_BYTE(Const $nInt) ;-> UInt32
Return _Integer_UInt8($nInt)
EndFunc
Func _Integer_WORD(Const $nInt) ;-> UInt32
Static Local $tData = DllStructCreate('WORD;')
DllStructSetData($tData, 1, $nInt)
Return DllStructGetData($tData, 1)
EndFunc
Func _Integer_DWORD(Const $nInt) ;-> UInt32
Static Local $tData = DllStructCreate('DWORD;')
DllStructSetData($tData, 1, $nInt)
Return DllStructGetData($tData, 1)
EndFunc
Func _Integer_QWORD(Const $nInt) ;-> UInt64
Return _Integer_UInt64($nInt)
EndFunc
Func _Integer_LoBYTE(Const $nInt16) ;-> UInt32
Return BitAND($nInt16, 0xFF)
EndFunc
Func _Integer_HiBYTE(Const $nInt16) ;-> UInt32
Return BitAND(BitShift($nInt16, 8), 0xFF)
EndFunc
Func _Integer_LoWORD(Const $nInt32) ;-> UInt32
Return BitAND($nInt32, 0xFFFF)
EndFunc
Func _Integer_HiWORD(Const $nInt32) ;-> UInt32
Return BitShift($nInt32, 16)
EndFunc
Func _Integer_LoDWORD(Const $nInt64) ;-> UInt32
Static Local $tInt64 = DllStructCreate('INT64;')
Static Local $tQWord = DllStructCreate('DWORD;DWORD;',DllStructGetPtr($tInt64))
DllStructSetData($tInt64, 1, $nInt64)
Return DllStructGetData($tQWord, 1)
EndFunc
Func _Integer_HiDWORD(Const $nInt64) ;-> UInt32
Static Local $tInt64 = DllStructCreate('INT64;')
Static Local $tQWORD = DllStructCreate('DWORD;DWORD;', DllStructGetPtr($tInt64))
DllStructSetData($tInt64, 1, $nInt64)
Return DllStructGetData($tQWORD, 2)
EndFunc