Quantcast
Viewing all articles
Browse latest Browse all 28

Problem reading from array at runtime

Ok, so basically I am making a game engine, and am having it so it reads from a code file at runtime. This is a short snippet that is causing the problem: (varList is a string, varArray is an array, I am splitting spaces to read the code file, so str is the string after the first space, the cases is the word before the first space) case "var": varList = varList + str + "|"; varArray = varList.ToString().Split("|"[0]); case "getkey": var varIndex : int = 999; var error : boolean = false; var isDone : boolean = false; for (var iCount : int = 0; iCount < varArray.Length; iCount++) { if (varArray[iCount] == str && isSub && error == false && isDone == false) { varIndex = iCount; error = false; isDone = true; } } if (error || isDone == false || varIndex == 999) { print("Variable, '" + str + "' not found!"); } else { var key; while (key == "") { key = Input.anyKeyDown; } print("Key pressed : " + key.ToString()); } break; sorry, formatting a bit messed up, but basically its throwing this error repetitively: NullReferenceExceptioon: Object reference not set to instance of an object Boo.Lang.Runtime>RuntimeServices.InvokeBinaryOperator (System.String operatorName, System.Object lhs System.Object rhs) Referring to the line of code: varList = varList + str + "|";

Viewing all articles
Browse latest Browse all 28

Trending Articles