Batya

|
Posted: Tue Dec 16, 2008 15:48 Post subject: |
|
|
Из того, что пока понял по задаче, слепил vbs-скрипт:
Code: | '==============================================================================
' Формирование списка отсутствующих в последовательности элементов
'==============================================================================
Option Explicit
'===== Изменяемые параметры ===================================================
Dim InFile, OutFile, Prefix, Postfix
With WScript
InFile = .Arguments(0)
OutFile = .Arguments(1)
Prefix = .Arguments(2)
Postfix = .Arguments(3)
End With
'==============================================================================
Dim Dic, FSO, List, l, i, m, Str, LenPrefix, LenPostfix
Set Dic = CreateObject("Scripting.Dictionary")
Set FSO = CreateObject("Scripting.FileSystemObject")
LenPrefix = Len(Prefix)
LenPostfix = Len(Postfix)
List = FSO.OpenTextFile(InFile).ReadAll
For Each l In Split(List, vbNewLine)
If (UCase(Left(l, LenPrefix )) = UCase(Prefix )) And _
(UCase(Right(l, LenPostfix)) = UCase(Postfix)) Then
m = CInt(Mid(l, LenPrefix + 1, Len(l) - LenPrefix - LenPostfix))
Dic.Add m, l
End If
Next
For i = Min(Dic.Keys) To Max(Dic.Keys)
If Not Dic.Exists(i) Then
Str = Str & vbNewLine & prefix & i & postfix
End If
Next
Str = Mid(Str, Len(vbNewLine) + 1)
FSO.CreateTextFile(OutFile, True).Write Str
Quit
Function Max(pArr)
Dim lE, lM
lM = pArr(0)
For Each lE In pArr
If lE > lM Then lM = lE
Next
Max = lM
End Function
Function Min(pArr)
Dim lE, lM
lM = pArr(0)
For Each lE In pArr
If lE < lM Then lM = lE
Next
Min = lM
End Function
Sub Quit
Set Dic = Nothing
Set FSO = Nothing
WScript.Quit
End Sub |
Скрипт запускается с четырьмя параметрами:
1 - исходный список-последовательность,
2 - выходной список-последовательность,
3 - начало элемента,
4 - окончание элемента.
Например: Code: | "existing_files.txt" "missing_files.txt" "str _" "_ end.test" |
_________________ Нет, я не сплю. Я просто медленно моргаю. |
|