Sub Main

Dim oSheet as Object
Dim oCell as Object

Dim oDoc As Object, MonRep As String
Dim sURL As String





dim m as integer
dim  adresse(100) as integer
dim  ma(100) as integer
dim  vit(100) as integer
dim  f0(100) as integer
dim  f1(100) as integer
dim  f2(100) as integer
dim  f3(100) as integer
dim  f4(100) as integer
dim  f5(100) as integer
dim  f6(100) as integer
dim  f7(100) as integer
dim  f8(100) as integer
dim  dt(100) as integer
dim  ag(100) as integer
dim  c(100) as integer
dim  hp(100) as integer
dim nom1 as String
dim nom as String
dim x as integer
dim x2 as integer
dim x3 as integer
dim x4 as integer

  
oSheet = ThisComponent.getSheets.getByName("loco1")
    m = 0
    z = 0
    Do
        m =m+1
        z =z+1
        adresse(m) = oSheet.getCellByPosition(0,5+m).value
        ma(m) = oSheet.getCellByPosition(1,5+m).value
        vit(m) = oSheet.getCellByPosition(2,5+m).value
        f0(m) = oSheet.getCellByPosition(3,5+m).value
        f1(m) = oSheet.getCellByPosition(4,5+m).value
        f2(m) = oSheet.getCellByPosition(5,5+m).value
        f3(m) = oSheet.getCellByPosition(6,5+m).value
        f4(m) = oSheet.getCellByPosition(7,5+m).value
        f5(m) = oSheet.getCellByPosition(8,5+m).value
        f6(m) = oSheet.getCellByPosition(9,5+m).value
        f7(m) = oSheet.getCellByPosition(10,5+m).value
        f8(m) = oSheet.getCellByPosition(11,5+m).value
        dt(m) = oSheet.getCellByPosition(12,5+m).value
        ag(m) = oSheet.getCellByPosition(13,5+m).value
        c(m) = oSheet.getCellByPosition(14,5+m).value
        hp(m) = oSheet.getCellByPosition(15,5+m).value
        
        loop until adresse(m)=0
    oCell =  oSheet.getCellByPosition(0, 0)
    nom1 = oCell.getString

oDoc = ThisComponent
	sURL = oDoc.Url
	MonRep =  MonRepertoire(sURL)
	
 
        
   
    

    
    open MonRep + "temp/" + nom1+".txt" for output as #1
    For m = 1 To z - 1
    Write #1, adresse(m), ma(m), vit(m), f0(m), f1(m), f2(m), f3(m), f4(m), f5(m), f6(m), f7(m), f8(m), dt(m), ag(m), c(m), hp(m)
    Next m
    Write #1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    Close #1
    
oSheet = ThisComponent.getSheets.getByName("loco2")
    m = 0
    z = 0
    Do
        m =m+1
        z =z+1
        adresse(m) = oSheet.getCellByPosition(0,5+m).value
        ma(m) = oSheet.getCellByPosition(1,5+m).value
        vit(m) = oSheet.getCellByPosition(2,5+m).value
        f0(m) = oSheet.getCellByPosition(3,5+m).value
        f1(m) = oSheet.getCellByPosition(4,5+m).value
        f2(m) = oSheet.getCellByPosition(5,5+m).value
        f3(m) = oSheet.getCellByPosition(6,5+m).value
        f4(m) = oSheet.getCellByPosition(7,5+m).value
        f5(m) = oSheet.getCellByPosition(8,5+m).value
        f6(m) = oSheet.getCellByPosition(9,5+m).value
        f7(m) = oSheet.getCellByPosition(10,5+m).value
        f8(m) = oSheet.getCellByPosition(11,5+m).value
        dt(m) = oSheet.getCellByPosition(12,5+m).value
        ag(m) = oSheet.getCellByPosition(13,5+m).value
        c(m) = oSheet.getCellByPosition(14,5+m).value
        hp(m) = oSheet.getCellByPosition(15,5+m).value
        
        loop until adresse(m)=0
    oCell =  oSheet.getCellByPosition(0, 0)
    nom1 = oCell.getString

oDoc = ThisComponent
	sURL = oDoc.Url
	MonRep =  MonRepertoire(sURL)
	
oCell = oSheet.getCellRangeByName("D1")	
if (oCell.getString="oui") then  x2=1  
        
   
    

    
    open MonRep + "temp/" + nom1+".txt" for output as #1
    For m = 1 To z - 1
    Write #1, adresse(m), ma(m), vit(m), f0(m), f1(m), f2(m), f3(m), f4(m), f5(m), f6(m), f7(m), f8(m), dt(m), ag(m), c(m), hp(m)
    Next m
    Write #1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    Close #1
    
