Moulinette en VBScript pour décaler toutes les adresses des variables externes dans une application Vijeo-Designer (ou autre).
Les moulinettes c’est comme les coquilles St Jacques, une fois bien lavés ça peut resservir surtout si le besoin s’en fait sentir, lol
Procédure :
Copier les lignes du script ci dessous et les coller dans le Bloc-notes, enregistrer sous MoveVijeo.vbs
Avec l’explorateur de fichiers de Windows double-clic sur MoveVijeo.vbs pour exécuter le script.
Avant, dans le script mettre les valeur des décalages désirés en +/- à la place de ceux mis par défaut ou 0 si pas de décalages:
'------- VALEUR DU DECALAGE POUR LES BITS %M -------------------
MOFS=+100 ou ( MOFS=-100 pour un décalage négatif)
'------- VALEUR DU DECALAGE POUR LES MOTS %MW,%MD,%MF ----------
WOFS=+1000 ou ( WOFS=-1000 pour un décalage négatif)
'---------------------------------------------------------------
Dans Vijeo-designer (ou autre) ,
Exporter les variables dans un fichier ASCII et ouvrir ce fichier avec la moulinette puis importer le fichier résultant _RESULT_
dans le Vijeo (ou autre) avec écrasement.
(Ps : ça cherche les termes : %Mx , %MWx , %MWx:X , %MDx , %MFx, en fait, ça décale les adresses dans tout fichiers ASCII ou l'on retrouve ces termes.
modifier pour chercher d’autres termes que ceux là)
Code : Tout sélectionner
'Script Version V1.00
Option explicit
Dim TXT,fileNameSource,fileNameCible,sOBJ,sVAL, iVAL,sL
Dim mySize,XMin,XMax,XX,MOFS,WOFS
Dim FSO,Rtxt,Wtxt
Dim oRegExp, oMatches, oMatch
'Objet Régular-expressions
Set oRegExp = CreateObject("VBScript.RegExp")
oRegExp.Global = True
oRegExp.IgnoreCase = True
fileNameSource=GetFileNameDlg()
if InStr(fileNameSource,".")=0 then
MsgBox("Fichier avec Extension obligatoire ex: *.txt")
WScript.Quit 0
end if
'Fichier résultat
fileNameCible = Replace(fileNameSource, ".", "_RESULT_.")
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Rtxt = FSO.OpenTextFile(fileNameSource)
TXT=Rtxt.ReadAll
Rtxt.close
Set Wtxt = FSO.createTextFile(fileNameCible,true)
'------- VALEUR DU DECALAGE POUR LES BITS %M -------------------
MOFS=+110
'------- VALEUR DU DECALAGE POUR LES MOTS %MW,%MW:X %MD,%MF ----------
WOFS=+1000
'---------------------------------------------------------------
'%M0
XMin=32000:XMax=0
oRegExp.Pattern = "%M[0-9]+"
Set oMatches = oRegExp.Execute(TXT)
For Each oMatch In oMatches
sOBJ=oMatch.Value
iVAL=CInt(Replace(sOBJ, "%M", ""))
if iVAL<XMin then XMin=iVAL
if iVAL>XMax then XMax=iVAL
Next
For XX = XMax to XMin Step -1
sOBJ="%M" & CStr(XX)
sVAL="%§" & CStr(XX+MOFS)
TXT=Replace(TXT, sOBJ,sVAL)
Next
'%MW0
XMin=32000:XMax=0
oRegExp.Pattern = "%MW[0-9]+"
Set oMatches = oRegExp.Execute(TXT)
For Each oMatch In oMatches
sOBJ=oMatch.Value
iVAL=CInt(Replace(sOBJ, "%MW", ""))
if iVAL<XMin then XMin=iVAL
if iVAL>XMax then XMax=iVAL
Next
For XX = XMax to XMin Step -1
sOBJ="%MW" & CStr(XX)
sVAL="%§W" & CStr(XX+WOFS)
TXT=Replace(TXT, sOBJ,sVAL)
Next
'%MD0
XMin=32000:XMax=0
oRegExp.Pattern = "%MD[0-9]+"
Set oMatches = oRegExp.Execute(TXT)
For Each oMatch In oMatches
sOBJ=oMatch.Value
iVAL=CInt(Replace(sOBJ, "%MD", ""))
if iVAL<XMin then XMin=iVAL
if iVAL>XMax then XMax=iVAL
Next
For XX = XMax to XMin Step -1
sOBJ="%MD" & CStr(XX)
sVAL="%§D" & CStr(XX+WOFS)
TXT=Replace(TXT, sOBJ,sVAL)
Next
'%MF0
XMin=32000:XMax=0
oRegExp.Pattern = "%MF[0-9]+"
Set oMatches = oRegExp.Execute(TXT)
For Each oMatch In oMatches
sOBJ=oMatch.Value
iVAL=CInt(Replace(sOBJ, "%MF", ""))
if iVAL<XMin then XMin=iVAL
if iVAL>XMax then XMax=iVAL
Next
For XX = XMax to XMin Step -1
sOBJ="%MF" & CStr(XX)
sVAL="%§F" & CStr(XX+WOFS)
TXT=Replace(TXT, sOBJ,sVAL)
Next
TXT = Replace(TXT, "%§", "%M")
Wtxt.write (TXT)
Wtxt.close
Set oRegExp = Nothing
Set oMatches =Nothing
Set oMatch =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
