Ok, thanks, this I understood. Now I still don't get the decision whether the script or the file is executed. There's that "init_scan" function; does it only execute if a file is loaded otherwise the "load_script" is used? (Sorry for my dumb questions but as I said C is rather confusing for me.)
In AllegroBASIC it's that simple (for now):
if (argc>1) {
if(mb_load_file(bas, argv[1]) == MB_FUNC_OK)
_alloc_data_seq();
mb_run(bas,true);
_free_data_seq();
}
else {
tinyfd_messageBox("No Script", "AllegroBASIC 0.6.5\nUsage: allegrobasic[.exe] script.bas", "ok", "error", 1);
}
And in PulsarLua the decision whether to use the script or the file, looks like this (Pascal is so much easier to read...):
if isbound = true then
begin
if luaL_dostring (L,PChar(prog))<>0 then
begin
//show if an error occured
Messagebox(1,'Error',lua_tostring (L,-1));
closeapplication;
halt;
end;
end
else
if (luaL_dofile(L, script))<>0 then
begin
//show if an error occured
Messagebox(1,'Error',lua_tostring (L,-1));
closeapplication;
halt;
end;
lua_close(L);
end.
("isbound" is a boolean which is filled at runtime - if I found out that the script is bound then it's true otherwise false.)