Posted By: laci
Malfunction W1508, Can't load... - 12/14/11 09:41
Hi,
I save a struct array with this code:
After it I try to load with this program:
But I get always the Error:
Malfunction W1508
Can't load test1.SAV
What is wrong ?
I save a struct array with this code:
Code:
#include <acknex.h> #include <default.c> typedef struct TESTSTRUCT { char word1[30]; char word2[30]; } TESTSTRUCT; TESTSTRUCT* test_array; FONT* font1 = "Arial#24"; FONT* infofont = "Arial#24bi"; STRING* str1 = "text 1"; STRING* str2 = "text 2"; STRING* str3 = "text 3"; STRING* str4 = "text 4"; STRING* infostr = "Start"; TEXT* txt1 = {pos_x = 10; pos_y = 10; string (str1); font = font1; flags = SHOW;} TEXT* txt2 = {pos_x = 10; pos_y = 50; string (str2); font = font1; flags = SHOW;} TEXT* txt3 = {pos_x = 10; pos_y = 100; string (str3); font = font1; flags = SHOW;} TEXT* txt4 = {pos_x = 10; pos_y = 150; string (str4); font = font1; flags = SHOW;} TEXT* infotxt = {pos_x = 10; pos_y = 200; string (infostr); font = infofont; flags = SHOW;} /////////////////////////////// function main() { var fhandle; wait(-3); str_cpy(infostr, "read"); test_array = (TESTSTRUCT*)sys_malloc(2 * (sizeof(TESTSTRUCT))); // test1.txt contains 2 lines: // abc;def // ghi;jkl fhandle = file_open_read("test1.txt"); // line 1 file_str_readto(fhandle, test_array[0].word1, ";", 30); file_str_readto(fhandle, test_array[0].word2, "\n", 30); // line 2 file_str_readto(fhandle, test_array[1].word1, ";", 30); file_str_readto(fhandle, test_array[1].word2, "\n", 30); str_cpy(str1, test_array[0].word1); str_cpy(str2, test_array[0].word2); str_cpy(str3, test_array[1].word1); str_cpy(str4, test_array[1].word2); file_close(fhandle); wait(-3); str_cpy(infostr, "save"); add_struct(test_array, 2 * (sizeof(TESTSTRUCT))); result = game_save("test", 1, SV_STRUCT); if (result <= 0) { printf("Save Error!"); } wait(-3); str_cpy(infostr, "reset"); str_cpy(str1, ""); str_cpy(str2, ""); str_cpy(str3, ""); str_cpy(str4, ""); str_cpy(_str(test_array[0].word1), ""); str_cpy(_str(test_array[0].word2), ""); str_cpy(_str(test_array[1].word1), ""); str_cpy(_str(test_array[1].word2), ""); wait(-3); str_cpy(infostr, "end"); sys_exit(NULL); }
After it I try to load with this program:
Code:
#include <acknex.h> #include <default.c> typedef struct TESTSTRUCT { char word1[30]; char word2[30]; } TESTSTRUCT; TESTSTRUCT* test_array; FONT* font1 = "Arial#24"; FONT* infofont = "Arial#24bi"; STRING* str1 = "text 1"; STRING* str2 = "text 2"; STRING* str3 = "text 3"; STRING* str4 = "text 4"; STRING* infostr = "Start"; TEXT* txt1 = {pos_x = 10; pos_y = 10; string (str1); font = font1; flags = SHOW;} TEXT* txt2 = {pos_x = 10; pos_y = 50; string (str2); font = font1; flags = SHOW;} TEXT* txt3 = {pos_x = 10; pos_y = 100; string (str3); font = font1; flags = SHOW;} TEXT* txt4 = {pos_x = 10; pos_y = 150; string (str4); font = font1; flags = SHOW;} TEXT* infotxt = {pos_x = 10; pos_y = 200; string (infostr); font = infofont; flags = SHOW;} /////////////////////////////// function main() { wait(-3); str_cpy(infostr, "reset"); str_cpy(str1, ""); str_cpy(str2, ""); str_cpy(str3, ""); str_cpy(str4, ""); wait(-3); str_cpy(infostr, "load"); test_array = (TESTSTRUCT*)sys_malloc(2 * (sizeof(TESTSTRUCT))); add_struct(test_array, 2 * (sizeof(TESTSTRUCT))); result = game_load("test", 1); if (result <= 0) { printf("Load Error!"); } str_cpy(str1, test_array[0].word1); str_cpy(str2, test_array[0].word2); str_cpy(str3, test_array[1].word1); str_cpy(str4, test_array[1].word2); wait(-3); str_cpy(infostr, "end"); sys_exit(NULL); }
But I get always the Error:
Malfunction W1508
Can't load test1.SAV
What is wrong ?