Mad Libs: Difference between revisions

m
→‎{{header|REXX}}: typos (mostly)
(→‎{{header|REXX}}: added the REXX language. -- ~~~~)
m (→‎{{header|REXX}}: typos (mostly))
Line 589:
 
=={{header|REXX}}==
<lang rexx>/*REXX program to prompt user for template subsitutionssubstitutions within a story. */
@=; @.=; !.=0; #=0; old.= /*assign some defaults. */
parse arg iFID . /*allow useuser to specify input fileinputfile*/
if iFID=='' then iFID="MAD_LIBS.TXT" /*Not specified? Then use default*/
 
Line 601:
recs=recs-1 /*adjust for E-O-F or blank line.*/
 
do k=1 /*look for subsitutionstemplates in text. */
parse var @ '<' ? '>' @ /*scan for <xxx> stuff in text.*/
if ?='' then leave /*if no XXX, then we're done. */
Line 610:
parse pull ans; if ans\='' then leave
end /*forever*/
#=#+1 /*bump the subsitute nametemplate counter */
old.#='<'?">"; new.#=ans /*assign "old" name, "new" name. */
end /*k*/
Line 617:
 
do m=1 for recs /*display the text, line for line*/
do n=1 for # /*perform the subsitutionssubstitutions in txt */
@.m=changestr(old.n, @.m, new.n)
end /*n*/
say @.m /*display (new) subsitutedsubstituted text. */
end /*m*/
 
2,300

edits