-
-
-
method:CreateTextFile ( filename, rewrite, type )
return type:Object
content:ใช้สร้างออปเจ็ค TextStream
example:Set fsystem = CreateObject ( “Scripting.FileSystemObject” )
Set tstream = fsystem.CreateTextFile ( “bamboo.txt”, true, false )
comment:rewrite คือถ้ากำหนด true หมายถึงถ้ามีไฟล์นั้นอยู่แล้วให้สร้างทับเลย
type คือถ้ากำหนด true หมายถึงใช้ Unicode ถ้ากำหนด false หมายถึงใช้ ascii
-
method:OpenTextFile ( filename, typework, new, typeopen )
return type:Object
content:ใช้สร้างออปเจ็ค TextStream
example:Set fsystem = CreateObject ( “Scripting.FileSystemObject” )
Set tstream = fsystem.OpenTextFile ( “bamboo.txt”, 2, true, 0 )
comment:typework คือ 1 หมายถึงอ่านอย่างเดียว, 2 หมายถึง แก้ไขไฟล์ได้, 8 หมายถึง เพิ่มข้อมูล
new คือถ้ากำหนด true หมายถึงถ้าไม่มีไฟล์นั้นอยู่ให้สร้างใหม่เลย
typeopen คือ -2 คือเปิดแบบ default (ตามไฟล์), -1 คือเปิดแบบ Unicode, 0 คือเปิดแบบ ascii
-
property:Line
return type:Number
content:ใช้คืนค่าตำแหน่งของแถว ที่ cursor ชี้อยู่ (นับจากต้นไฟล์)
example:Set fsystem = CreateObject ( “Scripting.FileSystemObject” )
Set tstream = fsystem.OpenTextFile ( “bamboo.txt”, 2, true, 0 )
Dim position_line = tstream.Line
-
property:Column
return type:Number
content:ใช้คืนค่าตำแหน่งของคอลัมน์ ที่ cursor ชี้อยู่ (นับจากต้นไฟล์)
example:Set fsystem = CreateObject ( “Scripting.FileSystemObject” )
Set tstream = fsystem.OpenTextFile ( “panda.txt”, 2, true, 0 )
Dim position_column = tstream.Column
-
property:AtEndOfStream
return type:boolean
content:ตรวจสอบว่าตำแหน่ง Cursor เกินจุดสิ้นสุดของไฟล์หรือยัง (true = เกินแล้ว)
example:Set fsystem = CreateObject ( “Scripting.FileSystemObject” )
Set tstream = fsystem.OpenTextFile ( “bamboo.txt”, 2, true, 0 )
if ( tstream.AtEndOfStream )
{
tstream.Close
}
-
property:AtEndOfLine
return type:boolean
content:ตรวจสอบว่าตำแหน่ง Cursor เกินจุดสิ้นสุดของบรรทัดหรือยัง (true = เกินแล้ว)
example:Set fsystem = CreateObject ( “Scripting.FileSystemObject” )
Set tstream = fsystem.OpenTextFile ( “bamboo.txt”, 2, true, 0 )
if ( tstream.AtEndOfLine )
{
tstream.Close
}
-
property:Read ( num_char )
return type:String
content:ใช้อ่านข้อมูลจากไฟล์ตาม จำนวนตัวอักษร ที่กำหนด
example:Set fsystem = CreateObject ( “Scripting.FileSystemObject” )
Set tstream = fsystem.OpenTextFile ( “bamboo.txt”, 2, true, 0 )
Dim data = tstream.Read ( 10 )
-
property:ReadLine
return type:String
content:ใช้อ่านข้อมูลจากไฟล์ ครั้งละ 1 บรรทัด
example:Set fsystem = CreateObject ( “Scripting.FileSystemObject” )
Set tstream = fsystem.OpenTextFile ( “bamboo.txt”, 2, true, 0 )
Dim data = tstream.ReadLine
-
property:ReadAll
return type:String
content:ใช้อ่านข้อมูลจากไฟล์ โดยอ่านทั้งหมด
example:Set fsystem = CreateObject ( “Scripting.FileSystemObject” )
Set tstream = fsystem.OpenTextFile ( “bamboo.txt”, 2, true, 0 )
Dim data = tstream.ReadAll
-
property:Write ( data )
return type:void
content:ใช้เขียนข้อมูลลงไฟล์
example:Set fsystem = CreateObject ( “Scripting.FileSystemObject” )
Set tstream = fsystem.OpenTextFile ( “bamboo.txt”, 2, true, 0 )
tstream.Write ( "Welcome” )
tstream.Write ( "BambooLabCode” )
-
property:WriteLine ( data )
return type:void
content:ใช้เขียนข้อมูลลงไฟล์ แล้วเริ่มต้นบรรทัดใหม่หลังจากเขียนเสร็จ
example:Set fsystem = CreateObject ( “Scripting.FileSystemObject” )
Set tstream = fsystem.OpenTextFile ( “bamboo.txt”, 2, true, 0 )
tstream.WriteLine ( “Welcome” )
tstream.WriteLine ( “BambooLabcode” )
-
property:WriteBlankLines ( num_line )
return type:void
content:ใช้เขียนข้อมูลลงไฟล์ โดยเขียนบรรทัดว่าง (เว้นบรรทัด)
example:Set fsystem = CreateObject ( “Scripting.FileSystemObject” )
Set tstream = fsystem.OpenTextFile ( “bamboo.txt”, 2, true, 0 )
tstream.WriteBlankLines ( 3 )
-
method:Skip ( num_char )
return type:void
content:ใช้ข้ามข้อมูล ตามจำนวนตัวอักษรที่กำหนด
example:Set fsystem = CreateObject ( “Scripting.FileSystemObject” )
Set tstream = fsystem.OpenTextFile ( “bamboo.txt”, 2, true, 0 )
tstream.Skip ( 5 )
-
property:SkipLine
return type:void
content:ใช้ข้ามข้อมูล จำนวน 1 บรรทัด
example:Set fsystem = CreateObject ( “Scripting.FileSystemObject” )
Set tstream = fsystem.OpenTextFile ( “bamboo.txt”, 2, true, 0 )
tstream.SkipLine
-
property:FileExists ( filename )
return type:boolean
content:ใช้ตรวจสอบว่า ชื่อไฟล์ที่กำหนดมีอยู่แล้วหรือไม่ (true = มีแล้ว)
example:Set fsystem = CreateObject ( “Scripting.FileSystemObject” )
if ( fsystem.FileExists ( “bamboo.txt” ) )
{
tstream.WriteLine ( “Welcome” )
tstream.WriteLine ( “BambooLabcode” )
}
-
property:Close
return type:void
content:ใช้ปิดไฟล์
example:Set fsystem = CreateObject ( “Scripting.FileSystemObject” )
Set tstream = fsystem.OpenTextFile ( “bamboo.txt”, 2, true, 0 )
tstream.Close
-
method:HTMLEncode ( data_html )
return type:String
content:ใช้แสดงข้อมูลในรูปแบบที่มี Tag HTML
example:Set fsystem = CreateObject ( “Scripting.FileSystemObject” )
Set tstream = fsystem.OpenTextFile ( “bamboo.txt”, 2, true, 0 )
Dim data_encode = Server.HTMLEncode ( “<b>ยินดีต้อนรับ</b>” )
Response.Write data_encode
Response.Write “<b>ยินดีต้อนรับ</b>”