Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Color Calendar

2 views
Skip to first unread message

Frank P. Westlake

unread,
Nov 28, 2009, 3:38:41 PM11/28/09
to
@set @JScript=1;/*
:: Calendar.cmd
:: Demonstrates the Calendar subroutine.
:: Use with caution until the date routines have been approved
:: by Doctor Clockton.
:: Calls the following VBS statement to get a backspace character (ASCII08):
:: WScript.Echo(String.fromCharCode(WScript.Arguments(0)));
@Echo OFF
SetLocal EnableExtensions
Set "Year= 2009"
Set "Month= 11"
Set "List= 2009-12-24 2009-12-25 2009-12-26 2009-12-27"

Echo.Just one:
Call :Calendar %Year% %Month% 1 %List%
Echo.Across the entire buffer:
Call :Calendar %Year% %Month% 0xFFFFFFFF %List%

:: Those of you with the short date format (YYYY-MM-DD):
:: Call :Calendar %DATE:~0,4% %DATE:~5,2% 3 %List%

Goto :EOF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:Calendar year month [quantity [marks]]
:: Prints a color calendar.
:: V 1.0 Frank P. Westlake, 2009-11-28
::
:: year Required. 4 digits.
:: month Required. 1 or 2 digits, leading 0 OK.
:: quantity Optional; required if marks are specified.
:: The number of months to print calendars of.
:: marks Optional. A list of dates to mark on the calendar. Date format is
:: YYYY-MM-DD.
::
:: EXAMPLE: Calendar 2009 11 28 3 2009-12-20 2009-12-24 2009-12-25 2009-12-26 2009-12-27
::
SetLocal EnableExtensions EnableDelayEdexpansion
For /F "tokens=1 delims==" %%a in ('Set "$" 2^>NUL:') Do Set "%%a="
For /F "tokens=1 delims==" %%a in ('Set "#" 2^>NUL:') Do Set "%%a="
:: USER DEFINED CONSTANTS:
:: COLORS
Set "#Color.Title=0B" &:: Month Year
Set "#Color.Caption=8F" &:: SU MO TU WE TH FR SA
Set "#Color.Days=07" &:: 01 02 03 04 05 06 07
Set "#Color.Mark=E4" &:: [02]
:: TITLE FORMAT
:: Choose one or create your own.
:: _year = [space]2009, year_ = 2009[space]
Set "#format=month sp1 sp2 _year" &:: "Month YEAR"
REM Set "#format=year_ sp1 sp2 month" &:: "YEAR Month"
REM Set "#format=sp1 sp2 month _year" &:: " Month YEAR"
REM Set "#format=sp1 sp2 year_ month" &:: " YEAR Month"
REM Set "#format=year_ month sp1 sp2" &:: "YEAR Month "
REM Set "#format=month _year sp1 sp2" &:: "Month YEAR "
REM Set "#format=sp1 month _year sp2" &:: " Month YEAR "
REM Set "#format=sp1 year_ month sp2" &:: " YEAR Month "
:: CAPTION TEXT
:: CAPTION [XxxxxxxxxxxxxxxxxxxxxxxxxX] X=letter, x=letter OR space
Set "#Caption=SU MO TU WE TH FR SA"
:: MONTH NAMES
:: Month.x=[ LEQ 22 ]
Set "#Month.1=January"
Set "#Month.2=February"
Set "#Month.3=March"
Set "#Month.4=April"
Set "#Month.5=May"
Set "#Month.6=June"
Set "#Month.7=July"
Set "#Month.8=August"
Set "#Month.9=September"
Set "#Month.10=October"
Set "#Month.11=November"
Set "#Month.12=December"
:: END USER DEFINED CONSTANTS
Set "RANDOM=" & Set "DATE=" & Set "TIME="
Set "$ME=%~f0"
Set "$MY=%TEMP%\%~n0.%RANDOM%%TIME:~-2%"
Set "$Year=%1" & Shift & Set /A "$Year=$Year"
Set "$Month=%1" & Shift & Set /A "$Month=$Month"
Set "$Months=%1" & Shift & Set /A "$Months=$Months"
If %$months% EQU 0 Set "$Months=1"
:Args
If "%1" NEQ "" (Set "$Marks=!$Marks! %1" & Shift & Goto :Args)
For /F "tokens=2" %%a in ('MODE CON:^|Find "Columns:"') Do Set /A "$cols=%%a"
Set /A "$=($cols-2)/32"
If %$% LSS %$months% Set "$Months=%$%"
MkDir "%$MY%" & Pushd "%$MY%"
::Get a backspace character:
For /F "delims=" %%a in ('CSCRIPT /NOLOGO /E:JScript "%$ME%" 8') Do Set "ASCII08=%%a"
For /F "tokens=1 delims==" %%a in ('Set $line 2^>NUL:') Do Set "$line="
Set /A "$y=%$Year%" & Set "$m=0%$Month%" & Set /A "$m=1!$m:~-2!-100"
Set "$MaxLine=0" & Set "$Title="
Set "$Month.space= "
Set /A "$Columns=$Months*32-1"
For /L %%a in (1,1,%$Months%) Do (
If !$m! GTR 12 (Set /A "$m-=12, $y+=1")
Set /A "$n=0,$t=0"&For /F "tokens=1* delims=:" %%N in (
'(Set #Month.!$m!^& Echo.^)^|FindStr /O .') Do (Set /A "$t+=1"
If !$t! EQU 2 (Set /A "$n=%%N-11-$m/10, $nr=(21-$n)/2, $nl=21-$n-$nr"))
Set "$line="
Set /P "=.!ASCII08! "<NUL:
For %%f in (%#Format%) Do (
If /I "%%f" EQU "month" (
Call Set "$line=%%#Month.!$m!%%"
Call :ColorPrint %#Color.Title% !$line!
) Else If /I "%%f" EQU "year_" (
Call :ColorPrint %#Color.Title% !$y!
Set /P "=.!ASCII08! "<NUL:
) Else If /I "%%f" EQU "_year" (
Set /P "=.!ASCII08! "<NUL:
Call :ColorPrint %#Color.Title% !$y!
) Else If /I "%%f" EQU "sp1" (
Call Set "$line=%%$Month.space:~0,!$nl!%%"
Set /P "=.!ASCII08!!$line!"<NUL:
) Else If /I "%%f" EQU "sp2" (
Call Set "$line=%%$Month.space:~0,!$nr!%%"
Set /P "=.!ASCII08!!$line!"<NUL:
)
)
Set /P "=.!ASCII08! "<NUL:
Set "$line=0"
Call :DIM !$y! !$m!
Call :DOW !$y! !$m!
Set /A "$Start=-($dow %% 7)"
For /L %%i in (!$start!,1,!$dim!) Do (
If %%i LSS 1 (
If %%i LSS 0 (Call Set "$line.!$line!=%%$line.!$line!%% ")
) Else (
Set "$i= %%i "
For %%m in (%$Marks%) Do (
Set "$Mark=%%m" & Set /A "$Mark.m=1!$Mark:~5,2!-100" & Set /A "$Mark.d=1!$Mark:~8,2!-100"
If "!$Mark:~0,4!" EQU "!$y!" If "!$Mark.m!" EQU "!$m!" If "!$Mark.d!" EQU "%%i" Set "$i= [%%i]"
)
Call Set "$line.!$line!=%%$line.!$line!%%!$i:~-4!"
Set /A "$dow+=1, $t=$dow %% 7"
If !$t! EQU 0 (
Call Set "$line.!$line!=%%$line.!$line!%% "
Set /A "$line+=1"
If !$line! GTR !$MaxLine! Set "$MaxLine=!$line!"
)
)
)
Set /A "$dow %% =7"
For /L %%i in (!$dow!,1,7) Do (
Call Set "$line.!$line!=%%$line.!$line!%% "
)
Set /A "$line+=1"
For /L %%i in (!$line!,1,5) Do (
Set "$line.%%i=!$line.%%i! "
Set "$MaxLine=%%i"
)
Set /A "$m+=1"
)
Echo.
For /L %%i in (1,1,%$Months%) Do (
Set /P "=.!ASCII08! "<NUL:
Call :ColorPrint %#Color.Caption% %#Caption%
Set /P "=.!ASCII08! "<NUL:
)
Echo.
Set "$Colors=%#Color.Days%"
For /L %%i in (0,1,%$MaxLine%) Do (
For /L %%j in (0,1,%$Columns%) Do (
If DEFINED $line.%%i (
If "!$line.%%i:~%%j,1!" EQU " " (
Set /P "=.!ASCII08! "<NUL:
) Else If "!$line.%%i:~%%j,1!" EQU "[" (
Set /P "=.!ASCII08! "<NUL:
Set "$Colors=%#Color.Mark%"
) Else If "!$line.%%i:~%%j,1!" EQU "]" (
Set "$Colors=%#Color.Days%"
Set /P "=.!ASCII08! "<NUL:
) Else (
Echo.!$line.%%i:~%%j!|FindStr "[ ]" >NUL: && (
Call :ColorPrint !$Colors! !$line.%%i:~%%j,1!
) || (
Set /P "=!$line.%%i:~%%j!"<NUL:
Set "$line.%%i="
)
)
)
)
Echo.
)
PopD
RD /S /Q "%$MY%"
Goto :EOF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:DIM y m
SetLocal EnableExtensions
If "%2" NEQ "2" (
Set /A "$DIM=30+((5547>>%2)&1)"
Goto :DIM.END
)
:: %2 EQU 2
Set /A "$l1=$y %% 4, $l2=$y %% 100, $l3=$y %% 400"
If %$l3% EQU 0 (Set "$L=1") Else If %$l2% EQU 0 (Set "$L=0"
) Else If %$l1% EQU 0 (Set "$L=1") Else (Set "$L=0")
Set /A "$DIM=28+$L"
:DIM.END
EndLocal & Set "$DIM=%$DIM%"
Goto :EOF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:DOW dy dm
SetLocal EnableExtensions
Set /A "$dy=%1, $dm=%2"
Set /A "$a=(14-$dm)/12"
Set /A "$y=$dy-$a"
Set /A "$m=$dm+12*$a-2"
Set /A "$dow=(1+$y+$y/4-$y/100+$y/400+(31*$m/12))%%7"
If %$dow% EQU 0 (Set "$dow=7")
EndLocal&Set "$dow=%$dow%"
Goto :EOF
::::::::::::::::::::::::::::::::::::::::::::::::::ColorPrint
::ColorPrint ColorValueName
:ColorPrint hexvalue string
SetLocal EnableExtensions DisableDelayedExpansion
Set "$h=%~1"
If NOT DEFINED $ColorPrint (
Set /P "=%ASCII08% %ASCII08%"<NUL: >ColorPrint
Set "$ColorPrint=ColorPrint"
)
Set "$CommandLine=%*"
If NOT DEFINED $CommandLine Goto :EOF
Set "$CommandLine=%$CommandLine:~3%"
Rename "%$ColorPrint%" "%$CommandLine%"
FindStr /A:%$h% /R "^" *
EndLocal & Set "$ColorPrint=%$CommandLine%"
Goto :EOF
*/
WScript.Echo(String.fromCharCode(WScript.Arguments(0)));

