<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; VBS: Выборочное считывание текстового файла]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=5591</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=5591&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «VBS: Выборочное считывание текстового файла».]]></description>
		<lastBuildDate>Sun, 12 Jun 2011 10:54:09 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: VBS: Выборочное считывание текстового файла]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=49091#p49091</link>
			<description><![CDATA[<p>ну уже с предыдущим и сам разобрался, но теперь надо сделать еще так, чтобы показывалось количество строк без этих символов</p>]]></description>
			<author><![CDATA[null@example.com (president100)]]></author>
			<pubDate>Sun, 12 Jun 2011 10:54:09 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=49091#p49091</guid>
		</item>
		<item>
			<title><![CDATA[Re: VBS: Выборочное считывание текстового файла]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=49086#p49086</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (Alexey)]]></author>
			<pubDate>Sat, 11 Jun 2011 06:43:57 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=49086#p49086</guid>
		</item>
		<item>
			<title><![CDATA[Re: VBS: Выборочное считывание текстового файла]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=49085#p49085</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (president100)]]></author>
			<pubDate>Sat, 11 Jun 2011 06:29:36 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=49085#p49085</guid>
		</item>
		<item>
			<title><![CDATA[Re: VBS: Выборочное считывание текстового файла]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=49073#p49073</link>
			<description><![CDATA[<div class="quotebox"><cite>president100 пишет:</cite><blockquote><p>а как например сделать, чтоб скрипт не считывал из файлов строки, начинающиеся на #, ! и | ?</p></blockquote></div><p><strong>Никак</strong>. Чтобы понять, что строка начинается с искомых символов, надо её (строку) считать. А далее действовать по усмотрению: <em>если строка начинается с символа(ов), то ...</em></p>]]></description>
			<author><![CDATA[null@example.com (Rumata)]]></author>
			<pubDate>Fri, 10 Jun 2011 18:56:32 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=49073#p49073</guid>
		</item>
		<item>
			<title><![CDATA[Re: VBS: Выборочное считывание текстового файла]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=49069#p49069</link>
			<description><![CDATA[<p>а как например сделать, чтоб скрипт не считывал из файлов строки, начинающиеся на #, ! и | ?</p>]]></description>
			<author><![CDATA[null@example.com (president100)]]></author>
			<pubDate>Fri, 10 Jun 2011 17:23:37 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=49069#p49069</guid>
		</item>
		<item>
			<title><![CDATA[Re: VBS: Выборочное считывание текстового файла]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=47435#p47435</link>
			<description><![CDATA[<p>Огромное списибо....всё подошло</p>]]></description>
			<author><![CDATA[null@example.com (NAUN)]]></author>
			<pubDate>Thu, 07 Apr 2011 11:46:56 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=47435#p47435</guid>
		</item>
		<item>
			<title><![CDATA[Re: VBS: Выборочное считывание текстового файла]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=46382#p46382</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (alexii)]]></author>
			<pubDate>Sat, 19 Mar 2011 05:50:20 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=46382#p46382</guid>
		</item>
		<item>
			<title><![CDATA[VBS: Выборочное считывание текстового файла]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=46218#p46218</link>
			<description><![CDATA[<p>Уважаемые коллеги.&nbsp; Помогите написать код , который считывает&nbsp; выборочно строки текстового файла. Количество строк в файле заранее неизвестно.Необходимо чтобы скрипт последовательно считывал строки пропуская в начале каждой новой строки 3 символа и допустим записывал результат&nbsp; в другой текстовый файл. Заранее благодарю за помощь.</p>]]></description>
			<author><![CDATA[null@example.com (NAUN)]]></author>
			<pubDate>Wed, 16 Mar 2011 13:52:36 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=46218#p46218</guid>
		</item>
	</channel>
</rss>
