-
Notifications
You must be signed in to change notification settings - Fork 12
/
lib-strings.muf
53 lines (48 loc) · 1.13 KB
/
lib-strings.muf
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
@program lib-strings
1 99999 d
1 i
( ***** Misc String routines -- STR *****
sms [ str -- str' ] strips out mult. internal spaces
fillfield [ str char width -- padstr ] return padding string to width chars
STRparse [ str -- str1 str2 str3 ] " #X Y y = Z" -> "X" "Y y" " Z"
)
$doccmd @list __PROG__=!@1-5
: sms ( str -- str')
begin
dup " " instr while
" " " " subst
repeat
;
: fillfield (str padchar fieldwidth -- padstr)
rot ansi_strlen - dup 1 < if pop pop "" exit then
swap over begin swap dup strcat swap 2 / dup not until pop
swap ansi_strcut pop
;
: STRparse ( s -- s1 s2 s3 )
(
Before: " #option tom dick harry = message "
After: "option" "tom dick harry" " message "
)
"=" rsplit swap
striplead dup "#" 1 strncmp not if
1 strcut swap pop
" " split
else
"" swap
then
strip sms rot
;
public sms $libdef sms
public fillfield $libdef fillfield
public STRparse $libdef STRparse
.
c
q
@register lib-strings=lib/strings
@register #me lib-strings=tmp/prog1
@set $tmp/prog1=2
@set $tmp/prog1=L
@set $tmp/prog1=S
@set $tmp/prog1=H
@set $tmp/prog1=V
@register #me =tmp