X-Git-Url: https://code.consxy.com/gitweb/gitweb.cgi?p=clnl;a=blobdiff_plain;f=bin%2Fruncmd.scala;h=f4668874a455890a89105a628153573e28b19e85;hp=e2d16d78ac099caaa605d2284f955bd73a41fd48;hb=762ab38881c8870c9a61ca6857a28159f9fef9fc;hpb=c75540c5e70876738fa70daee3bb5fb888367796 diff --git a/bin/runcmd.scala b/bin/runcmd.scala index e2d16d7..f466887 100755 --- a/bin/runcmd.scala +++ b/bin/runcmd.scala @@ -23,21 +23,63 @@ import org.nlogo.util.Utils.url2String import collection.JavaConversions._ +val input = io.Source.stdin.getLines.mkString("\n").split("\\@\\#\\$\\#\\@\\#\\$\\#\\@") + System.out.println("----") val workspace = HeadlessWorkspace.newInstance workspace.silent = true -workspace.openFromSource(url2String("file:resources/empty.nlogo")) -val input = io.Source.stdin.getLines.mkString("\n").split("\\@\\#\\$\\#\\@\\#\\$\\#\\@") -val commands = input(0) +if (input.length > 2 && input(2).length > 0) { + val modelSetup = input(2) + workspace.openFromSource(modelSetup + +""" +@#$#@#$#@ +GRAPHICS-WINDOW +210 +10 +649 +470 +-1 +-1 +13.0 +1 +10 +1 +1 +1 +0 +1 +1 +1 +-1 +1 +-1 +1 +0 +0 +1 +ticks +30.0 + +@#$#@#$#@ +@#$#@#$#@ +@#$#@#$#@ +NetLogo 5.2.0""") +} else { + workspace.openFromSource(url2String("file:resources/empty.nlogo")) +} workspace.mainRNG.setSeed(15) + +val commands = input(0) if(commands.length > 0) { workspace.runCompiledCommands(new api.SimpleJobOwner("test", workspace.world.mainRNG, classOf[api.Observer]), workspace.compileCommands(commands)) } if(input.length > 1) { val reporter = input(1) - System.out.println(org.nlogo.api.Dump.logoObject(workspace.runCompiledReporter(new api.SimpleJobOwner("test", workspace.world.mainRNG, classOf[api.Observer]), workspace.compileReporter(reporter)))) + if(reporter.length > 0) { + System.out.println(org.nlogo.api.Dump.logoObject(workspace.runCompiledReporter(new api.SimpleJobOwner("test", workspace.world.mainRNG, classOf[api.Observer]), workspace.compileReporter(reporter)))) + } } workspace.world.exportWorld(new java.io.PrintWriter(System.out, true), true)