Odd word problem: Difference between revisions

m
→‎{{header|REXX}}: simplified the program, changed some comments.
m (→‎{{header|REXX}}: split compound statements, used a template for the output section, simplified the code.)
m (→‎{{header|REXX}}: simplified the program, changed some comments.)
Line 2,281:
do until x==. /* [↓] perform until reaching a period*/
do until \datatype(x, 'M') /* [↓] " " punctuation found*/
call readCharrChar /*read a single character. */
call writeCharwChar /*write " " " */
end /*until \data···*/ /* [↑] read/write until punctuation. */
if x==. then leave /*is this the end─of─sentence (period)?*/
call readLetters; punct= # /*save the location of the punctuation.*/
do j=#-1 by -1 /*read some characters backwards. */
call readCharrChar j /*read previous word (backwards). */
if \datatype(x, 'M') then leave /*Found punctuation? Then leave J. */
call writeCharwChar /*write a character (which is a letter)*/
end /*j*/ /* [↑] perform for "even" words. */
call readLettersrLett /*read a letter (and maybe punctuation)*/
call writeCharwChar; #= punct /*write a char; punctuation location. */
end /*until x==.*/
end /*case*/ /* [↑] process both of the input files*/
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
readLettersrLett: do until \datatype(x, 'M'); call readCharrChar; end; return
writeCharwChar: call charout , x /*console*/; call charout oFID, x /*file*/; return
/*──────────────────────────────────────────────────────────────────────────────────────*/
readCharrChar: if arg(1)==''0 then do; x= charin(iFID); #= #+1; end /*read next char*/
else x= charin(iFID, arg(1) ) ; /* " specific " */ return</lang>
return</lang>
{{out|output|text=&nbsp; when using the two (default) input files which contain:}}
:* &nbsp; input file &nbsp; '''ODDWORD.IN1''' &nbsp; ───► &nbsp; <tt> what,is,the;meaning,of:life. </tt>