0
I am trying to display an image when loading a Form, but the command needs to come from an external file. txt (or a string that will store this existing command in .txt). I can show the lines with Showmessage, that way:
procedure TFrmAlbum.FormShow(Sender: TObject);
var
Achar : TStringList;
j : Integer;
img : String;
begin
Achar := TStringList.Create;
Try
Achar.LoadFromFile('images.txt');
for j := 0 to Achar.Count-1 do
begin
ShowMessage(Achar[j]);
end;
Finally
Achar.Free;
End;
end;
What I want is some command I can use instead of Showmessage for instead of showing lines, run them. Do you have how to do this?
Edit1: I don’t know if it will help, but the command lines in . txt, which should be interpreted by the program are like these:
Image1.Picture.Bitmap.LoadFromResourceName(HInstance, 'Bitmap_1');
Image2.Picture.Bitmap.LoadFromResourceName(HInstance, 'Bitmap_2');
Run an external file code? I find it difficult since Delphi is compiled and not interpreted.
– Jhonny Freire
In this case, do you want the operating system itself to execute the command (opening the image in the default program)? You can use the Shellexecute command (uses Shellapi).
– Ricardo Alves Carvalho
@Jhonny Freire, I researched and saw that a solution would be to create an interpreter (I think of pascal), but it is complicated, especially for me that I am beginner (and self-taught) in Delphi. I’m looking for a way around this, I just don’t know if it’s possible...
– Nelson Surian
@Ricardo Alves Carvalho, what I want is for the program I’m running to execute the command (show an image in Timage), not the Operating System.
– Nelson Surian