FileAppend
実行制御 | GUI表示 | 演算・変数 | メモリ・DLL操作 | 文字列操作 |
キーボード | マウス | シェル | ウィンドウ | ウィンドウグループ
ステータスバー | コントロール | サウンド | ファイル | INIファイル |
レジストリ | 環境変数 | AutoHotkey | その他 | 設定関係 | オブジェクト
FileAppend[編集]
テキストファイルに書き加える。ファイルが存在しなければ作成される。
FileAppend [, Text, Filename[, Encoding]]
Parameters[編集]
引数名 | 説明 |
---|---|
Text | 書き加えるテキスト。 空の新規ファイルを作成したい場合は、この引数を空にする。 |
Filename | 書き加える先のファイル名。 相対パスで指定した場合は、%A_WorkingDir%を基準としたパスとなる。 先頭に * をつけると、バイナリモードでの処理となり、改行コードの自動変換が行われない。
標準出力(STDOUT): ファイル名に「 "%ProgramFiles%\AutoHotkey\AutoHotkey.exe" "My Script.ahk" > "Error Log.txt" しかし標準出力機能は、コマンドプロンプトでリダイレクトやパイプを用いたコマンドを発行したときのように、 明らかに標準出力を使うというシーンでしか有効とはならない。 "%ProgramFiles%\AutoHotkey\AutoHotkey.exe" "My Script.ahk" |more For /F "tokens=*" %L in ('""%ProgramFiles%\AutoHotkey\AutoHotkey.exe" "My Script .ahk""') do @Echo %L |
Encoding | AHKL [AHK_L 42+]: 書き込むエンコーディングを指定する。未指定時はFileEncodingで指定したものに従う。 |
ErrorLevel[編集]
成功時は 0
、失敗時は 1
。
AHKL [L55+] A_LastError にOSのGetLastError()関数を呼び出した結果を格納。
AHKL [v1.1.04+] このコマンドは失敗した場合に例外をスローすることができる。詳細は実行時エラーを参照。
Related[編集]
FileRead, file-reading loop, FileReadLine, IniWrite, FileDelete
AHKL FileEncoding, FileOpen(), A_FileEncoding
Example(s)[編集]
FileAppend, Another line.`n, C:\My Documents\Test.txt
; The following example uses a continuation section to enhance readability and maintainability:
FileAppend,
(
A line of text.
By default, the hard carriage return (Enter) between the previous line and this one will be written to the file.
This line is indented with a tab; by default, that tab will also be written to the file.
Variable references such as %Var% are expanded by default.
), C:\My File.txt
; The following example demonstrates how to automate FTP uploading using the operating
; system's built-in FTP command. This script has been tested on Windows XP and 98se.
FTPCommandFile = %A_ScriptDir%\FTPCommands.txt FTPLogFile = %A_ScriptDir%\FTPLog.txt FileDelete %FTPCommandFile%; In case previous run was terminated prematurely.
FileAppend, ( open host.domain.com username password binary cd htdocs put %VarContainingNameOfTargetFile% delete SomeOtherFile.html rename OldFileName.html NewFileName.html ls -l quit ), %FTPCommandFile% RunWait %comspec% /c ftp.exe -s:"%FTPCommandFile%" >"%FTPLogFile%" FileDelete %FTPCommandFile%; Delete for security reasons.
Run %FTPLogFile%; Display the log for review.