Import(handle, file_path, file_name)

grandMA3 ユーザマニュアル » プラグイン » Lua 関数 - Object API » Import(handle, file_path, file_name) Version 2.2

説明

Import 関数は、XML形式で記述されたオブジェクトをインポートします。

制限
インポートするファイルは、すでに存在している必要があります。
重要
Import は、確認ポップアップなしで、XMLファイルの内容をオブジェクトにマージします。

引数

  • handle:
    light_userdata 型のハンドルです。オブジェクトでコロン記法を用いる場合は省略できます(後述の例を参照)。
  • string:
    ファイルの場所へのパスを含む文字列です。
  • string:
    目的のファイルのファイル名を含む文字列です。

戻り値

  • boolean:
    インポートが成功したかどうかを示す boolean 値を返します。

この例では、XMLファイルの内容を選択されているシーケンスにインポートします。ファイル名は "MySelectedSequence" で、"../gma3_library/datapools/sequences" にあります。ファイルは、Export 関数の例を用いて作成できます。

Lua
return function()
--SelectedSequence() creates a handle to the selected sequence.
-- The imported object will be merged into this sequence.
local selectedSequence = SelectedSequence()
-- Check if there is a selected sequence - if not then exit the function.
if selectedSequence == nil then
ErrPrintf("The selected sequence could not be found.")
return
end
--The path is stored in a variable.
local path = GetPath(Enums.PathType.UserSequences)
--The actual import function.
local success = selectedSequence:Import(path, "mySelectedSequence.xml")
--Print some feedback.
if success then
Printf("The sequence is imported from: " .. path .. GetPathSeparator() .. "mySelectedSequence.xml")
else
ErrPrintf("The object could not be imported.")
end
end

関連するオブジェクト関数

Export - XMLテーブルをエクスポートするためるオブジェクト関数。