GetScriptName のバックアップ差分(No.1)


  • 追加された行はこの色です。
  • 削除された行はこの色です。
#contents

* 概要 [#v88c8dde]

現在使用中の AVS ファイルの名前(フルパス)を取得する関数。関数の戻り値は、文字列(string 型)です。

ネタ元は、[[Get the current script filename - Doom9's Forum:http://forum.doom9.org/showthread.php?t=66627]] です。

* 作者 [#wc49f553]

-stickboy
-mf([[オリジナル版:http://forum.doom9.org/showthread.php?p=412930#post412930]])

* 関数 [#cbf923da]

[[Get the current script filename - Doom9's Forum:http://forum.doom9.org/showthread.php?p=413006#post413006]] より。

#code(nonumber){{
function GetScriptName()
{
    Try
    {
        assert(false)
    }
    Catch(err_msg)
    {
        err_msg = MidStr(err_msg, FindStr(err_msg, "(") + 1)
        filename = LeftStr(err_msg, StrLen(err_msg) - FindStr(RevStr(err_msg), ","))
        return filename
    }
}
}}

* 書式 [#ga1c404d]

#code(nonumber){{
GetScriptName()
}}

** 引数 [#p7a895ee]

-なし

* 使用例 [#v4042497]

#code(nonumber){{
AVISource("D:\AviSynth\test\example.avi") # ソース
this_script_name = GetScriptName() # AVS ファイルの名前を取得して、変数 this_script_name に代入
Subtitle(this_script_name) # Subtitle フィルタでファイル名を表示
}}

#ref(getscriptname_function_example.png)

画像ではモザイクがかかっていますが、ドライブ名やフォルダ名を含めたフルパスのファイル名を取得します。

なお、GetScriptName 関数の戻り値は文字列なので、上記の使用例は以下のようにもっと簡単に書くこともできます。

#code(nonumber){{
AVISource("D:\AviSynth\test\example.avi")
Subtitle(GetScriptName())
}}

* 備考 [#pdfb85c4]

-Doom9's Forum 関連スレッド
--[[Get the current script filename - Doom9's Forum:http://forum.doom9.org/showthread.php?t=66627]]