DLLOneScriptLoadBuffer
函数 DLLOneScriptLoadBuffer 从内存缓冲区加载 OneScript 程序到指定任务。(适合动态生成脚本内容或从非文件源加载程序的场景。)
C/C++
ErrorCode DLLOneScriptLoadBuffer(INT_PTR hClientHandle, int taskId, const char* scriptContent, int scriptLength);
C#
Controller.Tasks[taskId].OneScript.LoadBuffer(content) — 从内存缓冲区加载脚本内容到指定任务。
参数
hClientHandle (INT_PTR)
客户端会话句柄,由 DLLSysConnect 获取。
taskId (int)
目标任务编号(1-indexed)。
scriptContent (const char*)
脚本内容字符串。
scriptLength (int)
*scriptContent 的字符数(不含终止 \0)。
返回值
返回 ErrorCode;NoError (0) 表示成功,ProgramError 表示编译错误,详见 SDK 发布头 ErrorCode.h。
示例
const char* code = "Print(\"hello\")\n";
DLLOneScriptLoadBuffer(handle, 1, code, (int)strlen(code));
DLLOneScriptRun(handle, 1);