aUCBLogo Demos and Tests / scalehtmlpages
be scalehtmlpages
scale=100/1188
scalepx=100/25
clearText
foreach (Files [*.*] wxDIR_DIRS)
[ scaledir ?
]
be scaledir d
cd d
foreach (Files [*.html])
[ pr ?
outf="tmp.html
scalefile ? outf
eraseFile ?
renameFile outf ?
]
cd "..
end
be scalefile inf outf
openRead inf
setReader inf
openWrite outf
setWriter outf
while [not eof?]
[ ::w=readword
i=1
while [i < (count w)]
[ len=count w
if w.i ==":
[ i=i+1
i0=i
while [(digit? w.i) and2 (i < len)]
[ i=i+1
]
if (not alpha? w.i) and2 w.i != "%
[ i=i-1
s=Items i0 i w
if (count s) > 0
[ s=Int s
s2=(Word (Int 10*s*scale)/10 "%)
l=Items 1 i0-1 w
ifelse i < len
[ r=Items i+1 len w
w=(Word l s2 r)
][ w=(Word l s2)
]
]
]
]
i=i+1
]
i=1
while [i < (count w)]
[ len=count w
if w.i ==""
[ i=i+1
i0=i
while [(digit? w.i) and2 (i < len)]
[ i=i+1
]
if (not alpha? w.i) and2 w.i != "%
[ i=i-1
s=Items i0 i w
if (count s) > 0
[ s=Int s
s2=(Word (Int 10*s*scale)/10 "%)
l=Items 1 i0-1 w
ifelse i < len
[ r=Items i+1 len w
w=(Word l s2 r)
][ w=(Word l s2)
]
]
]
]
i=i+1
]
i=1
while [i < (count w)]
[ len=count w
if w.i ==":
[ i=i+1
i0=i
while [(digit? w.i) and2 (i < len)]
[ i=i+1
]
if w.i == "p
[ i=i-1
s=Items i0 i w
if (count s) > 0
[ s=Int s
s2=(Word (Int 10*s*scalepx)/10 "%)
l=Items 1 i0-1 w
ifelse i < len
[ r=Items i+3 len w
w=(Word l s2 r)
][ w=(Word l s2)
]
]
]
]
i=i+1
]
print w
]
setReader []
setWriter []
close inf
close outf
end
end