Цитата TRaMeLL:
Код:
Код: Выделить всё
Дата=…Так что, начните с формулировки новых требований: что, как, откуда…
Код: Выделить всё
Дата=…Код: Выделить всё
Option Explicit
Const adInteger = 3
Const adCurrency = 6
Const adDate = 7
Const adVarChar = 200
Dim lngErrCode
Dim strSourceFile
Dim strLine
Dim objTS
Dim objRecordSet
Dim intNumberMaxLength
Dim intSummMaxLength
Dim intPlatMaxLength
If WScript.Arguments.Count = 1 Then
strSourceFile = WScript.Arguments.Item(0)
With WScript.CreateObject("Scripting.FileSystemObject")
If .FileExists(strSourceFile) Then
Set objTS = .OpenTextFile(strSourceFile)
With WScript.CreateObject("ADOR.Recordset")
With .Fields
.Append "Дата", adDate
.Append "Номер", adVarChar, 2^5
.Append "Сумма", adCurrency
.Append "ДлинаСтрокиСумма", adInteger
.Append "Плательщик", adVarChar, 2^15 - 1
.Append "ДлинаСтрокиПлательщик", adInteger
End With
.Open
Do Until objTS.AtEndOfStream
strLine = objTS.ReadLine()
Select Case Split(strLine, "=")(0)
Case "СекцияДокумент"
.AddNew
Case "Дата"
If Len(Split(strLine, "=")(1)) 0 Then
.Fields.Item("Дата").Value = CDate(Split(strLine, "=")(1))
End If
Case "Номер"
.Fields.Item("Номер").Value = CStr(Split(strLine, "=")(1))
Case "Сумма"
'SetLocale "en-us"
.Fields.Item("Сумма").Value = CCur(Split(strLine, "=")(1))
'SetLocale "ru"
.Fields.Item("ДлинаСтрокиСумма").Value = Len(FormatCurrency(.Fields.Item("Сумма").Value, 2))
Case "Плательщик", "Плательщик1"
.Fields.Item("Плательщик").Value = CStr(Split(strLine, "=")(1))
.Fields.Item("ДлинаСтрокиПлательщик").Value = Len(CStr(Split(strLine, "=")(1)))
End Select
Loop
objTS.Close
.Sort = "Номер DESC" : .MoveFirst
intNumberMaxLength = Len(.Fields.Item("Номер").Value)
.Sort = "ДлинаСтрокиСумма DESC" : .MoveFirst
intSummMaxLength = .Fields.Item("ДлинаСтрокиСумма").Value
.Sort = "ДлинаСтрокиПлательщик DESC" : .MoveFirst
intPlatMaxLength = .Fields.Item("ДлинаСтрокиПлательщик").Value
.Sort = "" : .MoveFirst
Do Until .EOF
With .Fields
WScript.StdOut.Write Left(CStr(.Item("Дата").Value) & Space(10), 10) & vbTab
WScript.StdOut.Write Right(Space(intNumberMaxLength) & CStr(.Item("Номер").Value), intNumberMaxLength) & vbTab
WScript.StdOut.Write Right(Space(intSummMaxLength) & FormatCurrency(.Item("Сумма").Value, 2), intSummMaxLength) & vbTab
WScript.StdOut.Write Left(CStr(.Item("Плательщик").Value) & Space(intPlatMaxLength), intPlatMaxLength)
WScript.StdOut.WriteLine
End With
.MoveNext
Loop
.Close
End With
Set objTS = Nothing
lngErrCode = 0
Else
WScript.StdErr.WriteLine "File [" & strSourceFile & "] not found"
lngErrCode = 2
End If
End With
Else
WScript.StdErr.WriteLine "Usage: cscript.exe //nologo """ & WScript.ScriptName & """ """""
lngErrCode = 1
End If
WScript.Quit lngErrCode
.Код: Выделить всё
Option Explicit
Const adInteger = 3
Const adCurrency = 6
Const adDate = 7
Const adVarChar = 200
Dim lngErrCode
Dim strSourceFile
Dim strLine
Dim objTS
Dim objRecordSet
Dim intNumberMaxLength
Dim intSummMaxLength
Dim intPlatMaxLength
If WScript.Arguments.Count = 1 Then
strSourceFile = WScript.Arguments.Item(0)
With WScript.CreateObject("Scripting.FileSystemObject")
If .FileExists(strSourceFile) Then
Set objTS = .OpenTextFile(strSourceFile)
With WScript.CreateObject("ADOR.Recordset")
With .Fields
.Append "Дата", adDate
.Append "Номер", adVarChar, 2^5
.Append "Сумма", adCurrency
.Append "ДлинаСтрокиСумма", adInteger
.Append "Плательщик", adVarChar, 2^15 - 1
.Append "ДлинаСтрокиПлательщик", adInteger
End With
.Open
Do Until objTS.AtEndOfStream
strLine = objTS.ReadLine()
Select Case Split(strLine, "=")(0)
Case "СекцияДокумент"
.AddNew
Case "Дата"
If Len(Split(strLine, "=")(1)) 0 Then
.Fields.Item("Дата").Value = CDate(Split(strLine, "=")(1))
End If
Case "Номер"
.Fields.Item("Номер").Value = CStr(Split(strLine, "=")(1))
Case "Сумма"
'SetLocale "en-us"
.Fields.Item("Сумма").Value = CCur(Split(strLine, "=")(1))
'SetLocale "ru"
.Fields.Item("ДлинаСтрокиСумма").Value = Len(FormatCurrency(.Fields.Item("Сумма").Value, 2))
Case "Плательщик", "Плательщик1"
.Fields.Item("Плательщик").Value = CStr(Split(strLine, "=")(1))
.Fields.Item("ДлинаСтрокиПлательщик").Value = Len(CStr(Split(strLine, "=")(1)))
Case "ДатаСписано"
If IsDate(Split(strLine, "=")(1)) Then
.Fields.Item("Сумма").Value = - .Fields.Item("Сумма").Value
End If
End Select
Loop
objTS.Close
.Sort = "Номер DESC" : .MoveFirst
intNumberMaxLength = Len(.Fields.Item("Номер").Value)
.Sort = "ДлинаСтрокиСумма DESC" : .MoveFirst
intSummMaxLength = .Fields.Item("ДлинаСтрокиСумма").Value
.Sort = "ДлинаСтрокиПлательщик DESC" : .MoveFirst
intPlatMaxLength = .Fields.Item("ДлинаСтрокиПлательщик").Value
.Sort = "" : .MoveFirst
Do Until .EOF
With .Fields
WScript.StdOut.Write Left(CStr(.Item("Дата").Value) & Space(10), 10) & vbTab
WScript.StdOut.Write Right(Space(intNumberMaxLength) & CStr(.Item("Номер").Value), intNumberMaxLength) & vbTab
WScript.StdOut.Write Right(Space(intSummMaxLength) & FormatCurrency(.Item("Сумма").Value, 2), intSummMaxLength) & vbTab
WScript.StdOut.Write Left(CStr(.Item("Плательщик").Value) & Space(intPlatMaxLength), intPlatMaxLength)
WScript.StdOut.WriteLine
End With
.MoveNext
Loop
.Close
End With
Set objTS = Nothing
lngErrCode = 0
Else
WScript.StdErr.WriteLine "File [" & strSourceFile & "] not found"
lngErrCode = 2
End If
End With
Else
WScript.StdErr.WriteLine "Usage: cscript.exe //nologo """ & WScript.ScriptName & """ """""
lngErrCode = 1
End If
WScript.Quit lngErrCodeКод: Выделить всё
Option Explicit
Const adInteger = 3
Const adCurrency = 6
Const adDate = 7
Const adVarChar = 200
Dim lngErrCode
Dim strSourceFile
Dim strLine
Dim objTS
Dim objRecordSet
Dim intNumberMaxLength
Dim intSummMaxLength
Dim intPlatMaxLength
Dim intNazPlatMaxLength
If WScript.Arguments.Count = 1 Then
strSourceFile = WScript.Arguments.Item(0)
With WScript.CreateObject("Scripting.FileSystemObject")
If .FileExists(strSourceFile) Then
Set objTS = .OpenTextFile(strSourceFile)
With WScript.CreateObject("ADOR.Recordset")
With .Fields
.Append "ДатаСписано", adDate
.Append "ДатаПоступило", adDate
.Append "Номер", adVarChar, 2^5
.Append "Сумма", adCurrency
.Append "ДлинаСтрокиСумма", adInteger
.Append "Плательщик", adVarChar, 2^15 - 1
.Append "ДлинаСтрокиПлательщик", adInteger
.Append "НазначениеПлатежа", adVarChar, 2^15 - 1
.Append "ДлинаСтрокиНазначениеПлатежа", adInteger
End With
.Open
Do Until objTS.AtEndOfStream
strLine = objTS.ReadLine()
Select Case Split(strLine, "=")(0)
Case "СекцияДокумент"
.AddNew
Case "ДатаСписано"
If Len(Split(strLine, "=")(1)) 0 Then
.Fields.Item("ДатаСписано").Value = CDate(Split(strLine, "=")(1))
.Fields.Item("Сумма").Value = - .Fields.Item("Сумма").Value
End If
Case "ДатаПоступило"
If Len(Split(strLine, "=")(1)) 0 Then
.Fields.Item("ДатаПоступило").Value = CDate(Split(strLine, "=")(1))
End If
Case "Номер"
.Fields.Item("Номер").Value = CStr(Split(strLine, "=")(1))
Case "Сумма"
'SetLocale "en-us"
SetLocale "en-us"
.Fields.Item("Сумма").Value = CCur(Split(strLine, "=")(1))
'SetLocale "ru"
SetLocale "ru"
.Fields.Item("ДлинаСтрокиСумма").Value = Len(FormatCurrency(.Fields.Item("Сумма").Value, 2))
Case "Плательщик", "Плательщик1"
.Fields.Item("Плательщик").Value = CStr(Split(strLine, "=")(1))
.Fields.Item("ДлинаСтрокиПлательщик").Value = Len(CStr(Split(strLine, "=")(1)))
Case "НазначениеПлатежа"
.Fields.Item("НазначениеПлатежа").Value = CStr(Split(strLine, "=")(1))
.Fields.Item("ДлинаСтрокиНазначениеПлатежа").Value = Len(CStr(Split(strLine, "=")(1)))
'Case "ДатаСписано"
' If IsDate(Split(strLine, "=")(1)) Then
' .Fields.Item("Сумма").Value = - .Fields.Item("Сумма").Value
' End If
End Select
Loop
objTS.Close
.Sort = "Номер DESC" : .MoveFirst
intNumberMaxLength = Len(.Fields.Item("Номер").Value)
.Sort = "ДлинаСтрокиСумма DESC" : .MoveFirst
intSummMaxLength = .Fields.Item("ДлинаСтрокиСумма").Value
.Sort = "ДлинаСтрокиПлательщик DESC" : .MoveFirst
intPlatMaxLength = .Fields.Item("ДлинаСтрокиПлательщик").Value
.Sort = "ДлинаСтрокиНазначениеПлатежа DESC" : .MoveFirst
intNazPlatMaxLength = .Fields.Item("ДлинаСтрокиНазначениеПлатежа").Value
.Sort = "" : .MoveFirst
Do Until .EOF
With .Fields
WScript.StdOut.Write Left(CStr(.Item("ДатаСписано").Value) & Space(10), 10) & vbTab
WScript.StdOut.Write Left(CStr(.Item("ДатаПоступило").Value) & Space(10), 10) & vbTab
WScript.StdOut.Write Right(Space(intNumberMaxLength) & CStr(.Item("Номер").Value), intNumberMaxLength) & vbTab
WScript.StdOut.Write Right(Space(intSummMaxLength) & FormatCurrency(.Item("Сумма").Value, 2), intSummMaxLength) & vbTab
WScript.StdOut.Write Left(CStr(.Item("Плательщик").Value) & Space(intPlatMaxLength), intPlatMaxLength) & vbTab
WScript.StdOut.Write Left(CStr(.Item("НазначениеПлатежа").Value) & Space(intNazPlatMaxLength), intNazPlatMaxLength)
WScript.StdOut.WriteLine
End With
.MoveNext
Loop
.Close
End With
Set objTS = Nothing
lngErrCode = 0
Else
WScript.StdErr.WriteLine "File [" & strSourceFile & "] not found"
lngErrCode = 2
End If
End With
Else
WScript.StdErr.WriteLine "Usage: cscript.exe //nologo """ & WScript.ScriptName & """ """""
lngErrCode = 1
End If
WScript.Quit lngErrCode