Download file real time - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: Download file real time (/showthread.php?tid=2998) |
Download file real time - Domoticatorino - 19.11.2020 Hi there, I am doing a script which writes in a CSV value and name of a list of object selected by a tag. Since the script is launched with a push button, I am wondering if It Is possibile download the file CSV directly on the browser. I mean such as trend log file push button export. Thanks as Always. Br. RE: Download file real time - admin - 20.11.2020 You can use .lp file to generate a CSV that will be sent to the user. First you need to attach an event to a button that will open .lp in a new window: Code: $(function() { Use this as a starting point for csv.lp: Code: <? RE: Download file real time - Domoticatorino - 20.11.2020 Thank you Admin. Can I do that in Mosaico as well? Br RE: Download file real time - Daniel - 20.11.2020 Mosaic does not have custom js but maybe you could do something in the html widget. RE: Download file real time - Domoticatorino - 24.11.2020 (20.11.2020, 06:57)admin Wrote: You can use .lp file to generate a CSV that will be sent to the user. Hi admin, sorry but do not understand program language above. If I use <? LM inform me "Lua syntax error at line 1: unexpected symbol near '<'". Thanks. RE: Download file real time - admin - 24.11.2020 .lp file is not a script, it's a Lua file that only the web server can run. It should be uploaded via FTP to the user directory using apps username. If the file is named csv.lp then the URL will be http://LM_IP/user/csv.lp RE: Download file real time - Domoticatorino - 24.11.2020 (24.11.2020, 07:34)admin Wrote: .lp file is not a script, it's a Lua file that only the web server can run. It should be uploaded via FTP to the user directory using apps username. If the file is named csv.lp then the URL will be http://LM_IP/user/csv.lp Code: <? I generate file as above without success. Is it correct the procedure? Thanks. RE: Download file real time - admin - 24.11.2020 Try this: Code: <? RE: Download file real time - Domoticatorino - 24.11.2020 (24.11.2020, 09:16)admin Wrote: Try this: Thank you very much Admin, but unfortunately when I launch the script on the visu I receive response from http://192.168.1.10/user/csv.lp that it is not possible reach the web site. The script is correct and I cannot identify the problem. Thanks. BR RE: Download file real time - admin - 24.11.2020 There were some errors in the script, this should work: Code: <? RE: Download file real time - Domoticatorino - 24.11.2020 (24.11.2020, 09:56)admin Wrote: There were some errors in the script, this should work: FANTASTIC ADMIN!! THANK YOU VERY MUCH. I would like only to clerify a thing. string.gsub(tostring(obj.value), ".", ",") With this above I would like to replace dot with comma in the number. I do not know why but he replace all the number with ",". Hence 23.88 became ,,,,, What is the reason? Thanks. RE: Download file real time - admin - 24.11.2020 dot is a special symbol that is treated as "any character" by the gsub. You need to escape it like this: Code: value = string.gsub(tostring(obj.value), "%.", ",") RE: Download file real time - Domoticatorino - 24.11.2020 (24.11.2020, 10:33)admin Wrote: dot is a special symbol that is treated as "any character" by the gsub. You need to escape it like this: Yes I know. I already use ";" in fact the format of the file in excel as well is perfect. Great Job. Thanks. Now I work to download file from Mosaic as well. Thanks. |