Hi Superku,

thx for your hint! I changed the example, and it works well.
I have done two examples, one for reading ASCII CSV file, and
one for reading Unicode CSV file. Here there is a different:

Reading ASCII:

file_str_readto(fhandle, test_array[0].word1, ";", 30);

Reading Unicode:

temp_str = str_create("#30");
file_str_readtow(fhandle, temp_str, ";", 30);
memcpy(test_array[0].word1, temp_str, 30);

The function file_str_readtow works not right, only with this
work around. (I tried _str() also.)

And I found out, that the Error W1508 comes, if I call the
function add_struct two times.

The examples read from a CSV file into a struct array, and save and
load the data with game_save() and game_load(). It can be useful for
somebody.

Example 1 with ASCII input file:

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;} 

var fhandle;
long array_size;

///////////////////////////////
function create_array()
{
	str_cpy(infostr, "create array");
	
	array_size = 2 * (sizeof(TESTSTRUCT));
	test_array = (TESTSTRUCT*)sys_malloc(array_size);
	if(test_array == NULL)
	{ 
		printf("sys_malloc Error!"); 
	} 
	memset(test_array, 0, array_size);
	add_struct(test_array, array_size);
}

function copy_array()
{
	// ANSI C function !!!
	memcpy(str1, test_array[0].word1, 30);
	memcpy(str2, test_array[0].word2, 30);
	memcpy(str3, test_array[1].word1, 30);
	memcpy(str4, test_array[1].word2, 30);
}

function read_file()
{
	str_cpy(infostr, "read ASCII CSV file: test1.txt");

	// ASCII: 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); 

	file_close(fhandle);

	copy_array();
}

function init_content()
{
	str_cpy(infostr, "init content");

	// ANSI C function !!!
	strcpy(test_array[0].word1, "xyz");
	strcpy(test_array[0].word2, "qwe");
	strcpy(test_array[1].word1, "asd");
	strcpy(test_array[1].word2, "poi");

	copy_array();
}

function save_array()
{
	str_cpy(infostr, "save: test1.SAV");

	result = game_save("test", 1, SV_STRUCT);
	if (result <= 0) 
	{ 
		printf("Save Error!"); 
	} 
}

function load_array()
{
	str_cpy(infostr, "load: test1.SAV");

	result = game_load("test", 1);
	if (result <= 0) 
	{ 
		printf("Load Error!"); 
	} 

	copy_array();
}

function main()
{
	create_array();
	
	on_r = read_file;
	on_i = init_content;
	on_s = save_array;
	on_l = load_array;

	while (1)
	{
		wait(1);
	}
}




Example 2 with Unicode input file:

Code:
#include <acknex.h>
#include <default.c>

typedef struct TESTSTRUCT
{
	char word1[30];
	char word2[30];
} TESTSTRUCT;

TESTSTRUCT* test_array;

FONT* font1 = "Arial Unicode MS#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;} 

var fhandle;
long array_size;

///////////////////////////////
function create_array()
{
	str_cpy(infostr, "create array");
	
	array_size = 2 * (sizeof(TESTSTRUCT));
	test_array = (TESTSTRUCT*)sys_malloc(array_size);
	if(test_array == NULL)
	{ 
		printf("sys_malloc Error!"); 
	} 
	memset(test_array, 0, array_size);
	add_struct(test_array, array_size);
}

function copy_array()
{
	// ANSI C function !!!
	memcpy(str1, test_array[0].word1, 30);
	memcpy(str2, test_array[0].word2, 30);
	memcpy(str3, test_array[1].word1, 30);
	memcpy(str4, test_array[1].word2, 30);
}

function read_file()
{
	STRING* temp_str;

	str_cpy(infostr, "read unicode CSV file: test2.txt");

	// Unicode: test2.txt contains 2 lines:
	// abc;def
	// ghi;jkl
	fhandle = file_open_read("test2.txt"); 
	// line 1
	temp_str = str_create("#30");
	file_str_readtow(fhandle, temp_str, ";", 30); 
	memcpy(test_array[0].word1, temp_str, 30);
	temp_str = str_create("#30");
	file_str_readtow(fhandle, temp_str, "\n", 30); 
	memcpy(test_array[0].word2, temp_str, 30);
	// line 2
	temp_str = str_create("#30");
	file_str_readtow(fhandle, temp_str, ";", 30); 
	memcpy(test_array[1].word1, temp_str, 30);
	temp_str = str_create("#30");
	file_str_readtow(fhandle, temp_str, "\n", 30); 
	memcpy(test_array[1].word2, temp_str, 30);

	file_close(fhandle);

	copy_array();
}

function init_content()
{
	STRING* temp_str;

	str_cpy(infostr, "init content");

	// ANSI C function !!!
	strcpy(test_array[0].word1, "xyz");
	strcpy(test_array[0].word2, "qwe");
	strcpy(test_array[1].word1, "asd");
	strcpy(test_array[1].word2, "poi");

	copy_array();
}

function save_array()
{
	str_cpy(infostr, "save: test2.SAV");

	result = game_save("test", 2, SV_STRUCT);
	if (result <= 0) 
	{ 
		printf("Save Error!"); 
	} 
}

function load_array()
{
	str_cpy(infostr, "load: test2.SAV");

	result = game_load("test", 2);
	if (result <= 0) 
	{ 
		printf("Load Error!"); 
	} 

	copy_array();
}

function main()
{
	create_array();
	
	on_r = read_file;
	on_i = init_content;
	on_s = save_array;
	on_l = load_array;

	while (1)
	{
		wait(1);
	}
}