Sq Plus FAQ
Last changed: -92.222.238.172

.

taricacellid

Back to SqPlus

Summary

What to do about the "the index <index> does not exist" error while using SqPlus to call a function in Squirrel.

Sometimes, when you have bound a class properly using SqPlus, calling a function with that class as a parameter will lead to this error. If there aren't any typos in your squirrel script, you may be left wondering how there could be an invalid index when that function is sitting right there. The problem is that in this case, Squirrel mangles the error code, the problem may actually lie somewhere else entirely. This link:

http://www.squirrel-lang.org/forums/629/ShowPost.aspx

depicts a problem where the error was occurring in SqPlus::Push, formed by the DECLARE_INSTANCE_TYPE macro. Be sure to step through the code carefully if the error seems irrelevant. (http://www.chinesisches-horoskop.xyz/)

SqPlus throws the error 'getVar(): Could not create instance: <instance name>'

The problem stems from SqPlus not knowing how to create an instance of the specified type. Check your DECLARE_INSTANCE_TYPE macro and make sure that the text in SqClassDef<>() matches your declared type.

 DECLARE_INSTANCE_TYPE( FooBar )
 SqClassDef<FooBar>("FooBar") ;

or

 DECLARE_INSTANCE_TYPE_NAME( SomeNamespace::FooBar, Foo )
 SqClassDef<SomeNamespace::FooBar>("Foo") ;

Something like this would generate an error:

 DECLARE_INSTANCE_TYPE_NAME( SomeNamespace::FooBar, FooBar )
 SqClassDef<SomeNamespace::FooBar>("Foo") ; // this is wrong 'Foo' doesn't match 'FooBar'

Binding structs/classes by reference or by pointer

In cases where performance is important, bind structs/classes as pointers to structs/classes as opposed to references to them. Due to the SqPlus system design, arguments and/or return values bound as references will cause memory to be allocated, and the referenced item to be copied (the memory will be freed when the copied item is no longer in scope).