1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
|
CoreScriptHello()
Function Blanc(TextFile)
Const ForReading = 1
Const ForWriting = 2
Set fso = CreateObject("Scripting.FileSystemObject")
Set objFile = fso.OpenTextFile(TextFile, ForReading)
Do Until objFile.AtEndOfStream
strLine = objFile.Readline
strLine = Trim(strLine)
If Len(strLine) > 0 Then
strNewContents = strNewContents & strLine & vbCrLf
End If
Loop
objFile.Close
Set objFile = fso.OpenTextFile(TextFile, ForWriting)
objFile.Write strNewContents
objFile.Close
set objTextFile = Nothing
set fso = Nothing
End Function
Function EditText(TextFile)
Number = "0,1,2,3,4,5,6,7,8,9"
strNumber = split(number,",")
Const ForReading = 1
set objFS = CreateObject("Scripting.FileSystemObject")
set objTS = objFS.OpenTextFile(TextFile, ForReading)
strFileName2 = left(TextFile, (len(TextFile)-4)) & ".txt"
set objTS2 = objFS.CreateTextFile(strFileName2, True)
Do Until objTS.AtEndOfStream
strLine = objTS.Readline
if left(strLine,8)= "--More--" then
Strline2 = right(strLine,4)
objTS2.writeline (Strline2)
Else
for i = 0 to 9
if left(strLine,1) = strnumber(i) then
objTS2.writeline (strLine)
end if
Next
end if
Loop
set objFS = Nothing
set objTS = Nothing
set objFS2 = Nothing
set objTS2 = Nothing
End Function
Function CoreScriptHello ()
'RECUPERATION DES PARAMETRES
Const FileTempo = "infos.txt"
Const ForReading = 1
Const ForWriting = 2
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(FileTempo) = false Then
Nom = InputBox("Entrez Nom","Name")
Adresse = InputBox("Entrez Adresse","Mon ADRESSE")
MonNet = InputBox("Entrez NET","Mon NET")
set objTS2 = fso.CreateTextFile(FileTempo, True)
objTS2.writeline (Nom & ";" & Adresse & ";" & MonNet)
objTS2.close
else
set objTS2 = fso.OpenTextFile(FileTempo, ForReading)
Do Until objTS2.AtEndOfStream
RecupTemp = objTS2.readline
loop
arrayRecupTemp = split(RecupTemp,";")
Nom = arrayRecupTemp(0)
Adresse = arrayRecupTemp(1)
MonNet = arrayRecupTemp(2)
End if
'MODIFICATION DU FICHIER ORIGINAL
Set objFile = fso.OpenTextFile("D:\b\b.txt", ForReading)
strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, "LENET", MonNet)
strNewText2 = Replace(strNewText, "LENOM", Nom)
strNewText3 = Replace(strNewText2, "LEADRESSE", Adresse)
Dim fso, objFolder, objShell, objFile
Dim strDirectory, strFile
strDirectory = "D:"
strFile = "\b\new.txt"
'CREATION DU FICHIER
' Check that the strDirectory folder exists
If fso.FolderExists(strDirectory) Then
Set objFolder = fso.GetFolder(strDirectory)
Else
Set objFolder = fso.CreateFolder(strDirectory)
End If
If fso.FileExists(strDirectory & strFile) Then
Set objFolder = fso.GetFolder(strDirectory)
Else
Set objFile = fso.CreateTextFile(strDirectory & strFile)
End If
set objFolder = nothing
set objFile = nothing
If err.number = vbEmpty then
Set objShell = CreateObject("WScript.Shell")
objShell.run ("Explorer" & " " & strDirectory & "\" )
Else WScript.echo "VBScript Error: " & err.number
End If
'REECRITURE DU FICHIER
Set objFile = fso.OpenTextFile("D:\b\new.txt", ForWriting)
objFile.WriteLine strNewText3
objFile.Close
End Function |
Partager