31 lines
817 B
Text
31 lines
817 B
Text
$ include "seed7_05.s7i";
|
|
|
|
const proc: main is func
|
|
local
|
|
var string: story is "";
|
|
var string: line is "";
|
|
var integer: pos1 is 0;
|
|
var integer: pos2 is 1;
|
|
var string: field is "";
|
|
begin
|
|
writeln("Enter a story template, terminated by an empty line:");
|
|
repeat
|
|
readln(line);
|
|
if line <> "" then
|
|
story &:= line & "\n";
|
|
end if;
|
|
until line = "";
|
|
pos1 := pos(story, '<');
|
|
while pos1 <> 0 and pos2 <> 0 do
|
|
pos2 := pos(story, '>', pos1);
|
|
if pos2 <> 0 then
|
|
field := story[pos1 .. pos2];
|
|
write("Enter a value for " <& field <& ": ");
|
|
story := replace(story, field, getln(IN));
|
|
pos1 := pos(story, '<', pos1);
|
|
end if;
|
|
end while;
|
|
writeln;
|
|
writeln("The story becomes:");
|
|
write(story);
|
|
end func;
|