April 29, 2024, 05:55:06 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Date Routines

Started by billhsln, August 24, 2008, 12:01:26 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

billhsln

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
When all else fails, get a bigger hammer.

Barney

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

billhsln

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
When all else fails, get a bigger hammer.

Bruce Peaslee

I believe when PrintDay() is evaluated, it prints then, then the print statement in which is put prints second.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Barney

August 24, 2008, 10:23:24 AM #4 Last Edit: August 24, 2008, 10:26:25 AM by Barney
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