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.t xt');
else : System.Assign(FileHandle,' others.txt ');
end;
Case DayOfWeek(Date) of
2 {Monday} : System.Assign(FileHandle,'
5 {Thursday} : System.Assign(FileHandle,'
else : System.Assign(FileHandle,'
end;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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(SysUtil s.Date) of
thanks.
>> 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(SysUtil
thanks.
Hmm... Raymond, sometimes it surprices me how fast you are hehehe
:-)
:-)
ASKER
Thanks to Williams too! You guys (gals?) are great.
That's alright, another time ?
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))
(It might also be an error, where you previously declared a 'Date' variable as an Integer overriding the system Date function.)
Regards,
Williams