Your Ad Here
Showing posts with label source code. Show all posts
Showing posts with label source code. Show all posts

Friday, June 4, 2010

Parsing Command Line Argument with Batch Files

On the site Computer Science 101 with Erik Oosterwal a method is described for simulating a WHILE loop in a batch file in order to parse all the parameters passed in to the batch file as command line arguments.  Here is a copy of the small amount of sample code highlighted in that article:


::     Process all the arguments from the command line
::
:_PROCESS_ARGUMENTS
    IF (%1)==() GOTO:_WRAP_TOP_DIRECTORY_IN_DOUBLE_QUOTES
    SET _Temp_Var=%1
    IF /I (%_Temp_Var:~0,2%)==(-H) GOTO:_INSTRUCTIONS
    IF /I (%_Temp_Var:~0,2%)==(/H) GOTO:_INSTRUCTIONS
    IF /I (%_Temp_Var:~0,2%)==(-?) GOTO:_INSTRUCTIONS
    IF /I (%_Temp_Var:~0,2%)==(/?) GOTO:_INSTRUCTIONS
    IF /I (%_Temp_Var:~0,2%)==(-A) SET Overwrite_File=NO
    IF /I (%_Temp_Var:~0,3%)==(-I:) SET Include_Directory=%_Temp_Var:~3%
    IF /I NOT (%_Temp_Var:~0,1%)==(-) SET Output_File="%~f1"
    SHIFT
    GOTO:_PROCESS_ARGUMENTS

:_WRAP_TOP_DIRECTORY_IN_DOUBLE_QUOTES
    IF (%Include_Directory%)==() GOTO:_INSTRUCTIONS


The original article, Parsing Command Line Parameters, includes a detailed description of how the loop works, how the parameters are evaluated, and a batch file that uses this code to create an include-file for a whole directory tree.

Monday, May 24, 2010

New Requirements by NSF for Data Management

The American National Science Foundation (NSF) has recently announced new requirements for handling and sharing data from projects funded by the agency.

"Science is becoming data-intensive and collaborative," noted Ed Seidel, acting assistant director for NSF's Mathematical and Physical Sciences directorate. "Researchers from numerous disciplines need to work together to attack complex problems; openly sharing data will pave the way for researchers to communicate and collaborate more effectively."

"This is the first step in what will be a more comprehensive approach to data policy," added Cora Marrett, NSF acting deputy director. "It will address the need for data from publicly-funded research to be made public."

The new requirements, although publicly stated to encourage better sharing of data within the science community, are almost certainly related to the recent Climategate fiasco.  It should be seen as a reminder to us all to follow proper procedures when writing software, especially in the area of source code control.

For more information on Climategate see the articles in Wikipedia, Wallstreet Journal, the original files related to the scandal, and an analysis of the emails.

For more information on the subjects that are more directly computer related see the articles in Wikipedia for LIMS, data management, and source code control.