- Module Module1
- Public Sub main()
- 'on va essayer sa :
- 'il faut chercher : # # # rgb
- 'et le changer pour : 0 0 0 rbg
-
- 'une boucle devrai suffire, g des doute pour les image...
- 'aller on adapte pour faire un exe :
- 'args : Nomfichier1, nomFichier2 ...
-
- 'verification qu'il y à des argument :
- Dim f As String
- If My.Application.CommandLineArgs.Count = 0 Then
- disphelp()
- Exit Sub
- End If
- 'recuperation du repertoire temporaire :
- Dim temp As String = System.Environment.GetEnvironmentVariable("temp")
-
-
- For Each f In My.Application.CommandLineArgs
-
- If System.IO.File.Exists(f) Then
- 'fichier temporaire :
- Dim e As Integer
- Dim temp_fich As String = temp & "\temp_ps" & e & ".ps"
- e += 1
-
- Dim li As New System.IO.StreamReader(f)
- Dim lio As New System.IO.StreamWriter(temp_fich, False)
-
- While Not li.EndOfStream
- Dim t As String = li.ReadLine
- If t Like "*rgb*" And Not t Like "*/rgb*" Then
- 'If Not t Like "*0 0 0 rgb*" Then
- 'bon la il faut faire une petite boucle...
- 'on prend l'index de rbg :
- Dim fi As Boolean = False
- Dim ind As Integer = 0
- While Not fi
- t = net_line(t, t.IndexOf("rgb", ind))
- If (t.LastIndexOf("0 0 0 rgb") + 9) <> (t.LastIndexOf("rgb") + 3) Then
- ind = t.LastIndexOf("0 0 0 rgb") + 9
- Else : fi = True
- End If
- End While
-
- 'End If
- End If
- lio.WriteLine(t)
- End While
- lio.Close()
- li.Close()
-
- 'on copi le fichier
- System.IO.File.Copy(temp_fich, f, True)
- End If
- Next
-
-
-
- End Sub
-
- Private Function net_line(ByVal l As String, ByVal i As Integer) As String
-
- Dim ind As Integer = i
- Dim ind2 = ind - 1
- Dim rgbfini As Boolean = False
- Dim pa As Integer = 0
- While rgbfini = False
-
- If (Char.IsNumber(l.Chars(ind2)) Or l.Chars(ind2) = " " Or l.Chars(ind2) = ".") And ind2 > 1 Then
- If l.Chars(ind2) = " " Then
- pa += 1
- If pa = 4 Then Exit While
- End If
-
- Console.WriteLine(l.Chars(ind2))
-
- ind2 -= 1
- Else
- Exit While
- End If
-
- End While
-
- If ind - 1 <> ind2 Then
- If l.Substring(ind2 - 1, ind + 2 - ind2) Like "* *" Then
- l = l.Replace(l.Substring(ind2 + 1, (ind - ind2) + 2), " 0 0 0 rgb")
- End If
- End If
-
- Return l
- End Function
-
-
- Sub disphelp()
-
- Console.WriteLine("Utilisation :")
- Console.WriteLine("Nom_du_premier_fichier nom_du_deuxieme_fichier...")
- Console.WriteLine("")
- Console.WriteLine("Les fichier sont ecrasés")
-
- End Sub
-
- End Module
-
Module Module1
Public Sub main()
'on va essayer sa :
'il faut chercher : # # # rgb
'et le changer pour : 0 0 0 rbg
'une boucle devrai suffire, g des doute pour les image...
'aller on adapte pour faire un exe :
'args : Nomfichier1, nomFichier2 ...
'verification qu'il y à des argument :
Dim f As String
If My.Application.CommandLineArgs.Count = 0 Then
disphelp()
Exit Sub
End If
'recuperation du repertoire temporaire :
Dim temp As String = System.Environment.GetEnvironmentVariable("temp")
For Each f In My.Application.CommandLineArgs
If System.IO.File.Exists(f) Then
'fichier temporaire :
Dim e As Integer
Dim temp_fich As String = temp & "\temp_ps" & e & ".ps"
e += 1
Dim li As New System.IO.StreamReader(f)
Dim lio As New System.IO.StreamWriter(temp_fich, False)
While Not li.EndOfStream
Dim t As String = li.ReadLine
If t Like "*rgb*" And Not t Like "*/rgb*" Then
'If Not t Like "*0 0 0 rgb*" Then
'bon la il faut faire une petite boucle...
'on prend l'index de rbg :
Dim fi As Boolean = False
Dim ind As Integer = 0
While Not fi
t = net_line(t, t.IndexOf("rgb", ind))
If (t.LastIndexOf("0 0 0 rgb") + 9) <> (t.LastIndexOf("rgb") + 3) Then
ind = t.LastIndexOf("0 0 0 rgb") + 9
Else : fi = True
End If
End While
'End If
End If
lio.WriteLine(t)
End While
lio.Close()
li.Close()
'on copi le fichier
System.IO.File.Copy(temp_fich, f, True)
End If
Next
End Sub
Private Function net_line(ByVal l As String, ByVal i As Integer) As String
Dim ind As Integer = i
Dim ind2 = ind - 1
Dim rgbfini As Boolean = False
Dim pa As Integer = 0
While rgbfini = False
If (Char.IsNumber(l.Chars(ind2)) Or l.Chars(ind2) = " " Or l.Chars(ind2) = ".") And ind2 > 1 Then
If l.Chars(ind2) = " " Then
pa += 1
If pa = 4 Then Exit While
End If
Console.WriteLine(l.Chars(ind2))
ind2 -= 1
Else
Exit While
End If
End While
If ind - 1 <> ind2 Then
If l.Substring(ind2 - 1, ind + 2 - ind2) Like "* *" Then
l = l.Replace(l.Substring(ind2 + 1, (ind - ind2) + 2), " 0 0 0 rgb")
End If
End If
Return l
End Function
Sub disphelp()
Console.WriteLine("Utilisation :")
Console.WriteLine("Nom_du_premier_fichier nom_du_deuxieme_fichier...")
Console.WriteLine("")
Console.WriteLine("Les fichier sont ecrasés")
End Sub
End Module