Archive for September, 2010

Batch file look-up table for month names

The look up table goes in months.bat:

:: one record per line
:: = is the delimiter
@echo 1=jan
@echo 2=feb
@echo 3=mar
@echo 4=apr
@echo 5=may
@echo 6=jun
@echo 7=jul
@echo 8=aug
@echo 9=sep
@echo 10=oct
@echo 11=nov
@echo 12=dec

Given a month number, you can then look up the month abbreviation as follows:

:: Enable numeric comparison in if statements (Windows NT or better)
@SETLOCAL ENABLEEXTENSIONS

:: Set the month number you want to look up
:: 8 is August
@SET MN=8

:: Look up the months abbreviation (e.g. 8 is aug, 9 is sep, 10 is oct)
@FOR /F "tokens=1,2 delims==" %%i IN ('months.bat') DO @IF %%i EQU %MN% SET MW=%%j

:: The month abbreviation is now the %MW% variable
@ECHO The month abbreviation corresponding to %MN% is %MW%.
  • ‘months.bat’ executes that file and pipes the output to the FOR /F command
  • delims== sets the delimiter to the equals sign
  • tokens=1,2 means you want the first two tokens (e.g. 1 and aug for 1=aug=August)
  • %%i means the first token will go in %%i, second in %%j, etc

Alternate solutions are welcome. I’m still a bit unclear on the difference between %%i, %i, and %i%.

Useful links:

Looking for help with DB2 support in MediaWiki

MediaWiki is the PHP application underlying Wikipedia and other sites. Over the past couple years, I’ve spent some of my spare time to add DB2 support to it. Here’s where things stand now:

  • Working: Installing on DB2 using the old installer
  • Broken: Creating and editing articles
  • Not implemented: Search
  • Not implemented: Installing on DB2 using the new 1.17 installer

Implementing the installer was half the battle, as it required a fully functional DB2 database abstraction layer. I think the main issue with article editing right now are some data inconsistencies in the initial database.

However, MediaWiki is getting a new installer in 1.17. I’ll try to spend some time soon to establish the scope of adding DB2 support to it, and then start implementing.

My MediaWiki time is pretty limited, though. If you or someone you know can pitch in on debugging, maintaining, and expanding the DB2 support in it, I’d be very happy to bring you up to speed and review your initial patches.

Keep in mind that MediaWiki is GPL software.

Some links:

  • http://www.mediawiki.org/wiki/MediaWiki
  • http://www.mediawiki.org/wiki/How_to_become_a_MediaWiki_hacker
  • http://www.mediawiki.org/wiki/Commit_access
  • http://www.mediawiki.org/wiki/Manual:Coding_conventions
  • http://www.mediawiki.org/wiki/Manual:IBM_DB2