Adding characters to output of text-string

Moderator: leecollings

Post Reply
Toulon7559
Posts: 859
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: <2025
Location: Hengelo(Ov)/NL
Contact:

Adding characters to output of text-string

Post by Toulon7559 »

Translating the contents of the KNMI Weather-info for an application, (amongst others) I use following lua-script-line for generation of output

Code: Select all

file:write("$forecast = " .. summary1 .. ";\n") --forecast
A typical result today from that lua-script-line is

Code: Select all

$forecast = Zonnige perioden;
However, the application reading this textstring requires to see

Code: Select all

$forecast = "Zonnige perioden";
Simple question, but causing headache:
how to get those enclosing " into the string?
Have looked at lua.org, but not yet seen a suitable answer

In other words:
need to find a way to insert ASCII-character hex022 into the text-string coming from that lua-script-line.
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
User avatar
boum
Posts: 136
Joined: Friday 18 January 2019 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: France
Contact:

Re: Adding characters to output of text-string

Post by boum »

Either switch your double quotes to single quotes.
Or just escape the character:

Code: Select all

file:write("$forecast = \"" .. summary1 .. "\";\n") --forecast
Toulon7559
Posts: 859
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: <2025
Location: Hengelo(Ov)/NL
Contact:

Re: Adding characters to output of text-string

Post by Toulon7559 »

Thanks for the hint!
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest