从一个 Dictionary 对象中删除一个主键,条目对。
object.Remove(key)
object
必选项。总是一个 Dictionary 对象的名称。
key
必选项。 key 与要从 Dictionary 对象中删除的主键,条目对相关联。
如果所指定的主键,条目对不存在,那么将导致一个错误。
下面这段代码说明了 Remove 方法的用法:
var a, d, i, s; //创建一些变量。d = new ActiveXObject("Scripting.Dictionary");d.Add ("a", "Athens"); //添加一些主键条目对。d.Add ("b", "Belgrade");d.Add ("c", "Cairo");...d.Remove("b"); //删除第二对主键条目对。
Add 方法 (Dictionary) | Exists 方法 | Items 方法 | Keys 方法 | RemoveAll 方法应用于: Dictionary 对象
RemoveAll 方法从一个 Dictionary 对象中删除所有的主键,条目对。
object.RemoveAll( )
其中 object 总是一个 Dictionary 对象的名称。
下面这段代码说明了 RemoveAll 方法的用法:
var a, d, i;//创建一些变量。d = new ActiveXObject("Scripting.Dictionary");d.Add ("a", "Athens");//添加一些主键和条目。d.Add ("b", "Belgrade");d.Add ("c", "Cairo");...d.RemoveAll( );//清除dictionary。
Add 方法 (Dictionary) | Exists 方法 | Items 方法 | Keys 方法 | Remove 方法应用于: Dictionary 对象
在读取 TextStream 文件时跳过指定个数的字符。
object.Skip(characters)
object
必选项。总是某个 TextStream 对象的名称。
characters
必选项。在读取文件时要跳过的字符个数。
被跳过的字符即被放弃。
下面的示例演示了Skip 方法的用法:
function SkipDemo() {var fso, f, r;var ForReading = 1, ForWriting = 2;fso = new ActiveXObject("Scripting.FileSystemObject")f = fso.OpenTextFile("c:\\testfile.txt", ForWriting, true);f.WriteLine("Hello world!");f.WriteLine("JScript is fun");f.Close();f = fso.OpenTextFile("c:\\testfile.txt", ForReading);f.Skip(6);r = f.ReadLine();return(r);}
Close 方法 | Read 方法 | ReadAll 方法 | ReadLine 方法 | SkipLine 方法 | Write 方法 | WriteLine 方法 | WriteBlankLines 方法应用于: TextStream 对象
在读取TextStream 文件时跳过下一行。
object.SkipLine( )
object 总是一个 TextStream 对象的名称。
下面的示例演示了SkipLine 方法的用法:
function SkipLineDemo() {var fso, f, rvar ForReading = 1, ForWriting = 2;fso = new ActiveXObject("Scripting.FileSystemObject")f = fso.OpenTextFile("c:\\testfile.txt", ForWriting, true)f.WriteLine("Hello world!");f.WriteLine("JScript is fun");f.Close();f = fso.OpenTextFile("c:\\testfile.txt", ForReading);f.SkipLine();r = f.ReadLine();return(r);}
Read 方法 | ReadAll 方法 | ReadLine 方法 | Skip 方法应用于: TextStream 对象
将给定的字符串写入到一个 TextStream 文件。
object.Write(string)
object
必选项。总是一个 TextStream 对象的名称。
string
必选项。要写入文件的文本。
给定的字符串在写入该文件时不会在字符串之间插入空格或字符。可以使用 WriteLine 方法来写入一个换行符或以换行符结束的字符串。
下面的示例演示了Write 方法的用法:
function WriteDemo() {var fso, f, rvar ForReading = 1, ForWriting = 2;fso = new ActiveXObject("Scripting.FileSystemObject")f = fso.OpenTextFile("c:\\testfile.txt", ForWriting, true)f.Write("Hello world!");f.Close();f = fso.OpenTextFile("c:\\testfile.txt", ForReading);r = f.ReadLine();return(r);}
WriteBlankLines 方法 | WriteLine 方法应用于: TextStream 对象
将指定数量的换行符写入到一个 TextStream 文件。
object.WriteBlankLines(lines)
object
必选项。总是一个 TextStream 对象的名称。
lines
必选项。要写入该文件的换行符的个数。
下面的示例演示了WriteBlankLines 方法的用法:
function WriteBlanksDemo() {var fso, f, r;var ForReading = 1, ForWriting = 2;fso = new ActiveXObject("Scripting.FileSystemObject");f = fso.OpenTextFile("c:\\testfile.txt", ForWriting, true);f.Write("Hello world!");f.WriteBlankLines(2);f.Write("JScript is fun!");f.Close();f = fso.OpenTextFile("c:\\testfile.txt", ForReading);r = f.ReadAll();return(r);}
Write 方法 | WriteLine 方法应用于: TextStream 对象
向 TextStream 文件中写入给定的字符串和一个换行符。
object.WriteLine([string])
object
必选项。总是一个 TextStream 对象的名称。
string
可选项。要写入该文件的文本。如果忽略该参数,则向该文件写入一个换行符。
下面的示例演示了WriteLine 方法的用法:
var fso, f;
fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.CreateTextFile("c:\\testfile.txt", true);
f.WriteLine("This is a test.");
f.Close();
Write 方法 | WriteBlankLines 方法应用于: TextStream 对象