-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCH.lss
69 lines (63 loc) · 2.04 KB
/
CH.lss
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
<h1>CH - Hex to string</h1>
CH(H) will convert the sequence of hexadecimal digits into the
corresponding character string. [[CH]] is the inverse of [[HEX]].
<h2>Uses</h2>
<a href="HEX.html">HEX</a><br>
<<INCLUDES>>=
-INCLUDE 'HEX.INC'
@
<<CH>>=
-PUBLIC CH()
*
DEFINE('CH(H)C,P')
*
CH_H_ = ' ' HEX(&ALPHABET)
CH_2 CH_H_ ' ' LEN(2) . C1
+ (ANY('0123456789ABCDEF') LEN(1)) . C2 = ' ' C1 ' ' C2
+ :S(CH_2)F(CH_END)
*
CH H = REPLACE(H, &LCASE, &UCASE)
CH_3 H LEN(2) . C = :F(RETURN)
CH_H_ ' ' C @P :F(FRETURN)
P = (P - 1) / 3
&ALPHABET LEN(P) LEN(1) . C
CH = CH C :(CH_3)
*
CH_END
@
<<unit_test>>=
#!/usr/bin/bash
exec "snobol4" "-b" "$0" "$@"
-INCLUDE 'CH.INC'
&CODE = 1
IDENT(CH('414243'), 'ABC') :F(END)
&CODE = 0
END
@
<<>>=
-MODULE CH
<<INCLUDES>>
-IN72
-STITL CH
-EJECT
*
************************************************************************
* *
* ##### # # *
* # # # # *
* # # # *
* # ####### *
* # # # *
* # # # # *
* ##### # # *
* *
* CH HEX TO STRING *
* *
************************************************************************
*
* CH.lss
*
<<CH>>
*
* CE: .MSNOBOL4;
@