If anyone has seen some recent threads I made on IDE/CreateEXE or Resource Files...
I have a working prototype of an IDE that can write (Writer.exe) a stream of data (just basic string for now) directly into a 2nd EXE (Reader.exe).. it appends the data to the end of the exe.... It works beautifully!
And FYI... This is not Fungus code... I have something else that is more inline with my goals.
NOTE: I am not making anything in particular, just doing a prototype to make sure I can read/write most formats into one file.
I build prototypes when learning stuff.
Now I am building the stream (string) that will be appended to the exe.
However, after I started coding I realized some things that could go wrong...
My data file can have these formats saved into it...
- bmp, jpg, png
- Icons
- Text
- Rtf
Each format may be different lengths
And I would be loading binary into controls, so conversion will be needed from the string
My file needs to be easy to write and read for flexibility sake.
Writing the data to the file is fine using just old-school saving. I am saving into a TXT file
This is a sample file...
This is a plain line text string
This is the 2nd plain line text string
500
This is the beginning of a Memo String
That has a line break and paragraph text That has a line break and paragraph text That has a line break and paragraph text That has a line break and paragraph text That has a line break and paragraph text That has a line break and paragraph text That has a line break and paragraph text That has a line break and paragraph text That has a line break and paragraph text That has a line break and paragraph text That has a line break and paragraph text That has a line break and paragraph text That has a line break and paragraph text That has a line break and paragraph text That has a line break and paragraph text
The
500 is the length of my Memo string.
I actually saved it in the file so I don't have to parse the data to figure it out.
However, when it comes to the block of text that has line breaks, I can't use ReadLn
So, I am trying to read an entire block.
I am keeping track of the Pos and length as i move through the file.
So, While the file is open, what is the Pascal way of getting block of string (using Length)??
Here is the code I am using to read the file...
procedure TForm1.Button3Click(Sender: TObject);
var
Pos: Single;
StrLength: Single;
X: String;
begin
Pos:= 0;
AssignFile(tfIn, fileName);
try
// Open the file for reading
reset(tfIn);
//edit box
readln(tfIn, s);
Pos:= Length(s);
Edit1.Text := s;
readln(tfIn, s);
Pos:= Pos + Length(s);
Edit2.Text := s
//Memo
//get str length for memo block
StrLength:= Length(s);
X:=SubStr(readln(tfIn, S,Pos,StrLength));
RichMemo1.Text := X;
Pos:= Pos + StrLength;
// Done so close the file
CloseFile(tfIn);
except
on E: EInOutError do
end;
end;
WHAT IS THE BEST... way to go about this?