how to read a file??

Hi everybody,

i’ve search a way to read a file and i’ve find that :

function Read_File (filename : String, tab : Array) {

	var SR : StreamReader;
    var S : String;
	var i = 0.0;
    SR=File.OpenText(filename);
    S=SR.ReadLine();
    while(S!=null)
    {
	tab[i] = S;
	i++;
    S=SR.ReadLine();
    }
    SR.Close();

}

the file i want to read contains this :

1234
5678

then i want to compare the 2 numbers but the function “Read_File” returns a string

so i’ve tried to do this

the variable tab contains: tab[0] = “1234” and tab[1] = “5678”
so tab[0][0] = “1”;

var trial = 0.0;
if (tab[0][0] == "1"){
trial = 1.0;
}
else{
print("error");
}

and that always prints “error” and i don’t understand why…

i’ve tried another way, i’ve thought it could be possiblr*e to convert each character from the file to its ASCII code but unity doesn’t seem to recognize the function “charCodeAt()”

i’ve tried this :

print(tab[0].charCodeAt(1));

and the result is :

and to finish i’ve tried to convert the character with “parseInt” but without results… :

var code = 0;
print(parseInt(tab[0][1]));

and the result :

can someboy help me?? (with one of the ideas i had or with another)

thanks in advance

i think you need to parse string value to float:

function Read_File (filename : String, tab : Array) {

   var SR : StreamReader;
    var S : String;
   var i = 0.0;
    SR=File.OpenText(filename);
    S=SR.ReadLine();
    while(S!=null)
    {
   tab[i] =  float.Parse(S); <------------
   i++;
    S=SR.ReadLine();
    }
    SR.Close();

}

ok i will try
thanks for your answer