I have those 3 functions in the C file and I commented out the “cberror_message” section, but nothing happens when I get an error except the app crashes. There’s so much stuff already in the file that looks like it’s about debugging, I wonder if any of it is interfering somehow. Stuff like this: static int cbtraceback (lua_State *L) { lua_getfield(L, LUA_GLOBALSINDEX, "debug"); if (!lua_istable(L, -1)) { lua_pop(L, 1); return 1; } lua_getfield(L, -1, "traceback"); if (!lua_isfunction(L, -1)) { lua_pop(L, 2); return 1; } lua_pushvalue(L, 1); /* pass error message */ lua_pushinteger(L, 2); /* skip this function and traceback */ lua_call(L, 2, 1); /* call debug.traceback */ return 1; } I don’t know what to do. I tried making a test of a simple Lua script embedded in C (using scripts from this: https://lucasklassmann.com/blog/2019-02-02-how-to-embeddeding-lua-in-c/#starting-lua-vm ) and then I was going to put those 3 functions into it to see if I could get the error console to appear (which would mean that the problem was with the code itself rather than something else), but I can’t get the test script to compile. > By “reuse” the console, are you advising that I use the original, outdated one (iuplua5.exe) that doesn’t need .dll’s, or can I use iuplua51.exe? No. Reuse the executable without recompiling it from source code. > Are those functions called anywhere or are they triggered automatically? Called inside IUP, but they are exported also in the DLL. > From the description, it sounds like “iup._ERRORMESSAGE(msg)” triggers automatically and shows a dialog with the error info. Is that true? Yes. If you provoke an error you will see that dialog. So, your function can fully replace that dialog. > If you want to reuse the IupLua Console and just replace the error handling, you can replace the iup._ERRORMESSAGE(msg) function. See IUP / Guide / Lua Binding / IupLua Advanced. Are there any example scripts showing this setup? I checked the site, but didn’t find anything. The only instance of _ERRORMESSAGE is formatted like this, so I don’t know how to replace it or what to replace it with: static void cberror_message(lua_State *L, const char *msg) { lua_getglobal(L, "iup"); lua_pushstring(L, "_ERRORMESSAGE"); lua_gettable(L, -2); lua_remove(L, -2); if(lua_isnil(L, -1)) { fprintf(stderr, "%s\n", msg); /* Panic mode */ fflush(stderr); return; } lua_pushstring(L, msg); lua_call(L, 1, 0); } // Then the function is called in the next function: --------------------------------------- static int cbreport (lua_State *L, int status) { if (status && !lua_isnil(L, -1)) { const char *msg = lua_tostring(L, -1); if (msg == NULL) msg = "(error with no message)"; cberror_message(L, msg); print_message(msg); lua_pop(L, 1); } return status; } By “reuse” the console, are you advising that I use the original, outdated one (iuplua5.exe) that doesn’t need .dll’s, or can I use iuplua51.exe? I went to the Advanced page and tried adding those lines to the file, above cberror_message… int iuplua_dofile(lua_State *L, const char *filename); int iuplua_dostring(lua_State *L, const char *string, const char *chunk_name); int iuplua_dobuffer(lua_State *L, const char *string, int len, const char *chunk_name); …but that didn’t work. Are those functions called anywhere or are they triggered automatically? From the description, it sounds like “iup._ERRORMESSAGE(msg)” triggers automatically and shows a dialog with the error info. Is that true? If you want to reuse the IupLua Console and just replace the error handling, you can replace the iup._ERRORMESSAGE(msg) function. See IUP / Guide / Lua Binding / IupLua Advanced. I put the .dll files in my source folder with iuplua51.exe and can now open the console. I moved “console.loh” out of the folder and commented out-- static void iuplua_input (lua_State *L) { #include "console.loh" } --in the C file, then recompiled the .exe. I put an error into a Lua script and when I used the original app version, it triggered the error message like it should, but when I put the same error into the updated version, the app just closes. I tried replacing the include in the C file with "lua_dofile(L,"../obj/iuplua51/console.lo");" and also tried "luaL_dofile(L,"../obj/iuplua51/console.lo");" but it didn't work. Was that the wrong code, or is there something else I need to change? > I downloaded the packages for IUP 3.30 and Lua 5.1, but when I copy iuplua51.exe to my app’s source folder, I get an error when I try to open the console there. Is it because it’s not in the same folder as the .dll files? Originally, the app came with iuplua5.exe and there were no .dll files with it, but if I double click on it, that .exe opens up just fine. Yes, the console uses DLLs a few years now... Just copy the DLLs along with the exe > Do I need to get bin2c and make a new .loh (I don’t know anything about those) or can I just remove the old console.loh and put “lua_dofile(L,"../obj/iuplua5/console.lo");” in the C file? > I don’t have a file called “console.lo” so I don’t know where I’d set the directory path. There’s a bunch of code in the C file related to debug and error messages. Would I have to change anything there so it knows to use iuplua51.exe instead? No. These files were used during the build. They are embedded in the executable. > I do have an idea for a feature for that— It would be useful if there was an option to output the code with indices instead of RGBA values so the colors can be set dynamically. For example, I made some icons that show what a user’s color choices look like together, which is updated when a color picker is used. As a workaround, I chose unique RGBA values for each of my original image’s 3 colors, which made it easy to do a search-and-replace on the IupView-generated Lua code in order to change RGBA into indices. The generated code will have indices if your input image is a 256 color image. When importing 32 bpp images the generated images will follow their bpp. You updated from a very old IUP version. I guess you will find several differences like these. I downloaded the packages for IUP 3.30 and Lua 5.1, but when I copy iuplua51.exe to my app’s source folder, I get an error when I try to open the console there. Is it because it’s not in the same folder as the .dll files? Originally, the app came with iuplua5.exe and there were no .dll files with it, but if I double click on it, that .exe opens up just fine. I found a .loh file in the source folder that says: /* code automatically generated by bin2c -- DO NOT EDIT */ { /* #include'ing this file in a C program is equivalent to calling lua_dofile(L,"../obj/iuplua5/console.lo"); */ /* ../obj/iuplua5/console.lo */ Do I need to get bin2c and make a new .loh (I don’t know anything about those) or can I just remove the old console.loh and put “lua_dofile(L,"../obj/iuplua5/console.lo");” in the C file? I don’t have a file called “console.lo” so I don’t know where I’d set the directory path. There’s a bunch of code in the C file related to debug and error messages. Would I have to change anything there so it knows to use iuplua51.exe instead? Speaking of the Tools package, I’m glad to see that IupView is still available. The link in the “Simple Paint” tutorial was broken and I didn’t know where to find it other than buried in the “Lua for Windows” files. I do have an idea for a feature for that— It would be useful if there was an option to output the code with indices instead of RGBA values so the colors can be set dynamically. For example, I made some icons that show what a user’s color choices look like together, which is updated when a color picker is used. As a workaround, I chose unique RGBA values for each of my original image’s 3 colors, which made it easy to do a search-and-replace on the IupView-generated Lua code in order to change RGBA into indices. Thanks, Kaz The latest version is included in the latest "Tools" package in the Downloads. Latest source code is on SVN. I’ve been working on updating an app that used the “iuplua5.exe” stand-alone interpreter so if the app crashes, an error message pops up. Since I can’t figure out how to get debugging to work for it (it’s several Lua scripts and 1 C script), I’d like to find out if there’s a way to at least get error messages to work. Is there an updated version of that .exe anywhere? Is it even needed? I noticed that on this page (https://www.tecgraf.puc-rio.br/iup/en/iuplua_adv.html) it says: "In C to improve the error report, use the following functions to execute Lua code: .. These functions mimics the implementation in the standalone interpreter for Lua 5, that displays the error message followed by the stack." Does that mean if you put those lines somewhere, an error pop up will appear if the app crashes?
_______________________________________________ Iup-users mailing list Iup-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/iup-users
_______________________________________________ Iup-users mailing list Iup-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/iup-users
_______________________________________________ Iup-users mailing list Iup-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/iup-users
_______________________________________________ Iup-users mailing list Iup-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/iup-users
|