Reputation: 313
Hi I am trying to get all this content in a string variable which I then used to create a text file
The problem is that it always fails when you use this code:
html: = '
<title> test </ title>
<STYLE type=text/css>
body, a: link {
background-color: black;
color: red;
Courier New;
cursor: crosshair;
font-size: small;
}
input, table.outset, table.bord, table, textarea, select, fieldset, td, tr {
font: normal 10px Verdana, Arial, Helvetica,
sans-serif;
background-color: black;
color: red;
border: 1px solid # 00FF0red0;
border-color: red
}
a: link, a: visited, a: active {
color: red;
font: normal 10px Verdana, Arial, Helvetica,
sans-serif;
text-decoration: none;
}
</ style>
';
What I have to do to make it work ?
Upvotes: 2
Views: 316
Reputation: 125620
You have to properly concatenate the string, using the +
string concatenation operator.
html: = '<title> test </ title>' + sLineBreak +
'<STYLE type=text/css>' + sLineBreak + sLineBreak +
'body, a: link {' + sLineBreak +
'background-color: black;' + sLineBreak +
'color: red;' + sLineBreak +
'Courier New;' + sLineBreak +
'cursor: crosshair;' + sLineBreak +
'font-size: small;' + sLineBreak +
'}'; // Keep going with the rest of your text
Or, simply use a TStringList
:
var
html: TStringList;
begin
html := TStringList.Create;
try
html.Add('<title> test </ title>');
html.Add('');
html.Add('<STYLE type=text/css>');
html.Add('body, a: link {');
html.Add('background-color: black');
html.Add('color: red;');
html.Add('Courier New;');
html.Add('cursor: crosshair;');
html.Add('font-size: small;');
html.Add('}'; // Keep going with the rest of your text
html.SaveToFile('YourFileName.html');
finally
html.Free;
end;
end;
Upvotes: 4