Hello there,
I'm new to the Lite C language, therefore i'm met with some problems with my school project and is hoping any kind souls out there could help me with this.
You see, I'm trying to extract some specific values
from a .txt file such as the one below.
<?xml version="1.0"?>
<Song>
<Properties>
blah blah
...
...
blah blah
</Properties>
<Data>
<Note time="1.9375" duration="0.0" track="0" >
</Note>
<Note time="1.9375" duration="0.0" track="1" >
</Note>
<Note time="2.125" duration="0.0" track="0" >
</Note>
<Note time="2.125" duration="0.0" track="1" >
</Note>
<Note time="2.375" duration="0.0" track="0" >
</Note>
<Note time="2.375" duration="0.0" track="1" >
</Note>
</Data>
</Song>
And so right now I'm trying to extract all the "Note time" and "track" values and store them into two seperate arrays. I've just started on this, so looking through at the game manual library, I intended to
use file_find to aid me on this.
And so, I've successfully extracted the first "Note time" value which is 1.9375 with the code below and first display it as text on the screen.
var filehandle;
STRING* time_str = "";
STRING* track_str = "";
TEXT* timing_txt =
{
pos_x = 0;
pos_y = 0;
//string(greeting_str);
string(time_str);
flags = VISIBLE;
}
TEXT* track_txt =
{
pos_x = 0;
pos_y = 50;
string(track_str);
flags = VISIBLE;
}
function read_file()
{
int eof = 0;
while(eof != -1)
{
file_find(filehandle, "<Data>");
file_find(filehandle, "time=\"");
eof = file_str_readto(filehandle, time_str, "\"", 4000); // Read till the set delimiter
}
}
function main()
{
video_mode = 7;
screen_color.blue = 150;
filehandle = file_open_read("testversion.sng");
read_file();
file_close(filehandle);
}
But when i try to extract the "track" value into track_str with the following updates to the codes in the read_file() function,
both text values appear as 0 value on the screen.
function read_file(STRING* filename)
{
int eof = 0;
while(eof != -1)
{
file_find(filehandle, "<Data>");
file_find(filehandle, "time=\"");
eof = file_str_readto(filehandle, time_str, "\"", 4000); // Read till the set delimiter
file_find(filehandle, "track=\"");
eof = file_str_readto(filehandle, track_str, "\"", 4000);
}
}
Could anyone shed some light as to where did i went wrong? I believe it's my understanding of the file_find method to be the problem though. And thank you very much in advance!