This project has moved. For the latest updates, please go here.

Still Error using Jurrasic basic functions


I just try to compile the following code, but i get an error. why?

var tmpgender="it";
var tmpnamestr=tmpgender.toLowerCase();

I use the jurassic.dll in unity and everything else works fine (like Math.PI etc.)




paulbartrum wrote Aug 9, 2015 at 3:34 AM

I cannot reproduce this error. Can you provide a test case, or just explain what error you are getting?

** Closed by paulbartrum 08/08/2015 8:34PM

SkandY123 wrote Aug 9, 2015 at 9:22 AM

I use Program # to parse AIML files in Unity. I don't know how I can retrieve the error to get more Information.
        protected override string ProcessChange()
            if (this.templateNode.Name.ToLower() == "script")
                // currently only AIML files in the local filesystem can be referenced
                if (this.templateNode.InnerText.Length > 0)
                    string jscript = this.templateNode.InnerText;
                        // Execute Javascript  
                        // Return string from function main
                        Debug.LogError("ERROR! Attempted (but failed) to execute following Javascript: " + jscript);
              "ERROR! Attempted (but failed) to execute following Javascript: " + jscript);
            return string.Empty;
This is the AIML Category:
000001: <category>
000002:     <pattern>
000003:         WHO IS *
000004:     </pattern>
000005:     <template>
000006:         <think>
000007:             <set name="star">
000008:                 <star></set>
000009:         </think>
000010:         <script>
000011:             function main(){
var tmpoutput="Sorry, I don't know " + star;
var tmpgender="it";
var tmpstar=this[star];
var tmpstargender = this[star+"Gender"];
var tmpname = star.toLowerCase(); // This Line causes an Exception, independend from the variable to lower case.
if(tmpstar=="known")tmpoutput="I know " + tmpgender + " by sight.";Thoughtful="1";if(tmpstar=="friend"){
tmpoutput=star + " is a friend of mine. " + "What do you want from "+ tmpgender+"?";
return tmpoutput;
000012:         </script>
000013:     </template>
000014: </category>
The Variable star is set bevore as global variable in this code:
        protected override string ProcessChange()
            if (this.templateNode.Name.ToLower() == "set")
                if ( > 0)
                    if (this.templateNode.Attributes.Count == 1)
                        if (this.templateNode.Attributes[0].Name.ToLower() == "name")
                            if (this.templateNode.InnerText.Length > 0)
                                // Work only with global settings
                                // Set Global Variable in Jurassic
                                // Set Global Variable in Program #
                       (this.templateNode.Attributes[0].Value, this.templateNode.InnerText);

                                // Do not use user predicates
                                //this.user.Predicates.addSetting(this.templateNode.Attributes[0].Value, this.templateNode.InnerText);
                                //return this.user.Predicates.grabSetting(this.templateNode.Attributes[0].Value);
                                // No need to "delete" setting variables
                                // remove the predicate
                                return string.Empty;
            return string.Empty;
Without the "LowerCase" Line, everything works fine.

SkandY123 wrote Aug 9, 2015 at 9:24 AM

First I used the Jurassic source code and compiled it in Unity. Now, i use the Jurassic.dll but get the same error.

SkandY123 wrote Aug 11, 2015 at 10:42 PM

I guess I found the Error.

It occured, because i forgot to use using Jurassic; in the file, where I executed the script and in the file, where I defined Jurassic. It is strange, because it didn't throw any Error doing basic logic opperations but advanced string,math, ... functions.

SkandY123 wrote Aug 12, 2015 at 8:25 AM

Unfortunately it wasn't the solution.

when i run this code:

string result;

i get this error:

NotImplementedException: The requested feature is not implemented.
System.Reflection.Emit.DynamicMethod.GetDynamicILInfo () (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection.Emit/DynamicMethod.cs:229)
Jurassic.Compiler.DynamicILGenerator..ctor (System.Reflection.Emit.DynamicMethod) <IL 0x0001d, 0x00130>
Jurassic.Compiler.Binder.CreateDelegateCore (int) <IL 0x00062, 0x00254>
Jurassic.Compiler.Binder.CreateDelegate (int) <IL 0x0002f, 0x001a3>
Jurassic.Compiler.Binder.Call (Jurassic.ScriptEngine,object,object[]) <IL 0x00004, 0x00068>
Jurassic.Library.ClrFunction.CallLateBound (object,object[]) <IL 0x00059, 0x002c2>
Jurassic.Library.FunctionInstance.CallWithStackTrace (string,string,int,object,object[]) <IL 0x00013, 0x000cc>
(wrapper dynamic-method) Jurassic.Compiler.MethodGenerator.eval (Jurassic.ScriptEngine,Jurassic.Compiler.Scope,object) <IL 0x00104, 0x00851>
Jurassic.Compiler.EvalMethodGenerator.Execute () <IL 0x00041, 0x0026a>
Jurassic.ScriptEngine.Evaluate (Jurassic.ScriptSource) <IL 0x00091, 0x00396>
Jurassic.ScriptEngine.Evaluate (string) <IL 0x00007, 0x0009e>
AIMLAdvancedTestChat.OnGUI () (at Assets/Chatbot/Unity Implementation/Example Scripts/AIMLAdvancedTestChat.cs:70)

I really need to know, how i can solve this.

SkandY123 wrote Aug 12, 2015 at 8:33 AM

Next Hint:

It looks like the Mono runtime Unity relies on may not support that GetDynamicILInfo() call. If you search around the net a bit, there are a number of people asking about similar problems over the past few years. There may be workarounds, but I'm not aware of any immediate solution.

SkandY123 wrote Aug 12, 2015 at 9:49 AM

Ok, i used another dll from another project and it worked. It seems, that Unity has special requirements. i will compile my own dll and change settings as discribed here