58 lines
996 B
Text
58 lines
996 B
Text
global name$[] out$[] .
|
|
func n2id n$ .
|
|
for id to len name$[] : if name$[id] = n$ : return id
|
|
name$[] &= n$
|
|
return id
|
|
.
|
|
print "Enter a story template, terminated by an empty line:"
|
|
repeat
|
|
s$ = input
|
|
print s$
|
|
until s$ = ""
|
|
for c$ in strchars s$
|
|
if c$ = "<"
|
|
in = 1
|
|
w$ = ""
|
|
elif c$ = ">"
|
|
in = 0
|
|
id = n2id w$
|
|
out$ &= "<" & id & ">"
|
|
elif in = 1
|
|
w$ &= c$
|
|
else
|
|
out$ &= c$
|
|
.
|
|
.
|
|
out$[] &= out$
|
|
out$ = ""
|
|
.
|
|
for i to len name$[]
|
|
write name$[i] & ": "
|
|
name$[i] = input
|
|
print name$[i]
|
|
.
|
|
print ""
|
|
for s$ in out$[]
|
|
for c$ in strchars s$
|
|
if c$ = "<"
|
|
in = 1
|
|
w$ = ""
|
|
elif c$ = ">"
|
|
in = 0
|
|
write name$[number w$]
|
|
elif in = 1
|
|
w$ &= c$
|
|
else
|
|
write c$
|
|
.
|
|
.
|
|
print ""
|
|
.
|
|
#
|
|
input_data
|
|
<name> went for a walk in the park. <he or she>
|
|
found a <noun>. <name> decided to take it home.
|
|
|
|
Monica
|
|
She
|
|
cockerel
|