Also: DO NOT PUT VERSION INFO IN A SIG. Sorry for shouting, but the problem is that as soon as you change your sig- because you've upgraded your system or changed compiler version- every time that somebody reads one of your messages they will see your new configuration, not the one that applied when you raised the issue. Worse, every time Google etc. or an AI scrapes the forum it will associate the problem with your new configuration, which is grossly unhelpful to anybody- quite possibly not a regular member of the forum or mailing lists- who reads about it in that way.
All very reasonable points. Though, as I pointed out to Zvoni, earlier, when I used to use Lazarus (and this forum) a lot, back in the late 2010's, no-one ever commented on posting style.
So by all means put something humorous in your sig, or make a social or political statement. But it IS NOT the place to put information on what compiler version etc. is associated with a problem being discussed.
I'll steer clear of political statements, I think ;0
Going back to where we were, it /would/ be useful if you could recreate the problem. But I'm bothered by this "vanished when I restarted Lazarus" aspect, which suggests that you might have stumbled upon some very odd cache misbehaviour or suchlike. Are you using any conditional compilation ($ifdef etc.) or include files in your code?
MarkMLl
It's really just a very straightforward console app...
program Search_Replace;
uses
SysUtils, Classes, StrUtils;
const
InputFilePath = 'OsmoseCategories.pas';
OutputFilePath = 'OsmoseCategories OUT.pas';
var
InputFileStream: TFileStream;
OutputFileStream: TFileStream;
StringStream: TStringStream;
Content: string;
LinesIn: TStringList;
i: Integer;
j: Integer;
Sub: string;
SubOut: string;
Commas: Integer;
begin
try
// Read input file into TStringStream
InputFileStream := TFileStream.Create(InputFilePath, fmOpenRead or fmShareDenyWrite);
try
StringStream := TStringStream.Create('');
try
StringStream.CopyFrom(InputFileStream, 0); // Copy entire file
Content := StringStream.DataString;
// Manipulate content
LinesIn := TStringList.Create;
try
LinesIn.Text := Content;
for i := 0 to LinesIn.Count - 1 do
begin
Sub := LinesIn[i];
SubOut := '';
Commas := 0;
if Sub[1] = ',' then
begin
SubOut := Sub;
end
else
begin
// In: 30,1,acid bass,aggressive + analog + distorted + stereo
// Out: 30, 1, 'acid bass', 'aggressive + analog + distorted + stereo'
for j := 1 to Length(Sub) do
begin
SubOut := SubOut + Sub[j];
if Sub[j] = ',' then
begin
Inc(Commas);
case Commas of
1: SubOut += ' ';
2: SubOut += ' "';
3: SubOut := Copy(SubOut, 1, Length(SubOut) - 1) + '", "'
else
;
end;
end;
end;
SubOut += '"';
end;
LinesIn[i] := SubOut;
WriteLn(SubOut);
end;
Content := LinesIn.Text;
finally
LinesIn.Free;
end;
// Write manipulated content to output file
OutputFileStream := TFileStream.Create(OutputFilePath, fmCreate);
try
StringStream.Position := 0;
StringStream.WriteString(Content);
OutputFileStream.CopyFrom(StringStream, 0);
WriteLn('File processing completed successfully.');
finally
OutputFileStream.Free;
end;
finally
StringStream.Free;
end;
finally
InputFileStream.Free;
end;
except
on E: Exception do
begin
WriteLn('An error occurred: ', E.Message);
end;
end;
end.
The input file is `OsmoseCategories.pas` (see attached) which, the observant will notice, is not currently a Pascal source file. All this text mangling is intended to turn it into a Pascal source file eventually
I stripped out the hard coded paths, but you may need to tweak the paths.