# GetAvailableFileName

作者: toralf 最近更新时间: 20051112

This function returns the next free/available file name.

GetAvailableFileName( GivenFileName, GivenPath = "", StartID = 1 )
GetAvailableFileName_fast( GivenFileName, GivenPath = "", StartID = 1 )

关于函数的参数和返回值, 请参阅其源码或 此文档.

#### 备注

The documentation is part of authors original posting of this library.

关于此函数(集)的更新细节和注意事项, 请参见 AutoHotkey 论坛: http://www.autohotkey.com/forum/viewtopic.php?t=6297

#### 许可

不存在

#### 示例

    ; #Include GetAvailableFileName.ahk
    #NoEnv
    SendMode Input
    SetWorkingDir %A_ScriptDir%

    ;######################## Testing

    Eval( GetAvailableFileName( A_ScriptName ))      ; should be error
    Eval( GetAvailableFileName( "xyz.ahk" ))         ; ok
    Eval( GetAvailableFileName( "xy#z.ahk" ))        ; ok
    Eval( GetAvailableFileName( "x#y#z.ahk" ))       ; ok
    Eval( GetAvailableFileName( "xy##z.ahk" ))       ; ok
    Eval( GetAvailableFileName( "x#.#y##z.ahk" ))    ; ok
    Eval( GetAvailableFileName( "####.ahk" ))        ; ok
    Eval( GetAvailableFileName( "xy##z.ahk", "C:\" ))              ; ok
    Eval( GetAvailableFileName( "xy##z.ahk", "C:\Windows" ))       ; ok
    Eval( GetAvailableFileName( "xy##z.ahk", "C:\XYZ0125RET\" ))   ; should be error
    Eval( GetAvailableFileName( "xy##z.ahk", "", 5 ))              ; ok
    Eval( GetAvailableFileName( "xy##z.ahk", "", 115 ))            ; should be error
    Eval( GetAvailableFileName( "xy##z.ahk", "", 33 ))             ; ok
    Eval( GetAvailableFileName( "xy##z.ahk", "", 33.3 ))           ; ok
    Msgbox, % Eval("")                                             ;%
    Return

    Eval(FileName)
    {
      static MsgTxt
      If FileName = 0
        MsgTxt = %MsgTxt%Error: %ErrorLevel%`n`n
      Else
        MsgTxt = %MsgTxt%%FileName%`n`n
      Return  MsgTxt
    }