Frank P. Westlake

unread,
Nov 28, 2009, 5:13:02 PM11/28/09
to
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:Calendar year month [quantity [marks]]
:: Prints a color calendar.
:: V 1.1 Frank P. Westlake, 2009-11-28

::
:: year Required. 4 digits.
:: month Required. 1 or 2 digits, leading 0 OK.
:: quantity Optional; required if marks are specified.
:: The number of months to print calendars of.
:: marks Optional. A list of dates to mark on the calendar. Date format is
:: YYYY-MM-DD.
::
:: EXAMPLE: Calendar 2009 11 28 3 2009-12-20 2009-12-24 2009-12-25 2009-12-26 2009-12-27
::
SetLocal EnableExtensions EnableDelayEdexpansion
For /F "tokens=1 delims==" %%a in ('Set "$" 2^>NUL:') Do Set "%%a="
For /F "tokens=1 delims==" %%a in ('Set "#" 2^>NUL:') Do Set "%%a="
:: USER DEFINED CONSTANTS:
:: COLORS
Set "#Color.Title=0B" &:: Month Year
Set "#Color.Caption=8F" &:: SU MO TU WE TH FR SA
Set "#Color.Days=17" &:: 01 02 03 04 05 06 07
Call :ColorPrint !$Colors! !$line.%%i:~%%j!
REM Set /P "=!$line.%%i:~%%j!"<NUL:

