ABC words: Difference between revisions
Content added Content deleted
m (added whitespace.) |
m (→{{header|REXX}}: changed a comment, changed wording in the REXX section header.) |
||
Line 421: | Line 421: | ||
=={{header|REXX}}== |
=={{header|REXX}}== |
||
This REXX version doesn't care what order the words in the dictionary are in, nor does it care what |
This REXX version doesn't care what order the words in the dictionary are in, nor does it care what |
||
<br>case (lower/upper/mixed) the words are in, the search for the |
<br>case (lower/upper/mixed) the words are in, the search for the ''ABC'' words is ''caseless''. |
||
It also allows the (ABC) characters to be specified on the command line (CL) as well as the dictionary file identifier. |
It also allows the (ABC) characters to be specified on the command line (CL) as well as the dictionary file identifier. |
||
<lang rexx>/*REXX pgm finds "ABC" words (within an identified dict.) where ABC are found in order.*/ |
<lang rexx>/*REXX pgm finds "ABC" words (within an identified dict.) where ABC are found in order.*/ |
||
parse arg chrs iFID . /*obtain optional arguments from the CL*/ |
parse arg chrs iFID . /*obtain optional arguments from the CL*/ |
||
if chrs=='' | chrs=="," then chrs= 'abc' /* |
if chrs=='' | chrs=="," then chrs= 'abc' /*Not specified? Then use the default.*/ |
||
if iFID=='' | iFID=="," then iFID='unixdict.txt' /* " " " " " " */ |
if iFID=='' | iFID=="," then iFID='unixdict.txt' /* " " " " " " */ |
||
@.= /*default value of any dictionary word.*/ |
@.= /*default value of any dictionary word.*/ |
||
do #=1 while lines(iFID)\==0 /*read each word in the file (word=X).*/ |
do #=1 while lines(iFID)\==0 /*read each word in the file (word=X).*/ |
||
x= strip( linein( iFID) ) /*pick off a word from the input line. */ |
x= strip( linein( iFID) ) /*pick off a word from the input line. */ |
||
$.#= x; upper x; |
$.#= x; upper x; @.#= x /*save: original case. */ |
||
end /*#*/ /* [↑] semaphore name is uppercased. */ |
end /*#*/ /* [↑] semaphore name is uppercased. */ |
||
say copies('─', 30) # "words in the dictionary file: " iFID |
say copies('─', 30) # "words in the dictionary file: " iFID |
||
Line 438: | Line 438: | ||
ABCs= 0 /*count of the "ABC" words found. */ |
ABCs= 0 /*count of the "ABC" words found. */ |
||
do j=1 for #-1 /*process all the words that were found*/ |
do j=1 for #-1 /*process all the words that were found*/ |
||
if verify(chrsU, |
if verify(chrsU, @.j)>0 then iterate /*All characters found? No, then skip.*/ |
||
p= 0 /*initialize the position location. */ |
p= 0 /*initialize the position location. */ |
||
do k=1 for L /*examine each letter of the ABC charts*/ |
do k=1 for L /*examine each letter of the ABC charts*/ |
||
_= pos( substr(chrsU, k, 1), |
_= pos( substr(chrsU, k, 1), @.j) /*find the position of the Kth letter.*/ |
||
if _<p then iterate j /*Less than the previous? Then skip it*/ |
if _<p then iterate j /*Less than the previous? Then skip it*/ |
||
p= _ /*save the position of the last letter.*/ |
p= _ /*save the position of the last letter.*/ |