-
Notifications
You must be signed in to change notification settings - Fork 12
/
lib-mesg.muf
167 lines (134 loc) · 3.92 KB
/
lib-mesg.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
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
@program lib-mesg
1 99999 d
1 i
( **** Message Object -- MSG- ****
A message is a set of elements with a count and an information string,
stored in properties.
base is a string containing the name of the message.
itemnum is the number of an item within a message.
itemstr is a single item's string.
infostr is the messages information string.
{strrange} is a string range that is all the elements of the message
with an integer count.
MSG-destroy [base dbref -- ]
Clears and removes the message.
MSG-create [{strrange} infostr base dbref -- ]
Create a new message with the given items and info string on
the given object with the given name.
MSG-count [base dbref -- count]
Returns how many items are in the given message.
MSG-info [base dbref -- infostr]
Returns the information string for the given message.
MSG-setinfo [infostr base dbref -- ]
Sets the information string on an existing message.
MSG-message [base dbref -- {strrange}]
Returns the items of a message as a range on the stack.
MSG-item [itemnum base dbref -- itemstr]
Returns the given message item from the message.
MSG-setitem [itemstr itemnum base dbref -- ]
Sets the specified message item to the given string.
MSG-insitem [itemstr itemnum base dbref -- ]
Inserts a new message item into the message at the given point.
MSG-append [itemstr base dbref -- ]
Appends a message item to the given message.
MSG-delitem [itemnum base dbref -- ]
Deletes the specified message item from the given message.
Message data type:
Base# Count of Message Items
Base#/X Message Items
Base#/i Info String
)
$doccmd @list __PROG__=!@1-50
$include $lib/lmgr
$include $lib/props
: MSG-destroy (base dbref -- )
over over swap "#/i" strcat remove_prop
LMGR-deletelist
;
: MSG-setinfo (infostr base dbref -- )
swap
"#" strcat
"/i" strcat rot setpropstr
;
: MSG-create ({strrange} infostr base dbref -- )
over over MSG-destroy
rot 3 pick 3 pick MSG-setinfo
({strrange} base dbref)
1 rot rot
LMGR-putrange
;
: MSG-count (base dbref -- count)
LMGR-getcount
;
: MSG-message (base dbref -- {strrange})
LMGR-getlist
;
: safeclear (d s -- )
over over propdir? if
over over "" -1 addprop
"" 0 addprop
else
remove_prop
then
;
: MSG-clearoldinfo (base dbref -- )
swap
over over
"#/i" strcat safeclear
;
: MSG-oldinfo (base dbref -- infostr)
swap "/i" strcat getpropstr
;
: MSG-newinfo (base dbref -- infostr)
swap "#/i" strcat getpropstr
;
: convert-info (base dbref value -- )
3 pick 3 pick MSG-clearoldinfo
rot rot MSG-setinfo
;
: MSG-info (base dbref -- infostr)
over over MSG-newinfo
dup if rot rot pop pop exit then
pop over over MSG-oldinfo
dup if dup -4 rotate convert-info exit then
pop pop pop ""
;
: MSG-item (itemnum base dbref -- itemstr)
LMGR-getelem
;
: MSG-setitem (itemstr itemnum base dbref -- )
LMGR-putelem
;
: MSG-insitem (itemstr itemnum base dbref -- )
1 -4 rotate LMGR-insertrange
;
: MSG-append (itemstr base dbref -- )
over over LMGR-getcount 1 +
rot rot LMGR-putelem
;
: MSG-delitem (itemnum base dbref -- )
1 -4 rotate LMGR-deleterange
;
public MSG-append $libdef MSG-append
public MSG-count $libdef MSG-count
public MSG-create $libdef MSG-create
public MSG-delitem $libdef MSG-delitem
public MSG-destroy $libdef MSG-destroy
public MSG-info $libdef MSG-info
public MSG-insitem $libdef MSG-insitem
public MSG-item $libdef MSG-item
public MSG-message $libdef MSG-message
public MSG-setinfo $libdef MSG-setinfo
public MSG-setitem $libdef MSG-setitem
.
c
q
@register lib-mesg=lib/mesg
@register #me lib-mesg=tmp/prog1
@set $tmp/prog1=3
@set $tmp/prog1=B
@set $tmp/prog1=H
@set $tmp/prog1=L
@set $tmp/prog1=S
@set $tmp/prog1=V
@register #me =tmp