Tải bản đầy đủ (.pdf) (7 trang)

Giáo Trình How To Use AutoIt A Professional Manner part 32 pdf

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (78.1 KB, 7 trang )

recurse
1 = áp dụng cho tất cả thư mục con
0 = chỉ áp dụng chi file ở thư mục chỉ định (mặc định)

Return Value
Success:

Returns 1.
Failure:

Returns 0 nếu có bất kì lỗi nào.

Remarks
None.
Related
FileGetTime, FileGetAttrib, FileSetAttrib
Example

;change file.au3's "modified" timestamp to 1st Nov 2003 and current time
$var = FileSetTime("file.au3", "20031101")




Function Reference
FileWrite
ghi đoạn văn bane thêm vào cuối file.
FileWrite ( filehandle or "filename", "text" )
Parameters
filehandle handle file, giá trị đc trả lại bởi fileopen
text đoạn văn bản để ghi vào



Return Value
Success:

Returns 1.
Failure:

Returns 0 nếu file ko đc mở để ghi, file có thuộc tính chỉ đc đọc, hoặc file
ko thể ghi đè

Remarks

chú ý: tên file và handle file là khác nhau, tên file là đường dẫn tới file, còn file
handle là địa chỉ của file đc load vào trong bộ nhớ (Ram), ta ko thể dùng lẫn lộn
giữa 2 cái này, hàm nào yêu cầu cái gì thì ta truyền cái đó
Related
FileClose, FileOpen, FileRead, FileReadLine, FileWriteLine, Binary
Example

$file = FileOpen("test.txt", 1)

; Check if file opened for writing OK
If $file = -1 Then
MsgBox(0, "Error", "Unable to open file.")
Exit
EndIf

FileWrite($file, "Line1")
FileWrite($file, "Still Line1" & @CRLF)
FileWrite($file, "Line2")


FileClose($file)




Function Reference
FileWriteLine
ghi thêm dòng vào cuối file.
FileWriteLine ( filehandle or "filename", "text" )
Parameters
filehandle handle file, giá trị đc trả lại bởi fileopen
text
đoạn văn bản để ghi vào, nếu cuối text ko có kí tự xuống dòng thì sẽ
đc tự động thêm vào

Return Value
Success:

Returns 1.
Failure:

Returns 0 nếu file ko đc mở để ghi, file có thuộc tính chỉ đc đọc, hoặc file
ko thể ghi đè

Remarks
The text file must be opened in write mode or the FileWriteLine command will
fail.

If a filename is given rather than a file handle, the file will be opened and closed

during the function call. For parsing large text files this will be much slower than
using filehandles. However, filename will be created if it does not already exist.

Note: Do not mix filehandles and filenames, i.e., don't FileOpen a file and then use
a filename in this function. Either use filehandles or filenames in your routines, not
both.

When writing text AutoIt will write using ANSI by default. To write in Unicode
mode the file must be opened with FileOpen() and the relevant flags.

Written text cannot contain Chr(0) characters. The output is truncated. FileWrite
binary mode must be used to write such bizarre string. FileRead can reread such
FileWrite string.
Related
FileClose, FileOpen, FileRead, FileReadLine, FileWrite
Example

$file = FileOpen("test.txt", 1)

; Check if file opened for writing OK
If $file = -1 Then
MsgBox(0, "Error", "Unable to open file.")
Exit
EndIf

FileWriteLine($file, "Line1")
FileWriteLine($file, "Line2" & @CRLF)
FileWriteLine($file, "Line3")

FileClose($file)





Function Reference
IniDelete
xóa giá trị trong file .ini đc định dạng theo kiểu chuẩn
IniDelete ( "filename", "section" [, "key"] )
Parameters
filename đường dẫn
section tên vùng trong file .ini
key tên key

Return Value
Success:

Returns 1.
Failure:

Returns 0 nếu file ko tồn tại hoặc file "read only".

Remarks
định dạng chuẩn của file .ini như sau:
[SectionName]
Key=Value
Related
IniRead, IniWrite, IniReadSection, IniReadSectionNames, IniRenameSection,
IniWriteSection
Example


IniDelete("C:\Temp\myfile.ini", "section2", "key")




Function Reference
IniRead
đọc giá trị trong file .ini đc định dạng theo kiểu chuẩn
IniRead ( "filename", "section", "key", "default" )
Parameters
filename đường dẫn
section tên vùng
key tên key
default giá trị mặc định trả về nếu ko tìm thấy key

Return Value
Success:

trar lại chuỗi kí tự
Failure:

trả lại default

Remarks
định dạng chuẩn của file .ini như sau:
[SectionName]
Key=Value
Related
IniDelete, IniWrite, FileReadLine, IniReadSection, IniReadSectionNames,
IniRenameSection, IniWriteSection

Example

$var = IniRead("C:\Temp\myfile.ini", "section2", "key", "NotFound")
MsgBox(4096, "Result", $var)




Function Reference
IniReadSection
đọc tất cả key trong section
IniReadSection ( "filename", "section" )
Parameters
filename đường dẫn
section tên vùng

Return Value
Success:

trả lại mảng 2 chiều với $array[n][0] là key, $array[n][1] là giá trị
Failure:

Sets @error=1 nếu file ini ko tồn tại, hoặc section ko tồn tại

Remarks
định dạng chuẩn của file .ini như sau:
[SectionName]
Key=Value

số lượng phần tử đc lưu trong $array[0][0], nếu @error thì ko có mảng nào đc tạo

ra
Chỉ 32767 kí tự đầu tiên được đọc một section vì tính tương thích Win9x.
Related

×