home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / kcss0012.zip / SAMPLES / API / EMBEDD / CSS.CPP
Text File  |  1998-02-11  |  2KB  |  52 lines

  1. /*  Copyright (c) 1998 IBK-Landquart-Switzerland. All rights reserved.
  2.  *
  3.  *  Module      :  CSS.cpp
  4.  *  Application :  C Styled Script
  5.  *  Purpose     :  Main program for standalone execution
  6.  *  Author      :  Peter Koch, IBK
  7.  *
  8.  *  Date        Description                                 Who
  9.  *  --------------------------------------------------------------------------
  10.  *  Jan 1998    First release                               P.Koch, IBK
  11.  */
  12. #include <stdio.h>
  13. #include <strstrea.h>
  14. #include "KCSS.hpp"
  15.  
  16. static KCss* css(0);
  17. static Boolean cssOk(false);
  18. static IString module("CSS.exe");
  19.  
  20. main(int argc, char *argv[], char *envp[])
  21. {
  22.    int ret;
  23.    try {
  24.       css = new KCss();
  25.       cssOk = true;
  26.       cout << "CSS Executive For OS/2 V0.11" << endl
  27.            << "Copyright (c) 1998 IBK-Landquart-Switzerland" << endl
  28.            << endl;
  29.       if (argc < 2) throw IException("%%% syntax: css scriptfile [parameters]");
  30.       IString init("const mainArgVals["+IString(argc)+"] = {\n");
  31.       for (int a = 0; a < argc; a++) {
  32.          init += "  '"+IString(argv[a])+"'";
  33.          if (a < argc-1) init += ",";
  34.          init += "\n";
  35.       } // for
  36.       init += "};\n";
  37.       istrstream str((char*)init);
  38.       css->loadScript(module, &str);
  39.       css->loadScript(argv[1]);
  40.       ret = css->call(module, "main").asInt();
  41.       delete css;
  42.    } // try
  43.    catch (IException err) {
  44.       for (int i = err.textCount()-1; i >= 0; i--)
  45.          if (*err.text(i)) cerr << err.text(i) << endl;
  46.       if (cssOk) delete css;
  47.       ret = 1;
  48.    } // catch
  49.    return ret;
  50. } // main
  51.  
  52.