Gregory McLeod Posted April 27, 2014 Share Posted April 27, 2014 I am trying to develo a user function which will give me the indices of a specific string in a source string. I keep getting a problem with variable not being defined within scope.I paste the c ode for the complete function tester script.string Source1 = "XbcdefghijklmnopqrstuvwxyX"; string StrInStrIndex(string psSrc,string psArg,integer piNum) { integer liIndex; integer liSrcLen; string psSrcTemp; list laFound; if (llSubStringIndex(psSrc,psArg) == -1) { return "-1"; } liIndex = llSubStringIndex(psSrc,psArg); llSay(0,"liIndexA: " + (string)liIndex); liSrcLen = llStringLength(psSrc); llSay(0,"liSrcLenA: " + (string)liSrcLen); if (liIndex == (liSrcLen -1)) { return (string)liIndex; } laFound = []; llSay(0,"laFoundA: " + llList2CSV(laFound)); laFound += [liIndex]; llSay(0,"laFoundB: " + llList2CSV(laFound)); if ((liIndex == 0) & (liSrcLen == 1)) { return llList2CSV(laFound); } else { psSrcTemp = llGetSubString(psSrc,(liIndex + 1), -1); llSay(0,"psSrcTempA: " + psSrcTemp); do { integer liSrcLen1; llSay(0,"Start DO loop"); liScrLen1 = llStringLength(psSrcTemp); llSay(0,"liSrcLen1A: " + (string)liSrcLen1); if (liSrcLen1 == 0) { return llList2CSV(laFound); } else { liIndex = llSubStringIndex(psSrcTemp,psArg); llSay(0,"liIndexB: " + (string)liIndex); if (liIndex == -1) { return llList2CSV(laFound); } else { laFound += [liIndex]; llSay(0,"laFound: " + llList2CSV(laFound)); psSrcTemp = llGetSubString(psSrcTemp,(liIndex + 1),-1); llSay(0,"psSrcTempB: " + psSrcTemp); } } } while (liSrcLen1 > 0); } return llList2CSV(laFound); } default { state_entry() { llSay(0, "Hello, Avatar!"); } touch_start(integer total_number) { string Result; llSay(0,"Source1: " + Source1); Result = StrInStrIndex(Source1,"X",-1); llSay(0,"Result1: " + Result); } } Can anyone tell me what I am doing wrong? Link to comment Share on other sites More sharing options...
Nova Convair Posted April 27, 2014 Share Posted April 27, 2014 liScrLen1 is not defined. 1 Link to comment Share on other sites More sharing options...
Gregory McLeod Posted April 27, 2014 Author Share Posted April 27, 2014 DUH! Too long c oding session! Link to comment Share on other sites More sharing options...
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now