PDA

View Full Version : Yet another date finder



GSAC3
18-05-2009, 02:54
Petr:

Attached is another version of my previous "date finder" program, RETURN_DATES.

This one takes any date that is entered, for example May 18 2009 (a Monday), and finds all future May 18ths that also fall on the same weekday, Monday.

Don

Petr Schreiber
18-05-2009, 07:14
Thanks!,

very useful. Maybe the days, if not too many, could be outputted both directly to console and file.
Interesting to see next May 18th is in 2015 :)


Petr

GSAC3
18-05-2009, 21:32
Petr:

Good idea.

Attached version displays up to the first 10 return dates on the console while writing the complete list to the output file.

Don

Petr Schreiber
18-05-2009, 21:45
Very nice,

thank you for new version!

GSAC3
19-05-2009, 20:16
Petr:

Attached is a revised version of the RETURN_DATES program.

I found a small logic error in the previous ones that caused the program to miss some return dates. I had missed including one of the date return periods. It is fixed now.

I tried sending this post earlier this AM, but apparently my message got lost in the system.

Don

Petr Schreiber
19-05-2009, 20:37
Thanks Don,

here is is bonus ChkInput function for you - it writes red warning in case of incorrect input, and then it correctly restores original color, whatever it was.


FUNCTION ChkInput(sRequest AS STRING, minValue AS LONG, maxValue AS LONG) AS LONG
'*********************************
' Petr's input validation function
'*********************************

DIM AS LONG tempVal, secondTry, textAttr

tempVal = 0
DO
IF secondTry THEN
' -- Retrieving original settings
textAttr = Console_GetTextAttribute()

' -- Print red
Console_SetTextAttribute(Console_ForegroundRGB(1,0,0,1))
PRINTL
PRINTL STRFORMAT$("Please enter value between {1} and {2}:", minValue, maxValue )

' -- Reseting original settings
Console_SetTextAttribute(textAttr)
END IF

PRINT (sRequest)
tempVal = VAL(CONSOLE_READ())
secondTry = %TRUE
LOOP WHILE outside(tempVal, minValue, maxValue)

FUNCTION = tempVal
END FUNCTION



Petr

GSAC3
19-05-2009, 20:42
Petr:

Many thanks; I give it a try.

Don

GSAC3
19-05-2009, 23:14
Petr:

You'r modification makes things more colorful and attention-getting!

Don