Marcus Daniels, 12-2-2000

>>>>> "ST" == Sven N Thommesen <sthomme@aub.mindspring.com> writes:

ST> The first has to do with saving parameters (ivars) using
ST> swarmAppArchiver in java: for some reason, the resulting .scm file
ST> does not contain any of the ivars I have created (in a batch swarm
ST> which subclasses SwarmImpl)

1) they need to be public, and 2) you may have to use the new DLLs -- I can't
remember if 2.1.1 handled this.

ST> The other issue is parameter input on the command line: how to do
ST> that in Java? In ObjC it was possible to use a call to
ST> initSwarmArguments () where you could supply your own subclass of
ST> Arguments. I don't see anything in the Swarm java docs about this
ST> anymore. What's the suggested manner of doing this now?

Here's a demo.  Being a test program, it deliberately does things the
hard way, i.e. it wasn't written for pedagogical purposes.  You
definitely need new DLLs for this.  The key is the addition of the addOption
method.

import swarm.Globals;
import swarm.SwarmEnvironmentC;
import swarm.SwarmEnvironmentCImpl;
import swarm.SwarmEnvironmentImpl;
import swarm.defobj.Arguments;
import swarm.defobj.ArgumentsC;
import swarm.defobj.ArgumentsCImpl;
import swarm.defobj.ArgumentsImpl;
import swarm.defobj.Zone;


public class TestArguments {
  static void main (String args[]) {
    Zone aZone = Globals.env.globalZone;
    
    ArgumentsC argumentsC = new ArgumentsCImpl (new ArgumentsImpl ());
    Arguments arguments;

    int i, len = args.length;
    String argv[] = new String[1 + len];

    argv[0] = "TestArguments";

    for (i = 0; i < len; i++)
      argv[1 + i] = args[i];

    argumentsC.createBegin (aZone);
    argumentsC.setArgc$Argv (len + 1, argv);
    argumentsC.setAppName (argv[0]);
    argumentsC.setAppModeString ("default");
    argumentsC.setBugAddress ("bug-swarm@swarm.org");
    argumentsC.setVersion ("0.0");
      
    argumentsC.addOption$key$arg$flags$doc$group ("myarg", (int) 'M', "argvalue", 0, "My Argument", 0);
    arguments = (Arguments) argumentsC.createEnd ();

    Globals.envC.setArguments (arguments);
    Globals.envC.createEnd ();
    
    System.out.println (Globals.env.arguments.getAppModeString ());
  }
}
