IonicWind Software

IWBasic => The Roundtable => Topic started by: billhsln on August 24, 2008, 12:01:26 AM

Title: Date Routines
Post by: billhsln on August 24, 2008, 12:01:26 AM
Here are a few date routines that might be of use.  There is a routine to determine Easter of any year, since it moves around.  And you never know when you need to figure out the 2nd Tuesday in a week or the 4th Friday.  Also to determine the last day of the month or the last Tuesday of the month.

Also, could some one take a look at lines 40 and 43 and maybe some one can explain why they do not print exactly the same.

Enjoy,
Bill
Title: Re: Date Routines
Post by: Barney on August 24, 2008, 02:51:45 AM
Line 40 is O.K. because you are using the sub that returns the string value and that value is inserted into the print stream.

Line 43 is basically the same as it expects the PrintDay sub to return the string value, but PrintDay does not do it.

I'd say you don't need PrintDay at all. StringDay does the job better. Just add the DEFAULT at the end to keep with the spirit of SELECT. ;)

Barney
Title: Re: Date Routines
Post by: billhsln on August 24, 2008, 08:13:52 AM
Revised the program to use DEFAULT in SELECT, but still has a problem.

Prints MONDAY on the wrong line, prints it before the "2008-09-01 is", rather than on that line.

Revised code is attached.

Bill
Title: Re: Date Routines
Post by: Bruce Peaslee on August 24, 2008, 10:22:16 AM
I believe when PrintDay() is evaluated, it prints then, then the print statement in which is put prints second.
Title: Re: Date Routines
Post by: Barney on August 24, 2008, 10:23:24 AM
Edit: Bruce beat me to it while I was typing this. Nevertheless it's useful, so I'll leave it anyway.

Change line 43 from:

print IDate, " is ", PrintDay(x)

to:

print IDate, " is ", : PrintDay(x)

or:

print IDate, " is ",
PrintDay(x)


Remember that PrintDay(x) subroutine actually prints. It does not return any value back to the calling program.

Why is it first printing "Monday" and then the beginning of the sentence? Simple. Obviously it's the way EBasic works and it is quite logical. Any called subroutines are executed (evaluated) first, so you get "Monday" printed. Since there was no comma in the print statement included in the PrintDay(x) sub, any subsequent printing will start on the next line and it does. Your program is doing what you ordered it to do all along. ;)

Barney