forked from health901/AHK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
System.ahk
71 lines (68 loc) · 905 Bytes
/
System.ahk
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
/*
;~ a=111
b=902030302010100000
;~ c=0XAD0
d:=system(B,"D","H")
c:=system(d,"h","d")
MsgBox,% d . "`n" . c . "`n" . system(b,"D","B")
*/
Bin(x)
{ ;dec-bin
while x
r:=1&x r,x>>=1
return r
}
Dec(x)
{ ;bin-dec
b:=StrLen(x),r:=0
loop,parse,x
r|=A_LoopField<<--b
return r
}
Dec_Hex(x) ;dec-hex
{
SetFormat, IntegerFast, hex
he := x
he += 0
he .= ""
SetFormat, IntegerFast, d
Return,he
}
Hex_Dec(x)
{
SetFormat, IntegerFast, d
de := x
de := de + 0
Return,de
}
system(x,InPutType="D",OutPutType="H")
{
if InputType=B
{
IF OutPutType=D
r:=Dec(x)
Else IF OutPutType=H
{
x:=Dec(x)
r:=Dec_Hex(x)
}
}
Else If InputType=D
{
IF OutPutType=B
r:=Bin(x)
Else If OutPutType=H
r:=Dec_Hex(x)
}
Else If InputType=H
{
IF OutPutType=B
{
x:=Hex_Dec(x)
r:=Bin(x)
}
Else If OutPutType=D
r:=Hex_Dec(x)
}
Return,r
}