irswat Posted November 6, 2016 Share Posted November 6, 2016 ;string[] SVE_DumpArray=new string[31] Event OnInit() if ((SVE_DumpArray[0]!="initialized") || (!SVE_DumpArray[0])) string[] SVE_DumpArray=new string[31] SVE_DumpArray[1]="initialized" endif endEvent results in the following compiler errors. ...SVE_ParserEngine.psc(25,6): only arrays can be indexed...SVE_ParserEngine.psc(25,22): cannot compare a none to a string (cast missing or types unrelated)...SVE_ParserEngine.psc(25,44): variable SVE_DumpArray is undefined...SVE_ParserEngine.psc(25,44): only arrays can be indexed Understandable. So I chance the declaration to: string[] SVE_DumpArray = new string[31] and I get compiler error "...SVE_ParserEngine.psc(21,25): no viable alternative at input 'new'" I don't understand. Any ideas? Link to comment Share on other sites More sharing options...
FrankFamily Posted November 6, 2016 Share Posted November 6, 2016 First error is because you use the array before declaring, second is because new must be within a function or event to check to see if it's initialized you can do this if !SVE_DumpArrayi.e. if SVE_DumpArray == nonebut i don't see the need to check that since when the scripts runs oninit the array will be guaranteed empty and after that oninit will not run again until the object is reset in which case the array is destroyed and empty again. string[] SVE_DumpArray Event OnInit() SVE_DumpArray = new string[31] endEventTo initialize the array like a "new outside of functions" you can make it a property and add elements on ck too. Link to comment Share on other sites More sharing options...
irswat Posted November 6, 2016 Author Share Posted November 6, 2016 thanks FF. Originally the check was in the main function. Link to comment Share on other sites More sharing options...
Recommended Posts