写入一些文本到文件, 然后从文件读取回内存(方法二)
; 示例: 这是个可运行脚本, 它写入一些文本到文件, 然后从文件读取回内存. ; 它提供了与 此 DllCall 示例 同样的功能. FileSelectFile, FileName, S16,, Create a new file: if (FileName = "") return file := FileOpen(FileName, "w") if !IsObject(file) { MsgBox Can't open "%FileName%" for writing. return } TestString := "This is a test string.`r`n" ; 通过这种方式写入内容到文件时, 要使用 `r`n 而不是 `n 来开始新行. file.Write(TestString) file.Close() ; 现在已经把内容写入文件了, 重新把它们读取回内存中. file := FileOpen(FileName, "r-d") ; 读取文件 ("r"), 共享除删除 ("-d") 外的所有访问权限 if !IsObject(file) { MsgBox Can't open "%FileName%" for reading. return } CharsToRead := StrLen(TestString) TestString := file.Read(CharsToRead) file.Close() MsgBox The following string was read from the file: %TestString%