Forum > Editor
How to pass multiple lines of text to a variable in the easiest way?
loaded:
Hi All,
Here's how I'm assigning multiple lines of text to a variable of type String.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---var kml:String='<?xml version="1.0" encoding="UTF-8"?>'+ '<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">'+ '<Document>';
Similarly, I use {} to comment multiple lines. Sample ;
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---{<?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom"> <Document>}
Now my aim is; I want to be able to transfer a text containing multiple lines to a String variable, even if it contains single quotation marks ', without making any corrections or additions, such as the text inside the {} marks above, is this possible? Or is there an easier way? If you can help it would be greatly appreciated. Respects.
Jurassic Pork:
hello,
you can try to use the macroEditor with the multlineStr Macro (see here)
you paste your multiline text in your code and launch the macro ( click on the attachment to see animation).
Friendly, J.P
loaded:
Jurassic Pork, thank you very much for your hard work. If I can't find one step easier, I'll use this one.
Kays:
--- Quote from: loaded on September 21, 2021, 03:57:43 pm ---[…] I want to be able to transfer a text containing multiple lines to a String variable, even if it contains single quotation marks ', without making any corrections or additions, […]
--- End quote ---
I myself tend to forget these tools, but the FPC is shipped with data2inc(1) and bin2obj.
--- Code: Bash [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---bin2obj -a -c head head.xmlThis will require support for and make a typed “constant” which actually is a variable.
loaded:
Thank you very much for your answer, brother Kays, but I am not smart enough to understand what you wrote. I would appreciate it if you could be a little more descriptive.
Navigation
[0] Message Index
[#] Next page