Rosetta Code/Fix code tags: Difference between revisions

Content added Content deleted
m (→‎{{header|REXX}}: re-aligned first comment, added whitespace. -- ~~~~)
(→‎{{header|REXX}}: changed comments and indentation, added a comment. -- ~~~~)
Line 347: Line 347:


=={{header|REXX}}==
=={{header|REXX}}==

Some older REXXes don't have the '''changestr''' bif, so one is include here.
<lang rexx>/*REXX program fixes (changes) depreciated code tags with newer tags.*/
<lang rexx>/*REXX program fixes (changes) depreciated code tags with newer tags.*/
@ = '<' /*ensure RC won't get confused. */
old. = /*define a default value for OLD.*/
old.1 = @'%s>' ; new.1 = @'lang %s>'
old.2 = @'/%s>' ; new.2 = @'/lang>'
old.3 = @'code %s>' ; new.3 = @'lang %s>'
old.4 = @'/code>' ; new.4 = @'/lang>'


old.='' /*define a default value for OLD.*/
ifid = 'Wikisource.txt' /* input file identifier. */
ofid = 'converted.txt' /*output " " */


do while lines(ifid)\==0 /*keep trunkin' until done. */
old.1='<%s>' ; new.1='<lang %s>'
old.2='</%s>' ; new.2='</lang>'
old.3='<code %s>' ; new.3='<lang %s>'
old.4='</code>' ; new.4='</lang>'

ifid='Wikisource.txt' /* input file identifier. */
ofid='converted.txt' /*output " " */

do while lines(ifid)\==0 /*keep trunkin' until done. */
_=linein(ifid) /*read a record from the input. */
_=linein(ifid) /*read a record from the input. */


do k=1 while old.j\=='' /*change old --> new until done. */
do k=1 while old.j\=='' /*change old --> new until done. */
_=changestr(new.k,_,old.k) /*let REXX do the heavy lifting. */
_=changestr(new.k,_,old.k) /*let REXX do the heavy lifting. */
end
end /*k*/


call lineout ofid,_ /*write out the re-formatted rec.*/
call lineout ofid,_ /*write out the re-formatted rec.*/
end
end /*while lines(ifid)\==0*/
exit /*stick a fork in it, we're done.*/
/*stick a fork in it, we're done.*/</lang>
Some older REXXes don't have the '''changestr''' bif, so one is include below.

/*───────────────────────────CHANGESTR subroutine───────────────────────*/
<lang rexx>/*───────────────────────────CHANGESTR subroutine───────────────────────*/
changestr: procedure; parse arg o,h,n; r=; w=length(o); if w==0 then return n||h
changestr: procedure; parse arg o,h,n; r=; w=length(o); if w==0 then return n||h
do forever; parse var h y (o) _ +(w) h; if _=='' then return r||y; r=r||y||n; end</lang>
do forever; parse var h y (o) _ +(w) h; if _=='' then return r||y; r=r||y||n; end</lang>