GML DS-Map_find_value_result is undefined ?! :(

Dirusym

Member
Hello guys,

i have a big problem in my Code.
I put a .Ini Data on my Website so the Program on any device can reached it and take the data from it.
But in some cases (like every 5 or 6 times) i get this error:

Code:
file_text_write_string argument 2 incorrect type (undefined) expecting a String (YYGS)
 at gml_Object_Game_Control_WebAsyncEvent_1 (line 11) -         file_text_write_string(file,result);
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_Game_Control_WebAsyncEvent_1 (line 11)

So i dont get it, why the most of the time the code work normal and then one time it crashes....

This ist my Code from the Game_Control Object:

HTTP Event:
Code:
var result, evid;
evid = ds_map_find_value(async_load, "id");

switch (evid) {
    case async_ini:
        result = ds_map_find_value(async_load, "result");
        file_delete("Data.ini");
        file = file_text_open_write( "Data.ini" );
        file_text_write_string(file,result);
        file_text_close(file);
        
        alarm[0] = 10;
        break;
}

Please help me :(
 

FrostyCat

Redemption Seeker
Always check async_load[? "status"] before assuming there is a result. If your file is big enough, there will come a point where you will get multiple "in-progress" HTTP events (status 1, has no result) before the final "done" HTTP event (status 0, has result).
GML:
if (async_load[? "id"] == async_ini) {
    switch (async_load[? "status"]) {
        case 1: break;
        case 0:
            // Process async_load[? "result"] here
        break;
        default:
            // Handle error here
    }
}
See this reply for the proper procedures, in particular this summary:
The HTTP event should always contain the following:
  • A check for async_load[? "id"] against a previous request ID
  • Checks for all 3 kinds of values for async_load[? "status"] (1, 0 and <0 as of the time of writing)
  • (if dependent on actual response output) Usage of async_load[? "result"] after confirming both async_load[? "id"] and async_load[? "status"]
Anything less is way too casual and asking for unexpected behaviour.
 
Top