aUCBLogo Demos and Tests / split_help


setCaseIgnored false

be split_help
clearText
   
language="de
   
basepath="D:\temp\help_en

   
changeDir basepath
   
fl=(files [aucblogo.hrf])
   
foreach fl
   
[   splitFile ?
   
]
   
   
be myform num width fillch
      
local [w]
      
w=(word num)
      
if (count w) < width
      
[   repeat width-count w
         
[   w=word fillch w
         
]
      
]
      
output w
   
end
   
   
be arform ar m
      
local [w]
      
w="
      
repeat min count ar m
      
[   w=(word w myform ar.repcount "0 "\ )
      
]
      
output w
   
end
   
   
be splitFile in
      
in_en="aucblogo.hrf
      
openRead in_en
      
setReader in_en
      
l=array readListFlatRaw
      
setWriter []
      
close in_en

      
out=(word in ".txt)
      
(print in "=> out)
comment[
      l=le
      cnt=count l
      sections=[]
      examples=Table 1021
      esectab=Table 1021
      linenr=1
      example=[]
      exline="
      exnr=0
      for [i 1 cnt]
      [   w=l.i
         ifelse i < cnt-3
         [   ifelse (and w=="
            l.(i+1)=="\    l.(i+2)=="\   )
            [   i=i+3
;               (print)
               linenr=linenr+1
;               (type "#\   \   )
               exline="\   \   
               while [and not (and l.i == "
                      (first l.(i+1)) !="\    
                      (first l.(i+2)) !="\    )
                  i<cnt-2]
               [   w=l.i
                  t=translation_en_de.w
                  ifelse t != [] 
                  [   w=t
                  ][   
                  ]
;                  (type w)
                  exline=lput w exline
                  i=i+1
               ]
               i=i-1
               example=lput exline example
            ][
               ifelse (or i==1 (and 
                  w=="
                  l.(i+1) !="\    
                  l.(i+1) !="= 
                  l.(i+1) !="-
                  (first l.(i+2)) !="\    ))
               [
                  examples.exnr=example
                  example=[]               
                  exnr=exnr+1
;                  (type w)
;                  (print)
                  linenr=linenr+1
                  j=i+2
                  ifelse (and l.j !="
                     ;[l.(j+1) !="
                     ;]
                     [(first l.(j+1)) !="\   ] j<cnt-1)
                  [   title="   ;(word linenr "\   )
;                     (type title)
                  ][   title=[]
                  ]
                  while [(and l.j !="
                     j<cnt-1)]
                  [   title=lput l.j title
;                     (type l.j)
                     j=j+1
                  ]
                  if (and 
                     (first l.(j+1)) != "-
                     (first l.(j+1)) != "=
                     j<cnt-1)
                  [
                     while [(and not (and 
                        l.j =="
                        l.(j+1) =="
                        ) j<cnt-1)]
                     [
   ;                     (type l.j)
                        if l.j=="
                        [   linenr=linenr+1
                        ]
                        j=j+1
                     ]
                  ]
                  if title != []
                  [;   title=lput l.j title
                     sections=fput title sections
                     esectab.exnr=title
                  ]
                  i=j-1
               ][
;               (type w)
               ]
            ]
         ][
;            (type w)
         ]
         if w=="
         [   linenr=linenr+1
         ]
      ]
      examples.exnr=example
      esections=reverse sections
      elinenr=linenr
]

      
cnt=count l
      
sections=[]
      
dirs=[]
      
linenr=1
      
exnr=0
      
exlnr=1
      
example=[]
      
level=0
      
path=[]
      
secnr={0 0 0}
      
o="
      
ftitle="nothing.txt
      
ftitles=[]
      
abspaths=[]
      
for [cnt]
      
[   w=l.i
         
ifelse cnt-3
         
[   ifelse (and w=="
            
l.(i+1)=="\    l.(i+2)=="\   )
            
[   i=i+3
               
(print)
               
linenr=linenr+1
               
(type "\   \   )
               
while [and not (and l.== "
                      
(first l.(i+1)) !="\    
                      
(first l.(i+2)) !="\    )
                  
i<cnt-2]
               
[   w=l.i
                  
(type w)
                  
i=i+1
               
]
               
i=i-1
               
exlnr=exlnr+1
            
][
               
ifelse (or i==(and 
                  
w=="
                  
l.(i+1) !="\    
                  
l.(i+1) !="= 
                  
l.(i+1) !="-
                  
(first l.(i+2)) !="\    ))
               
[   exnr=exnr+1
                  
exlnr=1
                  
o=w
                  
if i>1 
                  
[   o=word "
                  
]
                  
linenr=linenr+1
                  
j=i+2
                  
if member? ftitle allopen [close ftitle]
                  
ifelse (and l.!="
                     
[(first l.(j+1)) !="\   j<cnt-1)
                  
[   title="   ;(word linenr "\   )
                  
][   title=[]
                  
]
                  
while [(and l.!= "
                     
j<cnt-1)]
                  
[   title=lput l.j title
                     
o=word o l.j
                     
j=j+1
                  
]
                  
ifelse l.(j+1)=="=
                  
[   ;if level==1 [changeDir "..]
                     
level=1
                     
secnr.1=secnr.1+1
                     
secnr.2=1
                     
secnr.3=0
                     
ftitle=(word arform secnr title)
                     
path=(List ftitle)
                     
abspath=basepath
                     
changeDir abspath
                     
makeDirectory ftitle
                  
][   if l.(j+1)=="-
                     
[   ifelse level==1
                        
[   level=2
                           
secnr.2=secnr.2+1
                           
secnr.3=0
                           
ftitle=(word arform secnr title)
                           
path=lput ftitle path
                           
abspath=(word basepath "\ first path)
                           
changeDir abspath
                           
makeDirectory ftitle
                        
][   ifelse level==2
                           
[   secnr.2=secnr.2+1
                              
secnr.3=0
                              
ftitle=(word arform secnr title)
                              
path=lput ftitle butlast path
                              
abspath=(word basepath "\ first path)
                              
changeDir abspath
                              
makeDirectory ftitle
                           
][   (print [###title)
                           
]
                        
]
                     
]
                  
]
                  
if title != []
                  
[;   title=lput l.j title
                     
secnr.3=secnr.3+1
                     
dirs=fput path dirs
                     
sections=fput title sections
                     
abspath=basepath
                     
foreach path [abspath=(word abspath "\ ?)]
                     
changeDir abspath
                     
abspaths=fput abspath abspaths
                     
ftitle=(word arform secnr remove "
                        
remove "\    remove "_0 title ".txt)
                     
ftitles=fput ftitle ftitles
                     
openWrite ftitle
                     
setWriter ftitle
                  
]
                  
type o
                  
if (and 
                     
(first l.(j+1)) != "-
                     
(first l.(j+1)) != "=
                     
j<cnt-1)
                  
[
                     
while [(and not (and 
                        
l.=="
                        
l.(j+1) =="
                     
j<cnt-1)]
                     
[   (type l.j)
                        
if l.j=="
                        
[   linenr=linenr+1
                        
]
                        
j=j+1
                     
]
                  
]
                  
i=j-1
               
][
                  
(type w)
               
]
            
]
         
][
            
(type w)
         
]
         
if w=="
         
[   linenr=linenr+1
         
]
      
]
      
dirs=reverse dirs
      
sections=reverse sections
      
ftitles=reverse ftitles
      
abspaths=reverse abspaths
      
setWriter []
      
closeall
      
changeDir basepath
      
index="index_logo.txt
      
openWrite index
      
setWriter index
      
(foreach dirs sections 
      
[   foreach ?1 [(type "[ "])]
         
(type "[ ?2 "]) (print)
      
])
      
setWriter []
      
close index
      
      
index="index_dir.txt
      
openWrite index
      
setWriter index
      
(foreach abspaths ftitles 
      
[   (type "" ?1 "\ ?2 "") (print)
      
])
      
setWriter []
      
close index

      
index="index.tex
      
openWrite index
      
setWriter index
      
(foreach abspaths ftitles 
      
[   (type "\include{ ?1 "\ ?2 "}
         )
      
])
      
setWriter []
      
close index
   
end
end