Emedding CSS In Batch Files

C Styled Script
Reference Manual

<< Back  End  Next >>
 
 
INDEX
Introduction
Installation
Using The CSS Executive
   Jump Start
   Command Line Parameters
   Emedding CSS In Batch Files
Language
Directives
System Library
String Library
Regular Expression Lib.
File Library
Database Library
C API
C++ API
CSS Links
  

Typing CSS in front of the script name becomes annoying sometimes. One solution to this may be to write a batch file. For the previous example a batch file namedargs.bat (or args.cmd) might contain one single line as:

@css args %1 %2 %3 %4 %5 %6 %7 %8 %9
But CSS has also a feature enabling to embedd the script into the batch file itself: If a file starts with '@', CSS will skip the first line and start compiling in the second line. Rename your file args.css from our previous example to args.bat (Windows) or args.cmd (OS/2) and modify it this way:

@goto exec
 
#loadLibrary 'KcSysLib'
 
main()
{
   for (var i=0; i<sizeof(mainArgVals); i++)
      sysLog(mainArgVals[i]);
}
 
/*
:exec
@css %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
@rem */

You may now run the sample either with or without css in front:

css args my name is fred
    ...or...
args my name is fred

The output will however be the same in both cases:

css
args
my
name
is
fred

There is nothing magic about this. But what is actually goin on?

Since the extension of the file is .bat or .cmd respectively, the system runs it as a normal batch script by the command processor. The command processor in turn reads the first line and jumps down behind the:exec label where it calls the css executive. The @rem line at the end hides the css comment close from the command processor.

For CSS this file looks as a perfect source too since it ignores the first line starting with '@'.

After understanding this sample you are prepared to explore CSS going through the following sections.

 Copyright © IBK LandquartLast revised by Peter Koch, 24.02.00<< Back  Top  Next >>