Sorry - I meant to post this to one of the other user-oriented lists.
Please disregard.
On Tuesday, December 17, 2013 4:14:22 PM UTC-7, Tony Bigbee wrote:
>
> Hi,
>
> When I try to execute the first-n-integers extension example:
>
> show noise:first-n-integers 5
>
> I receive an error "ERROR: Expected command. " in the console or in the
> code tab.
> I have mostly copied and pasted the class examples as is, just renaming
> them and putting them in a different package. I wish the ERROR command was
> a little more descriptive, as I suspect I am making a simple error
> somewhere.
>
> I'm using 5.0.4 without the JRE and 1.7.0_45 JRE/JDK on a x64 Windows 7
> machine.
>
> My manifest.txt file with fully-qualified class-manager and crlf at the
> end of the version line--
>
> Manifest-Version: 1.0
> Extension-Name: noise
> Class-Manager: org.xyz.extensions.NoiseExtension
> NetLogo-Extension-API-Version: 5.0 <--there is a crlf here
>
> the jar is in a subfolder with my model file
>
> test/
> test.nlogo
> noise/
> noise.jar
>
>
> This is my Class-Manager:
>
> package org.xyz.extensions;
>
> import org.nlogo.api.*;
>
> /**
> * @author Tony Bigbee
> */
> public class NoiseExtension extends DefaultClassManager {
> public void load(PrimitiveManager primitiveManager) {
> primitiveManager.addPrimitive(
> "first-n-integers", new org.xyz.extensions.NoiseGenerator());
> }
> }
>
> This is the NoiseGenerator file:
>
> package org.xyz.extensions;
> import org.nlogo.api.*;
>
> public class NoiseGenerator extends DefaultReporter {
>
> public Syntax getSynax() {
> return Syntax.reporterSyntax(
> new int[] {Syntax.NumberType()}, Syntax.ListType());
>
> }
>
> public Object report(Argument args[], Context context) throws
> ExtensionException {
> // create a NetLogo list for the result
> LogoListBuilder list = new LogoListBuilder();
> int n ;
> // use typesafe helper method from
> // org.nlogo.api.Argument to access argument
> try {
> n = args[0].getIntValue();
> }
> catch(LogoException e) {
> throw new ExtensionException( e.getMessage() ) ;
> }
> if (n < 0) {
> // signals a NetLogo runtime error to the modeler
> throw new ExtensionException
> ("input must be positive");
> }
> // populate the list. note that we use Double objects; NetLogo
> // numbers are always Doubles
> for (int i = 0; i < n; i++) {
> list.add(Double.valueOf(i));
> }
> return list.toLogoList();
> }
> }
>
> Thanks for any help.
>
> AJB
>
>
--
You received this message because you are subscribed to the Google Groups
"netlogo-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.