XML/Output: Difference between revisions
Content added Content deleted
(Added XPL0) |
(→{{header|REXX}}: included a CHANGESTR subroutine (function) as a separate entity. -- ~~~~) |
||
Line 1,486: | Line 1,486: | ||
=={{header|REXX}}== |
=={{header|REXX}}== |
||
REXX doesn't have any functions to handle XML entities, an abbreviated version is included here. |
REXX doesn't have any functions to handle XML entities, an abbreviated version is included here. |
||
⚫ | |||
<lang rexx>/*REXX program to create a list of character names & remarks. */ |
<lang rexx>/*REXX program to create a list of character names & remarks. */ |
||
charname.= |
charname.= |
||
Line 1,604: | Line 1,603: | ||
if a then x=xml_(?,"amp") /*if we had an ampersand, translate it now.*/ |
if a then x=xml_(?,"amp") /*if we had an ampersand, translate it now.*/ |
||
if b then x=xml_(??,"semi") /*if we had a semicolon, translate it now.*/ |
if b then x=xml_(??,"semi") /*if we had a semicolon, translate it now.*/ |
||
return x |
return x</lang> |
||
⚫ | |||
/*───────────────────────────CHANGESTR subroutine───────────────────────*/ |
|||
<lang rexx>/*╔══════════════════════════════╗ CHANGESTR ╔═════════════════════════╗ |
|||
⚫ | |||
╔═╩══════════════════════════════╝ function ╚═════════════════════════╩═╗ |
|||
do forever; parse var h y (o) _ +(w) h; if _=='' then return r||y; r=r||y||n; end</lang> |
|||
║ new string to be used──────────┐ ┌─────limit of # changes (times)║ |
|||
║ original string (haystack)────────┐ │ │ [default: ≈ one billian]║ |
|||
║ old string to be changed───┐ │ │ │ ┌───begin at this occurance #.║ |
|||
║ {O, H, and N can be null.} │ │ │ │ │ [default: 1st occurrance]║ |
|||
╚═╦════════════════════════════╗ │ │ │ │ │ ╔═══════════════════════╦═╝ |
|||
╚════════════════════════════╝ ↓ ↓ ↓ ↓ ↓ ╚═══════════════════════╝*/ |
|||
⚫ | |||
$='' /*$: the returned string.*/ |
|||
t=word(t 999999999 , 1) /*maybe use the default? */ |
|||
b=word(b 1 , 1) /* " " " " */ |
|||
w=length(o) /*length of OLD string.*/ |
|||
if w==0 & t\=0 then return n || h /*changing a null char ? */ |
|||
#=0 /*# of changed occurances*/ |
|||
do j=1 until # >= t /*keep changing, T times.*/ |
|||
parse var h y (o) _ +(w) h /*parse the string ... */ |
|||
if _=='' then return $ || y /*no more left, return. */ |
|||
if j<b then $=$ || y || o /*didn't meet begin at ? */ |
|||
else do |
|||
$=$ || y || n /*build new STR from S. */ |
|||
#=#+1 /*bump occurance number. */ |
|||
end |
|||
end /*j*/ |
|||
/*Most REXX BIFs only ···*/ |
|||
return $ || h /* support three options.*/</lang> |
|||
'''output''' |
'''output''' |
||
<pre style="overflow:scroll"> |
<pre style="overflow:scroll"> |