<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; VBS: Выборочное считывание текстового файла]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=5591&amp;type=atom" />
	<updated>2011-06-12T10:54:09Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=5591</id>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Выборочное считывание текстового файла]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=49091#p49091" />
			<content type="html"><![CDATA[<p>ну уже с предыдущим и сам разобрался, но теперь надо сделать еще так, чтобы показывалось количество строк без этих символов</p>]]></content>
			<author>
				<name><![CDATA[president100]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27011</uri>
			</author>
			<updated>2011-06-12T10:54:09Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=49091#p49091</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Выборочное считывание текстового файла]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=49086#p49086" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>president100 пишет:</cite><blockquote><p>ну вот у меня есть код, который при заданном параметре, пропускает строки с решеткой</p><br /><br /><p>и в нем мне нужно еще сделать, чтоб он пропускал строки с ! и |</p></blockquote></div><p>Почему бы не завернуть его в тег code?</p><div class="codebox"><pre><code>
set args = wscript.arguments
set fso = wscript.createobject(&quot;scripting.filesystemobject&quot;)
set shell = wscript.createobject(&quot;wscript.shell&quot;)

dir = &quot;h:\smth&quot; &#039; нужно указывать существующую папку

if args.count &gt; 0 then
  if fso.folderExists(args(0)) then
    dir = args(0)
  end if
end if

if args.count &gt; 1 then
  sec = 1
else
  sec = 0
end if

shell.currentDirectory = dir

if fso.fileExists(&quot;out.txt&quot;) then
  fso.deleteFile(&quot;out.txt&quot;)
end if

set stream = fso.opentextfile(&quot;out&quot;, 2, true)

for each file in fso.getFolder(shell.currentDirectory).files
  if len(file.name) &gt; 3 then
    if ucase(right(file.name, 3)) = &quot;TXT&quot; then &#039; будем читать только файлы с расширением.txt
      set stream1 = fso.openTextFile(file.name, 1)
      do
        str = stream1.readline
        if (sec = 1) and (len(str) &gt; 0) then
          if left(str, 1) &lt;&gt; &quot;#&quot; then          
            stream.writeline str
          end if
        else
          stream.writeline str
        end if
      loop until stream1.atEndOfStream
      stream1.close
    end if
  end if
next

stream.close

set file = fso.getFile(&quot;out&quot;)
file.name = &quot;out.txt&quot;</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Alexey]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=2696</uri>
			</author>
			<updated>2011-06-11T06:43:57Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=49086#p49086</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Выборочное считывание текстового файла]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=49085#p49085" />
			<content type="html"><![CDATA[<p>ну вот у меня есть код, который при заданном параметре, пропускает строки с решеткой<br /></p><div class="codebox"><pre><code>set args = wscript.arguments
set fso = wscript.createobject(&quot;scripting.filesystemobject&quot;)
set shell = wscript.createobject(&quot;wscript.shell&quot;)

dir = &quot;h:\smth&quot; &#039; нужно указывать существующую папку

if args.count &gt; 0 then
  if fso.folderExists(args(0)) then
    dir = args(0)
  end if
end if

if args.count &gt; 1 then
  sec = 1
else
  sec = 0
end if

shell.currentDirectory = dir

if fso.fileExists(&quot;out.txt&quot;) then
  fso.deleteFile(&quot;out.txt&quot;)
end if

set stream = fso.opentextfile(&quot;out&quot;, 2, true)

for each file in fso.getFolder(shell.currentDirectory).files
  if len(file.name) &gt; 3 then
    if ucase(right(file.name, 3)) = &quot;TXT&quot; then &#039; будем читать только файлы с расширением.txt
      set stream1 = fso.openTextFile(file.name, 1)
      do
        str = stream1.readline
        if (sec = 1) and (len(str) &gt; 0) then
          if left(str, 1) &lt;&gt; &quot;#&quot; then          
            stream.writeline str
          end if
        else
          stream.writeline str
        end if
      loop until stream1.atEndOfStream
      stream1.close
    end if
  end if
next

stream.close

set file = fso.getFile(&quot;out&quot;)
file.name = &quot;out.txt&quot;</code></pre></div><p>и в нем мне нужно еще сделать, чтоб он пропускал строки с ! и |</p>]]></content>
			<author>
				<name><![CDATA[president100]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27011</uri>
			</author>
			<updated>2011-06-11T06:29:36Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=49085#p49085</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Выборочное считывание текстового файла]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=49073#p49073" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>president100 пишет:</cite><blockquote><p>а как например сделать, чтоб скрипт не считывал из файлов строки, начинающиеся на #, ! и | ?</p></blockquote></div><p><strong>Никак</strong>. Чтобы понять, что строка начинается с искомых символов, надо её (строку) считать. А далее действовать по усмотрению: <em>если строка начинается с символа(ов), то ...</em></p>]]></content>
			<author>
				<name><![CDATA[Rumata]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24846</uri>
			</author>
			<updated>2011-06-10T18:56:32Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=49073#p49073</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Выборочное считывание текстового файла]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=49069#p49069" />
			<content type="html"><![CDATA[<p>а как например сделать, чтоб скрипт не считывал из файлов строки, начинающиеся на #, ! и | ?</p>]]></content>
			<author>
				<name><![CDATA[president100]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27011</uri>
			</author>
			<updated>2011-06-10T17:23:37Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=49069#p49069</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Выборочное считывание текстового файла]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=47435#p47435" />
			<content type="html"><![CDATA[<p>Огромное списибо....всё подошло</p>]]></content>
			<author>
				<name><![CDATA[NAUN]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26223</uri>
			</author>
			<updated>2011-04-07T11:46:56Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=47435#p47435</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Выборочное считывание текстового файла]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=46382#p46382" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>NAUN пишет:</cite><blockquote><p>который считывает&nbsp; выборочно строки</p></blockquote></div><div class="quotebox"><cite>NAUN пишет:</cite><blockquote><p>последовательно считывал строки</p></blockquote></div><p><strong>NAUN</strong>, как-то непоследовательно <img src="//forum.script-coding.com/img/smilies/wink.png" width="15" height="15" />.</p><p>Предположим, что верно второе утверждение:<br /></p><div class="codebox"><pre><code>Option Explicit

&#039; IOMode Enum
Const ForReading   = 1
Const ForWriting   = 2
Const ForAppending = 8

&#039; Format Enum
Const TristateUseDefault = -2
Const TristateTrue       = -1
Const TristateFalse      =  0


Dim strFileIn
Dim strFileOut

Dim objFSO
Dim objTSIn
Dim objTSOut


With WScript.Arguments
    If .Count = 2 Then
        strFileIn  = .Item(0)
        strFileOut = .Item(1)
    Else
        WScript.Echo &quot;Usage: &quot; &amp; WScript.ScriptName &amp; &quot; &lt;File to input&gt; &lt;File to output&gt;&quot;
        WScript.Quit 1
    End If
End With

With WScript.CreateObject(&quot;Scripting.FileSystemObject&quot;)
    strFileIn  = .GetAbsolutePathName(strFileIn)
    strFileOut = .GetAbsolutePathName(strFileOut)
    
    If .FileExists(strFileIn) Then
        Set objTSIn  = .OpenTextFile(strFileIn,  ForReading, False, TristateUseDefault)
        Set objTSOut = .OpenTextFile(strFileOut, ForWriting, True,  TristateUseDefault)
        
        Do Until objTSIn.AtEndOfStream
            objTSOut.WriteLine Mid(objTSIn.ReadLine(), 4)
        Loop
        
        objTSOut.Close
        objTSIn.Close
        
        Set objTSOut = Nothing
        Set objTSIn  = Nothing
    Else
        WScript.Echo &quot;Can&#039;t find input file [&quot; &amp; strFileIn &amp; &quot;]&quot;
    End If
End With

WScript.Quit 0</code></pre></div>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2011-03-19T05:50:20Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=46382#p46382</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[VBS: Выборочное считывание текстового файла]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=46218#p46218" />
			<content type="html"><![CDATA[<p>Уважаемые коллеги.&nbsp; Помогите написать код , который считывает&nbsp; выборочно строки текстового файла. Количество строк в файле заранее неизвестно.Необходимо чтобы скрипт последовательно считывал строки пропуская в начале каждой новой строки 3 символа и допустим записывал результат&nbsp; в другой текстовый файл. Заранее благодарю за помощь.</p>]]></content>
			<author>
				<name><![CDATA[NAUN]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26223</uri>
			</author>
			<updated>2011-03-16T13:52:36Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=46218#p46218</id>
		</entry>
</feed>