Set "$line.%%i="
)
)
)
)
Echo.
)
PopD
RD /S /Q "%$MY%"
Goto :EOF
::CHANGES
::V 1.1 2009-11-28 Fixed failure to print days in color when
:: printing high speeed.


mokomoji

unread,
Nov 29, 2009, 4:33:57 PM11/29/09
to
plz i'am error..
plz not use's find syntax.. and microsoft jscript comfile error ...
plz for tokens use's..version

and...@_@)a scroll pressure
simple source...
@_@)a
eye's smilingly smilingly~!!!

Frank P. Westlake

unread,
Nov 29, 2009, 4:52:22 PM11/29/09
to
"mokomoji"
news:42716dbc-e6d4-489b...@d9g2000prh.googlegroups.com...

> plz i'am error..
___
W _!___!_ W
\\ {0^0} //
\\_[-]_//
\ """ /
| |

I don't know what error!!

Frank
Salam


Dr J R Stockton

unread,
Nov 29, 2009, 10:46:36 AM11/29/09
to
In alt.msdos.batch.nt message <hes1ol$rjj$1...@news.albasani.net>, Sat, 28
Nov 2009 12:38:41, Frank P. Westlake <frank.w...@yahoo.com> posted:

>:: Use with caution until the date routines have been approved

Seemingly does not comply fully with ISO 8601; therefore, fit only for
Americans and the elderly.

Lacks week numbers, which are commonly required in business AIUI.

--
(c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05.
Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm estrdate.htm js-dates.htm pas-time.htm critdate.htm etc.

Frank P. Westlake

unread,
Nov 29, 2009, 5:31:26 PM11/29/09
to
"Dr J R Clockton"
news:4gtKmNDc...@invalid.uk.co.demon.merlyn.invalid...

> Seemingly does not comply fully with ISO 8601; therefore, fit only for
> Americans and the elderly.

I'll look into it. I don't know what non-American feature I'm lacking. I
made the month names and day name abbreviations easily translatable.
Also month and year positions are easily configurable.

> Lacks week numbers, which are commonly required in business AIUI.

I thought of that afterwards and since it requires much reformatting I
decided to add it later. For version 2.

Monday as first day of week option might be version 3.

I'm waiting for more errors to become known before I do more.

Frank


Dr J R Stockton

unread,
Nov 30, 2009, 12:44:10 PM11/30/09
to
In alt.msdos.batch.nt message <heuso0$jv$1...@news.albasani.net>, Sun, 29
Nov 2009 14:31:26, Frank P. Westlake <frank.w...@yahoo.com> posted:

>"Dr J R Clockton"
>news:4gtKmNDc...@invalid.uk.co.demon.merlyn.invalid...
>
>> Seemingly does not comply fully with ISO 8601; therefore, fit only for
>> Americans and the elderly.
>
>I'll look into it. I don't know what non-American feature I'm lacking.

Genesis chapter 2 verse 2 provides the clue. See below.


> I
>made the month names and day name abbreviations easily translatable.
>Also month and year positions are easily configurable.
>
>> Lacks week numbers, which are commonly required in business AIUI.
>
>I thought of that afterwards and since it requires much reformatting I
>decided to add it later. For version 2.

Should not be difficult to add, as far as format goes. See, and try a
copy of, <http://www.merlyn.demon.co.uk/js-clndr.htm>. (NOTE: It's
rather old; the code is correct (AFAIK), but otherwise not necessarily
good).


>Monday as first day of week option might be version 3.

No. Since it seems to use ISO 8601 dates, Monday = Day 1 should be the
norm.


Note that it can be helpful to provide an array of day-of-week names,
starting Sunday=0 and ending Sunday=7. That matches both ISO and C.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
Do not Mail News to me. Before a reply, quote with ">" or "> " (SonOfRFC1036)

Frank P. Westlake

unread,
Dec 1, 2009, 10:07:47 AM12/1/09
to
"Dr J R Stockton"
news:voRPkiGq...@invalid.uk.co.demon.merlyn.invalid...


> Since it seems to use ISO 8601 dates, Monday = Day 1 should be the
> norm.

OK, I'll change it.


> Note that it can be helpful to provide an array of day-of-week names,
> starting Sunday=0 and ending Sunday=7. That matches both ISO and C.

That is how I do things in a compiled application and also in many
scripts. But in applications written with an interpreted language the
entire script is essentially a configurtation file. For day of week I
provide the following configuration option:

:: CAPTION TEXT
:: CAPTION [XxxxxxxxxxxxxxxxxxxxxxxxxX] X=letter, x=letter OR space
Set "#Caption=SU MO TU WE TH FR SA"

With that option a person can use a mixture of 1, 2, and 3 letter
abbreviations

Set "#Caption=S Mo Tue We Thu FR Sa"

or do something completely different:

Set "#Caption=1 2 3 4 5 6 7"
Set "#Caption=MY CALENDAR"


I had four weeks with electricity and am back to being without. It was a
productive four weeks, but the scripts I began might now take years to
complete. Anyone who wishes may improve anything I've done and republish
it.

Frank
Maidir te


0 new messages