oSheet = ThisComponent.getSheets.getByName("loco3")
    m = 0
    z = 0
    Do
        m =m+1
        z =z+1
        adresse(m) = oSheet.getCellByPosition(0,5+m).value
        ma(m) = oSheet.getCellByPosition(1,5+m).value
        vit(m) = oSheet.getCellByPosition(2,5+m).value
        f0(m) = oSheet.getCellByPosition(3,5+m).value
        f1(m) = oSheet.getCellByPosition(4,5+m).value
        f2(m) = oSheet.getCellByPosition(5,5+m).value
        f3(m) = oSheet.getCellByPosition(6,5+m).value
        f4(m) = oSheet.getCellByPosition(7,5+m).value
        f5(m) = oSheet.getCellByPosition(8,5+m).value
        f6(m) = oSheet.getCellByPosition(9,5+m).value
        f7(m) = oSheet.getCellByPosition(10,5+m).value
        f8(m) = oSheet.getCellByPosition(11,5+m).value
        dt(m) = oSheet.getCellByPosition(12,5+m).value
        ag(m) = oSheet.getCellByPosition(13,5+m).value
        c(m) = oSheet.getCellByPosition(14,5+m).value
        hp(m) = oSheet.getCellByPosition(15,5+m).value
        
        loop until adresse(m)=0
    oCell =  oSheet.getCellByPosition(0, 0)
    nom1 = oCell.getString
    
    oCell = oSheet.getCellRangeByName("D1")	
if (oCell.getString="oui") then  x3=1  

oDoc = ThisComponent
	sURL = oDoc.Url
	MonRep =  MonRepertoire(sURL)
	
  
        
   
    

    
    open MonRep + "temp/" + nom1+".txt" for output as #1
    For m = 1 To z - 1
    Write #1, adresse(m), ma(m), vit(m), f0(m), f1(m), f2(m), f3(m), f4(m), f5(m), f6(m), f7(m), f8(m), dt(m), ag(m), c(m), hp(m)
    Next m
    Write #1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    Close #1
    
oSheet = ThisComponent.getSheets.getByName("loco4")
    m = 0
    z = 0
    Do
        m =m+1
        z =z+1
        adresse(m) = oSheet.getCellByPosition(0,5+m).value
        ma(m) = oSheet.getCellByPosition(1,5+m).value
        vit(m) = oSheet.getCellByPosition(2,5+m).value
        f0(m) = oSheet.getCellByPosition(3,5+m).value
        f1(m) = oSheet.getCellByPosition(4,5+m).value
        f2(m) = oSheet.getCellByPosition(5,5+m).value
        f3(m) = oSheet.getCellByPosition(6,5+m).value
        f4(m) = oSheet.getCellByPosition(7,5+m).value
        f5(m) = oSheet.getCellByPosition(8,5+m).value
        f6(m) = oSheet.getCellByPosition(9,5+m).value
        f7(m) = oSheet.getCellByPosition(10,5+m).value
        f8(m) = oSheet.getCellByPosition(11,5+m).value
        dt(m) = oSheet.getCellByPosition(12,5+m).value
        ag(m) = oSheet.getCellByPosition(13,5+m).value
        c(m) = oSheet.getCellByPosition(14,5+m).value
        hp(m) = oSheet.getCellByPosition(15,5+m).value
        
        loop until adresse(m)=0
    oCell =  oSheet.getCellByPosition(0, 0)
    nom1 = oCell.getString

oDoc = ThisComponent
	sURL = oDoc.Url
	MonRep =  MonRepertoire(sURL)
	
oCell = oSheet.getCellRangeByName("D1")	
if (oCell.getString="oui") then  x4=1   
        
   
    

    
    open MonRep + "temp/" + nom1+".txt" for output as #1
    For m = 1 To z - 1
    Write #1, adresse(m), ma(m), vit(m), f0(m), f1(m), f2(m), f3(m), f4(m), f5(m), f6(m), f7(m), f8(m), dt(m), ag(m), c(m), hp(m)
    Next m
    Write #1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    Close #1
    
oSheet = ThisComponent.getSheets.getByName("loco1")    
oCell = oSheet.getCellRangeByName("D1")	
nom = oCell.getString
x=1+x2+x3+x4
open MonRep + "temp/" + nom+".txt" for output as #1
Write #1,x
Close #1



End Sub

Function MonRepertoire(sURL As String) As String
Dim Chemin() As String, MonRep As String 
	Chemin = Split(sURL,"/")
	Chemin(Ubound(Chemin())) = ""
	MonRepertoire = join(Chemin, "/")
End Function