テキストファイル入出力
  VBScript + BatchHelper オブジェクト



CreateObject は、WSH(.vbs or .wsf) では Wscript.CreateObject を使用し、
ASP では Server.CreateObject を使用します。

※ IE( 含む HTA ) 上で動かす場合は、CreateObject のみ

TextIo.vbs :
エクスプローラからダブルクリックするか、cscript.exe TextIo.vbs 、または wscript.exe TextIo.vbs


  
' **********************************************************
' オブジェクト作成
' **********************************************************
Set Fs = CreateObject( "Scripting.FileSystemObject" )
Set Lbox = CreateObject( "Lbox.BatchHelper" )

' **********************************************************
' ターゲット ファイル
' **********************************************************
InFile = Lbox.OpenFileName()
if InFile = "" then
	Lbox.MsgOk( "入力ファイル選択でキャンセルされました" )
	Wscript.Quit
end if
OutFile = Lbox.SaveFileName()
if OutFile = "" then
	Lbox.MsgOk( "出力ファイル選択でキャンセルされました" )
	Wscript.Quit
end if

' **********************************************************
' ファイルオープン
' **********************************************************
on error resume next
Set InObj = Fs.OpenTextFile( InFile, 1 )
if Err.Number <> 0 then
	Lbox.MsgOk( Err.Description )
	Wscript.Quit
end if
on error goto 0
Set OutObj = Fs.OpenTextFile( OutFile, 2, True )

' **********************************************************
' 処理
' **********************************************************
Do While not InObj.AtEndOfStream
	Buffer = InObj.ReadLine
	OutObj.WriteLine Buffer
Loop

' **********************************************************
' ファイルクローズ
' **********************************************************
OutObj.Close
InObj.Close
  












   home    create:2005/05/03  update:2013/02/28   InfoBoard Version 1.00 (Perl).




HOME : SQLの窓
インデックストップ
技術情報セクション T
技術情報セクション U
技術情報セクション V : ソース掲示板

外部セクション T : logical error
手書きブログ専用・カスタムパレットツール