artefaktur
software engineer &        architecture

 
 
 
 

The CfgScript Interpreter acdkcfgscript

| Introduction | Start | acdkcfgscript | Language | Library | Embedding | CfgScript IDE | Debugging | Templates | Samples | Wish List |

acdkcfgscript is the command line interpreter for executing CfgScript scripts.



Content of this chapter:

   Syntax
     Execute a Script File
     Execute a Script passed as argument
     Associate csf script file with the acdkcfgscript interpreter
     CfgScript Options
       -csfinclude / CSFINCLUDES
       -csfpath / CSFPATH
       -csfdebug
       -csfdebugonfail
     acdk-options
   Script Environment



 Syntax


When starting the acdkcfgscript executable without arguments you will receive following output:

CfgScript Interpreter. Copyright 2003-2005 by Roger Rene Kommer, artefaktur
Syntax:
  acdkcfgscript <acdk-options> <cfgscript-options> file.csf <script arguments>
  acdkcfgscript <acdk-options> <cfgscript-options> -e <scriptcode>
cfgscript-options:
  -csfinclude directory     insert include search directory
  -csfpath    directory     insert path for the CfgScript class loader
  -csfdebug                 start interpreter in debug mode
  -csfdebugonfail           branch to debugger if exception is thrown
  
acdk-options:
common acdk options:
  -acdk-home=<pathname>   set the path to acdk home directory
  -acdk-home <pathname>
  -acdk-tools-home=<pathname>   set the path to acdk tools home directory
  -acdk-tools-home <pathname>
  -acdk-path <pathlist>   Env path list for ACDKPATH, to find acdk libraries
  -acdk-gc                run with mark/sweep garbage collection (experimental)
  -acdk-rc                run with reference counting garbage collection
  -acdk-rcgc              run with reference counting and mark/sweek gc
  -acdk-pa                run with PageAllocator garbage collection (default)
  -acdk-st                run in single thread mode
  -cygpath                on windows platform runs in cygwin enviromnent
  -acdk-enc <char enc>    use encoding for console in/output
  -acdk-maxmem <number>   limit memory usage -1 no limit, otherwise number of MB
  -loglevel <loglevel>    integer [0(all)-65535(Non)] or 
                                  [All|Trace|Debug|Info|Warn|Note|Error|Fatal|None]



 Execute a Script File

The base syntax to start a CfgScript is:
cfgscript MyScriptFile.csf
If you want to pass argument to the script:
cfgscript MyScriptFile.csf -first -second
These arguments are availabe in the script:

foreach (String arg in scriptargs)
{
  out.println("Script Argument: " + arg);
}

 Execute a Script passed as argument

To execute a mini script directly from commandline just use the -e option:

cfgscript -e 'out.println("hello");'
Please note: the quoting of the following code after the -e option depends on the operation system and shell you use.

 Associate csf script file with the acdkcfgscript interpreter

On MS Windows, use the standard mechanism to associate a file extension with a program to open.

  • On Unix you can add following lines to the top of a script file:

    
    #!/bin/sh
    
    #!ignorenextline
    
    eval 'exec acdkcfgscript $0 ${1:"$@"}'
    
    System.out.println("executed"); // this is the first line of the real script
    
  • make the script file executable (chmod +x scriptfile.csf).
  • Add the $ACDKHOME/bin path to the environment variable PATH and LD_LIBRARY_PATH.

 CfgScript Options

 -csfinclude / CSFINCLUDES

The -csfinclude option insert a search path for the  include statement.

You can also use the CSFINCLUDES environment variable, to declare a list of include path.
On Unix:
export CSFINCLUDES=/usr/local/acdk/extmodules/csf:~/acdk/csf/include
On Windows:
set CSFINCLUDES=c:\programr\acdk\extmodules\csf;c:\MyDocs\acdk\csf\include

 -csfpath / CSFPATH


The -csfpath insert a directory in the CSFPATH environment variable.
Is a list of directory where the CfgScript ClassLoader tries to load CfgScript Classes.

Please refer also to:  CfgScript ClassLoader.

 -csfdebug

Start the interpreter in the debugging mode.
Please refer to  Debugging.

 -csfdebugonfail

if -csfdebugonfail is set the interpreter branches to the  debugger if any exception will be thrown.

 acdk-options


The acdk-options are documented in  man acdk_core.

 Script Environment

When starting the interpreter some variables are predefined:


Inside the method of CfgScriptClass following variables are set:
  • this if method is not static.
  • super super class.

 
Last modified 2005-05-08 22:25 by SYSTEM By Artefaktur, Ing. Bureau Kommer