SirMacMoneysack Posted May 12, 2016 Share Posted May 12, 2016 Hi i work on a project in this project i have to access a JSON DB with the same Searchparameters, the first 2 searches work fine, but the 3. one fails - the values are the same all times Thats the script i use : string auswertung(string mmsg){ integer i=0; string temp="?"; string aktMp=""; do { aktMp=aktM+(string)i; temp=llJsonGetValue(db,[aktMp,"name"]); if(temp==JSON_INVALID) // only for debug llWhisper(0,"JSON_INVALID"); // only for debug if(temp!=JSON_INVALID) { if(temp==mmsg) return llJsonGetValue(db,[aktMp,"antwort"]); } ++i; } while(i<=12); // Max Entry in DB per use return NOTF;} thats the values i use to start the script: mmsg = "Pause +"aktM="H1"NOTF="DSNF"db={"H112":{"name":"ENDE","antwort":"ende"},"H110":{"name":"SAVE","antwort":"Okay"},"H11":{"name":"Pause +","antwort":"P+"},"H13":{"name":"Pause -","antwort":"P-"},"H14":{"name":"Rahmen -","antwort":"1010"},"H15":{"name":"Reset","antwort":"1012"},"H16":{"name":"Rahmen +","antwort":"1011"},"H17":{"name":"Farbe","antwort":"1019"},"":{"name":"P+","antwort":""},"":{"name":"P+","antwort":""}} i checked all values doubble but cant see the problem, everytime i call this script - if works 2 times fine then it returns only JSON_INVALID until i reset it - then it works fine agin 2 times and the problem is backplease tell me whats wrong with this code? Link to comment Share on other sites More sharing options...
NiceCo Posted May 12, 2016 Share Posted May 12, 2016 This is the "LSL Scripting" forum. Shouldn't you be asking in a JSON forum? This is not a JSON forum. Link to comment Share on other sites More sharing options...
Rolig Loon Posted May 12, 2016 Share Posted May 12, 2016 NiceCo wrote: This is the "LSL Scripting" forum. Shouldn't you be asking in a JSON forum? This is not a JSON forum. LSL supports JSON. See http://wiki.secondlife.com/wiki/Json_usage_in_LSL . Link to comment Share on other sites More sharing options...
Dora Gustafson Posted May 12, 2016 Share Posted May 12, 2016 NiceCo wrote: This is the "LSL Scripting" forum. Shouldn't you be asking in a JSON forum? This is not a JSON forum. It is proper:) LSL has JSON functionality http://wiki.secondlife.com/wiki/Json_usage_in_LSL :smileysurprised::smileyvery-happy: Link to comment Share on other sites More sharing options...
SirMacMoneysack Posted May 12, 2016 Author Share Posted May 12, 2016 tx for this link - but i know this source of information and use it to build this script but there is no Information about this kind of problems and its a Part of LSL Scripting, so i am right here i think. But if you know a JSON Forum here - i will try my luck there - Link to comment Share on other sites More sharing options...
SirMacMoneysack Posted May 12, 2016 Author Share Posted May 12, 2016 tx for this link - but i know this source of information and use it to build this script but there is no Information about this kind of problems and its a Part of LSL Scripting, so i am right here i think. But if you know a JSON Forum here - i will try my luck there - Link to comment Share on other sites More sharing options...
wherorangi Posted May 12, 2016 Share Posted May 12, 2016 undefined json name in the json string returns unpredicatable results. I made a test out of your script to show this. If uncomment the undefined records then will get undefined (unpredictable) returns string NOTF = "DSNF";string db;string aktM;string auswertung(string mmsg){ integer i = 0; string temp = "?"; string aktMp = ""; do { aktMp = aktM + (string)i; temp = llJsonGetValue(db,[aktMp,"name"]); //if (temp == JSON_INVALID) // only for debug // llWhisper(0, "JSON_INVALID"); // only for debug if (temp != JSON_INVALID) return llJsonGetValue(db,[aktMp,"antwort"]); ++i; } while(i <= 12); // Max Entry in DB per use return NOTF;}default{ touch_start(integer total_number) { db = "{" + "\"H112\":{\"name\":\"ENDE\",\"antwort\":\"ende\"}," + "\"H110\":{\"name\":\"SAVE\",\"antwort\":\"Okay\"}," + "\"H11\":{\"name\":\"Pause+\",\"antwort\":\"P+\"}," + "\"H13\":{\"name\":\"Pause -\",\"antwort\":\"P-\"}," + "\"H14\":{\"name\":\"Rahmen -\",\"antwort\":\"1010\"}," + "\"H15\":{\"name\":\"Reset\",\"antwort\":\"1012\"}," + "\"H16\":{\"name\":\"Rahmen +\",\"antwort\":\"1011\"}," + "\"H17\":{\"name\":\"Farbe\",\"antwort\":\"1019\"}" //+ "\"\":{\"name\":\"P+\",\"antwort\":\"\"}," // undefined json name //+ "\"\":{\"name\":\"P+\",\"antwort\":\"\"}" // returns unpredictable results + "}"; aktM = "H1"; string m = "Pause +"; integer i; llOwnerSay("begin..."); for (i = 1; i <= 4; i++) { string r = auswertung(m); llOwnerSay®; } llOwnerSay("...end"); }} Link to comment Share on other sites More sharing options...
SirMacMoneysack Posted May 14, 2016 Author Share Posted May 14, 2016 oh sometimes will not see the woods too mutch trees - this undef. JSON is a multfunktion of the script that calls this one - sorry dont reg the problem - so think if i fixed the propblem - it will work fine - tx for this push of my nose to this fact. Link to comment Share on other sites More sharing options...
wherorangi Posted May 15, 2016 Share Posted May 15, 2016 is all good Mac sometimes like you say all it takes is someone else to put a fresh eye on a issue when we been staring at it for too long ourselves. We can all end up in that state sometimes all the best with your project Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now