Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 09-20-2005, 06:37 AM
DJK DJK is offline
Senior Member
 
Join Date: Aug 2002
Posts: 1,379
Default Database tags converted to images in delphi

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]<1>

should result in :

image1 = b.jpg
image2 = w.jpg
image3 = 1.jpg
image4 = r.jpg
Reply With Quote
  #2  
Old 09-20-2005, 06:43 AM
ctiberg ctiberg is offline
Senior Member
 
Join Date: Aug 2003
Posts: 611
Default RE: Database tags converted to images in delphi

The below isn't tested - but go ahead and try it The idea is to call LoadImages(Table1Memo.AsString);

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.
Reply With Quote
  #3  
Old 09-20-2005, 12:31 PM
DJK DJK is offline
Senior Member
 
Join Date: Aug 2002
Posts: 1,379
Default RE: Database tags converted to images in delphi

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 or am I missing something ?
Reply With Quote
  #4  
Old 09-20-2005, 11:42 PM
ctiberg ctiberg is offline
Senior Member
 
Join Date: Aug 2003
Posts: 611
Default RE: Database tags converted to images in delphi

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.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 01:33 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.