It is currently April 18th, 2024, 6:52 am
[BUG/Suggestion]Replace \ with \\ when using built-in path variables in Inline Lua
-
- Rainmeter Sage
- Posts: 1399
- Joined: April 24th, 2021, 8:13 pm
[BUG/Suggestion]Replace \ with \\ when using built-in path variables in Inline Lua
I was trying to take an path as an argument for a lua function and I wanted to use [#ROOTCONFIGPATH]. But lua doesn't read single \. So if it is possible to repalce single \ by double \\ of built-in path variables before sending it to lua would be good. I know the work around but it would be good if it's done automatically.
from the Realm of Death
-
- Rainmeter Sage
- Posts: 1399
- Joined: April 24th, 2021, 8:13 pm
Re: [BUG/Suggestion]Replace \ with \\ when using built-in path variables in Inline Lua
I just wanted to bring it to the front. Is this possible?death.crafter wrote: ↑June 3rd, 2021, 10:38 am I was trying to take an path as an argument for a lua function and I wanted to use [#ROOTCONFIGPATH]. But lua doesn't read single \. So if it is possible to repalce single \ by double \\ of built-in path variables before sending it to lua would be good. I know the work around but it would be good if it's done automatically.
from the Realm of Death
-
- Developer
- Posts: 22629
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: [BUG/Suggestion]Replace \ with \\ when using built-in path variables in Inline Lua
I'm just not sure I agree with it. Yes, there are times when you pass a string to Lua and the nature of the function you use it in sees it as an "expression" that will treat the \ character as an escape, but there are just as many times, probably a lot more, when it doesn't, and forcing in \\ would break things. It's not hard to deal with really, and I'm not sure there is a one-size-fits-all answer to this.death.crafter wrote: ↑June 10th, 2021, 3:25 pm I just wanted to bring it to the front. Is this possible?
If you have Lua like this:
Code: Select all
function readFile(arg)
file = io.open(arg)
fileTxt = file:read('*all')
file:close()
return fileTxt
end
-
- Rainmeter Sage
- Posts: 1399
- Joined: April 24th, 2021, 8:13 pm
Re: [BUG/Suggestion]Replace \ with \\ when using built-in path variables in Inline Lua
Ahh I see. Actually if you look at my skin here, I have to use inline lua to take paths and configs. This is fine Ig. Thanks for the reply.jsmorley wrote: ↑June 10th, 2021, 3:29 pm I'm just not sure I agree with it. Yes, there are times when you pass a string to Lua and the nature of the function you use it in sees it as an "expression" that will treat the \ character as an escape, but there are just as many times, probably a lot more, when it doesn't, and forcing in \\ would break things. It's not hard to deal with really, and I'm not sure there is a one-size-fits-all answer to this.
If you have Lua like this:
It will work perfect well with a call like [&LuaMeasure:readFile('#CURRENTPATH#myFile.txt')]. Forcing \\ into the resolution of #CURRENTPATH# before sending it to Lua would break this.Code: Select all
function readFile(arg) file = io.open(arg) fileTxt = file:read('*all') file:close() SKIN:Bang('!SetOption', 'MeterFile', 'Text', fileTxt) end
from the Realm of Death