Link to home
Start Free TrialLog in
Avatar of Kapusta
Kapusta

asked on

Case DayOfWeek(Date) of

Why will this not compile under Delhpi 3?  The error is on the first line, Incompatible types, Integer and TDateTime.

Case DayOfWeek(Date) of
2 {Monday} : System.Assign(FileHandle,'Monday.txt');
5 {Thursday} : System.Assign(FileHandle,'Thursday.txt');
else : System.Assign(FileHandle,'others.txt');
end;
ASKER CERTIFIED SOLUTION
Avatar of rwilson032697
rwilson032697

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of williams2
williams2

I'm not sure, though this example compiles fine:

procedure TForm1.FormCreate(Sender: TObject);
var
  S: String;
  F: File;
begin
  Case DayOfWeek(Date) of
    1 {Sunday}   : S:='Sunday.txt';
    2 {Monday}   : S:='Monday.txt';
    3 {Tuesday}  : S:='Tueday.txt';
    4 {Wednsday} : S:='Wednsday.txt';
    5 {Thursday} : S:='Thursday.txt';
    6 {Friday}   : S:='Friday.txt';
    7 {Saturday} : S:='Saturday.txt';
    else
                   S:='Else';
  end;
  System.Assign(F,S);
end;

If this doesn't help, try to say where your problem occurs.

But you could event though try to replace the case sentence with:
  Case DayOfWeek(TDateTime(Date)) of

(It might also be an error, where you previously declared a 'Date' variable as an Integer overriding the system Date function.)

Regards,
Williams
Avatar of Kapusta

ASKER

>>However, there is a syntax error, also change date to SYSutils.date
>> to remove any name collision:
>>    Change it to this:
>>    Case DayOfWeek(SysUtils.Date) of

Your solution did not work.  Same problem...  However, you did get my brain juices flowing, and I did discover that the following DOES work...

    Case SysUtils.DayOfWeek(SysUtils.Date) of

thanks.
Hmm... Raymond, sometimes it surprices me how fast you are hehehe

:-)
Avatar of Kapusta

ASKER

Thanks to Williams too!  You guys (gals?) are great.


That's alright, another time ?