Les moulinettes c’est comme les coquilles St Jacques , une fois bien lavés a peut resservir aux autres, lol
Cette moulinette extrait toutes les variables Tableaux (ARRAY) du fichier « Variables élémentaires » exporté au format .TXT et génère un fichier Table d’animation .XTB
Dans mon cas, j'en avais beaucoup (258) c’était pour m'évite de me palucher la table d'animation à la mano.
Procédure :
Copier les lignes du script ci dessous et les coller dans le Bloc-notes, enregistrer sous GenereAnim.vbs
Avec l’explorateur de fichiers de Windows double-clic sur GenereAnim.vbs pour exécuter le script.
Ouvrir le fichier « Variables élémentaires » exporté au format .TXT
Ça génère un fichier du même nom avec extension .XTB à importer.
----------------------------------
Code : Tout sélectionner
Option explicit
Dim TXT, sLIGN,sSYMB
Dim fileNameSource, fileNameCible
Dim X1
Dim FSO,Rtxt,Wtxt
fileNameSource=Ucase(GetFileNameDlg())
if InStr(fileNameSource,".TXT")=0 then
MsgBox("Extension fichier Source non valide .Txt")
WScript.Quit 0
end if
'Fichier Résultant Table Animation
fileNameCible = Replace(fileNameSource, ".TXT", ".XTB")
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Rtxt = FSO.OpenTextFile(fileNameSource)
Set Wtxt = FSO.createTextFile(fileNameCible,true)
sLIGN = "<" & Chr(63) & "xml version=§1.0§ encoding=§UTF-8§ standalone=§yes§?>"
sLIGN = Replace(sLIGN, "§", Chr(34))
Wtxt.writeline (sLIGN)
sLIGN = "<TABExchangeFile>"
sLIGN = Replace(sLIGN, "#", Chr(34))
Wtxt.writeline (sLIGN)
sLIGN = vbTab & "<fileHeader company=§Schneider Automation§ product=§Unity Pro XL V6.1 - 111205A§ dateTime=§date_and_time#2016-2-8-14:12:36§ content=§Fichier source tables d'animation§ DTDVersion=§41§></fileHeader>"
sLIGN = Replace(sLIGN, "§", Chr(34))
Wtxt.writeline (sLIGN)
sLIGN = vbTab & "<contentHeader name=§STATION§ version=§0.0.73§ dateTime=§date_and_time#2016-1-15-10:14:37§></contentHeader>"
sLIGN = Replace(sLIGN, "§", Chr(34))
Wtxt.writeline (sLIGN)
sLIGN = vbTab & "<animationTable name=§TArray1§ location=§§ version=§1.0§ dateTime=§date_and_time#2016-2-8-14:12:36§ ExtStringAnim=§0§ ExtStringAnimLen=§100§>"
sLIGN = Replace(sLIGN, "§", Chr(34))
Wtxt.writeline (sLIGN)
sLIGN = vbTab & vbTab & "<comment>commentaire</comment>"
sLIGN = Replace(sLIGN, "§", Chr(34))
Wtxt.writeline (sLIGN)
Do While Not Rtxt.AtEndOfStream
TXT = Rtxt.Readline
X1=instr(TXT,chr(9))
if X1>0 and instr(TXT,"ARRAY[")>0 then
sSYMB=LEFT(TXT,X1-1)
sLIGN = vbTab & vbTab & "<elementDescription displayBase=§4§ name=§" & sSYMB & "§></elementDescription>"
sLIGN = Replace(sLIGN, "§", Chr(34))
Wtxt.writeline (sLIGN)
End If
Loop
Rtxt.Close
sLIGN = vbTab & "</animationTable>"
Wtxt.writeline (sLIGN)
sLIGN = "</TABExchangeFile>"
Wtxt.writeline (sLIGN)
Wtxt.Close
Set FSO = Nothing
Set Rtxt = Nothing
Set Wtxt = Nothing
MsgBox "Fin des opérations" , vbInformation, fileNameCible
Function GetFileNameDlg()
GetFileNameDlg=CreateObject("WScript.Shell").Exec("mshta.exe ""about:<input type=file id=f><script language=""VBScript"">f.click():CreateObject(""Scripting.FileSystemObject"").GetStandardStream(1).Write(f.value):close()</script>""").StdOut.ReadAll
End Function
