2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -1,36 +1,35 @@
|
|||
/*REXX program prompts user for a template substitutions within a story.*/
|
||||
@.=; !.=0; #=0; @= /*assign some defaults. */
|
||||
parse arg iFID . /*allow use to specify input file*/
|
||||
if iFID=='' then iFID="MAD_LIBS.TXT" /*Not specified? Use a default.*/
|
||||
/*REXX program prompts the user for a template substitutions within a story (MAD LIBS).*/
|
||||
parse arg iFID . /*allow user to specify the input file.*/
|
||||
if iFID=='' | iFID=="," then iFID="MAD_LIBS.TXT" /*Not specified? Then use the default.*/
|
||||
@.= /*assign defaults to some variables. */
|
||||
$=; do recs=1 while lines(iFID)\==0 /*read the input file until it's done. */
|
||||
@.recs=linein(iFID); $=$ @.recs /*read a record; and append it to @ */
|
||||
if @.recs='' then leave /*Read a blank line? Then we're done.*/
|
||||
end /*recs*/
|
||||
recs=recs-1 /*adjust for a E─O─F or a blank line.*/
|
||||
pm= 'please enter a word or phrase to replace: ' /*this is part of the Prompt Message. */
|
||||
!.=0 /*placeholder for phrases in MAD LIBS.*/
|
||||
#=0; do forever /*look for templates within the text. */
|
||||
parse var $ '<' ? ">" $ /*scan for <ααα> stuff in the text.*/
|
||||
if ?='' then leave /*No ααα ? Then we're all finished.*/
|
||||
if !.? then iterate /*Already asked? Then keep scanning. */
|
||||
!.?=1 /*mark this ααα as being "found". */
|
||||
do until ans\='' /*prompt user for a replacement. */
|
||||
say '───────────' pm ? /*prompt the user with a prompt message*/
|
||||
parse pull ans /*PULL obtains the text from console. */
|
||||
end /*forever*/
|
||||
#=#+1 /*bump the template counter. */
|
||||
old.# = '<'?">"; new.# = ans /*assign the "old" name and "new" name.*/
|
||||
end /*forever*/
|
||||
say /*display a blank line for a separator.*/
|
||||
say; say copies('═', 79) /*display a blank line and a fence. */
|
||||
|
||||
do recs=1 while lines(iFID)\==0 /*read the input file 'til done. */
|
||||
@.recs=linein(iFID); @=@ @.recs /*read a record, append it to @ */
|
||||
if @.recs='' then leave /*Read a blank line? We're done.*/
|
||||
end /*recs*/
|
||||
do m=1 for recs /*display the text, line for line. */
|
||||
do n=1 for # /*perform substitutions in the text. */
|
||||
@.m=changestr(old.n, @.m, new.n) /*maybe replace text in @.m haystack.*/
|
||||
end /*n*/
|
||||
say @.m /*display the (new) substituted text. */
|
||||
end /*m*/
|
||||
|
||||
recs=recs-1 /*adjust for E─O─F or blank line.*/
|
||||
|
||||
do forever /*look for templates in the text.*/
|
||||
parse var @ '<' ? '>' @ /*scan for <ααα> stuff in text.*/
|
||||
if ?='' then leave /*if no ααα, then we're done. */
|
||||
if !.? then iterate /*already asked? Keep scanning.*/
|
||||
!.?=1 /*mark this ααα as "found". */
|
||||
do forever /*prompt user for a replacement. */
|
||||
say '─────────── please enter a word or phrase to replace: ' ?
|
||||
parse pull ans; if ans\='' then leave
|
||||
end /*forever*/
|
||||
#=#+1 /*bump the template counter. */
|
||||
old.# = '<'?">"; new.# = ans /*assign "old" name & "new" name.*/
|
||||
end /*forever*/
|
||||
|
||||
say; say copies('═',79) /*display a blank and a fence. */
|
||||
|
||||
do m=1 for recs /*display the text, line for line*/
|
||||
do n=1 for # /*perform substitutions in text. */
|
||||
@.m = changestr(old.n, @.m, new.n)
|
||||
end /*n*/
|
||||
say @.m /*display (new) substituted text.*/
|
||||
end /*m*/
|
||||
|
||||
say copies('═',79) /*display a final (output) fence.*/
|
||||
/*stick a fork in it, we're done.*/
|
||||
say copies('═', 79) /*display a final (output) fence. */
|
||||
say /*stick a fork in it, we're all done. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue