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 [< (count w)]
         
[   len=count w
            
if w.==":
            
[   i=i+1
               
i0=i
               
while [(digit? w.iand2 (len)]
               
[   i=i+1
               
]
               
if (not alpha? w.iand2 w.!= "%
               
[   i=i-1
                  
s=Items i0 i w
                  
if (count s) > 0
                  
[   s=Int s
                     
s2=(Word (Int 10*s*scale)/10 "%)
                     
l=Items i0-w
                     
ifelse len
                     
[   r=Items i+len w
                        
w=(Word l s2 r)
                     
][   w=(Word l s2)
                     
]
                  
]
               
]
            
]
            
i=i+1
         
]
         
i=1
         
while [< (count w)]
         
[   len=count w
            
if w.==""
            
[   i=i+1
               
i0=i
               
while [(digit? w.iand2 (len)]
               
[   i=i+1
               
]
               
if (not alpha? w.iand2 w.!= "%
               
[   i=i-1
                  
s=Items i0 i w
                  
if (count s) > 0
                  
[   s=Int s
                     
s2=(Word (Int 10*s*scale)/10 "%)
                     
l=Items i0-w
                     
ifelse len
                     
[   r=Items i+len w
                        
w=(Word l s2 r)
                     
][   w=(Word l s2)
                     
]
                  
]
               
]
            
]
            
i=i+1
         
]
         
i=1
         
while [< (count w)]
         
[   len=count w
            
if w.==":
            
[   i=i+1
               
i0=i
               
while [(digit? w.iand2 (len)]
               
[   i=i+1
               
]
               
if w.== "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 i0-w
                     
ifelse len
                     
[   r=Items i+len w
                        
w=(Word l s2 r)
                     
][   w=(Word l s2)
                     
]
                  
]
               
]
            
]
            
i=i+1
         
]
         
print w
      
]
      
setReader []
      
setWriter []
      
close inf
      
close outf   
   
end
end