To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.cadOpen lugnet.cad in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 CAD / 7893
7892  |  7894
Subject: 
Re: Can some give me a hand on delphi?
Newsgroups: 
lugnet.cad
Date: 
Thu, 9 May 2002 11:26:25 GMT
Viewed: 
440 times
  
You could make one big if for the (X > 280) and (Y > 20) and (X < 320)
and (Y < 220) because that's the same for all.

if (X > 280) and (Y > 20) and (X < 320) and (Y < 220) then
   if (label1.Caption = 'Spot 1 front') then
   begin
     image1.Picture.LoadFromFile('house\house1r.bmp');
     label1.Caption:=('Spot 1 right');
   end
   else
     if (label1.Caption = 'Spot 1 right') .....


Furthermore you could play with const array's to store the filename and
label names so you can access them via numbers whom are useable via case
and can reduce the source further, but will make it more diffacult to read.

Roland


Eduardo Vazquez Harte wrote:

Hello,

After making the my first interactive demo I notice that the are too many
IF and too much code for a simple project so I whould like to know
how to make this if in to a " CASE " you know all a case x of .
Well here is the if.

...............................................................
if (X > 280) and (Y > 20) and (X < 320) and (Y < 220)
and (label1.Caption = 'Spot 1 front') then
begin
  image1.Picture.LoadFromFile('house\house1r.bmp');
  label1.Caption:=('Spot 1 right');
end
else
if (X > 280) and (Y > 20) and (X < 320) and (Y < 220)
and (label1.Caption = 'Spot 1 right') then
begin
  image1.Picture.LoadFromFile('house\house1b.bmp');
  label1.Caption:=('Spot 1 back');
end
else
if (X > 280) and (Y > 20) and (X < 320) and (Y < 220)
and (label1.Caption = 'Spot 1 back') then
begin
  image1.Picture.LoadFromFile('house\house1l.bmp');
  label1.Caption:=('Spot 1 left');
end
  else
if (X > 280) and (Y > 20) and (X < 320) and (Y < 220)
and (label1.Caption = 'Spot 1 left') then
begin
  image1.Picture.LoadFromFile('house\house1f.bmp');
  label1.Caption:=('Spot 1 front');
end
...............................................................

If is not possible to make if in to a case the how can a reduce the code?
Thanks

FTP is on until
24:00 spanish night time
ftp://ldraw:ldraw@217.127.145.136:20202/




Message has 1 Reply:
  Re: Can some give me a hand on delphi?
 
(...) I think I'll use the big IF for now as I don't know how to do the other way thanks a lot. (...) FTP is on until 24:00 spanish night time ftp://ldraw:ldraw@21...136:20202/ (22 years ago, 9-May-02, to lugnet.cad)

Message is in Reply To:
  Can some give me a hand on delphi?
 
Hello, After making the my first interactive demo I notice that the are too many IF and too much code for a simple project so I whould like to know how to make this if in to a " CASE " you know all a case x of . Well here is the if. ......... if (X (...) (22 years ago, 9-May-02, to lugnet.cad)

4 Messages in This Thread:


Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR