![]() |
#1
|
|||
|
|||
![]()
I have for example in a database field the following text:
[b] How can I on a event do this: - delphi look at first item between <> in the database - delphi sees it is a B - delphi adds "c:\b.jpg" to image1 - delphi looks at second item between <> in the database - delphi sees it is a W - delphi adds "c:\w.jpg" to image2 - delphi sees there is no items left - that's it So it should add as far as needed with a maximum of 7 .. (so there is a image up to image7 on the form) It should fill from 1 up to 7 for as long as there are tags in the field, so [b] should result in : image1 = b.jpg image2 = w.jpg image3 = 1.jpg image4 = r.jpg |
#2
|
|||
|
|||
![]()
The below isn't tested - but go ahead and try it
![]() procedure TForm1.LoadImage(ImgNum: integer; fn: string); var Img: TImage; begin Img := TImage(FindComponent('Image' + IntToStr(ImgNum))); Img.Picture.LoadFromFile(fn); end; procedure TForm1.LoadImages(txt: string); var i, ix: integer; fn: string; begin for i := 1 to 7 do begin ix := Pos('<', txt); if ix <= 0 then break; Delete(txt, 1, ix); ix := Pos('>', txt); if ix <= 0 then break; fn := Copy(txt, 1, ix - 1); Delete(txt, 1, ix); LoadImage(i, 'c:\' + fn + '.jpg'); end; end; Best regards, Christian Tiberg PS. Please be sure to click "Accept as answer" if this helped you! DS. PPS. I do not answer forum messages by email! DS. |
#3
|
|||
|
|||
![]()
Hey
I would like to try the code but after a quick glance I don't see anywhere where to give in the fieldname of the database field where the tags are stored ... So I have serious doubts that it will do what I want it to do ![]() |
#4
|
|||
|
|||
![]()
I wrote this at the top, but OK. Here's the code for a button:
procedure TForm1.Button1Click(Sender: TObject); begin LoadImages(Table1Memo.AsString); end; In this code, Table1Memo is your database field.... Best regards, Christian Tiberg PS. Please be sure to click "Accept as answer" if this helped you! DS. PPS. I do not answer forum messages by email! DS. |
![]() |
Thread Tools | |
Display Modes | |
|
|