テキストファイル入出力

  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
  










  infoboard   管理者用   
このエントリーをはてなブックマークに追加





フリーフォントWEBサービス
SQLの窓WEBサービス

SQLの窓フリーソフト

素材

一般WEBツールリンク

SQLの窓

フリーソフト

JSライブラリ