For all those who are interested in a solution:

Code:
STRING* file_read_line(var myHandle, int nLineNr) {
	if (!myHandle) return "";
	
	var oldPosition = file_seek(myHandle,0,4);
	STRING* res = str_create("#1000");
	
	// Find the right line
	file_seek(myHandle,0,0);
	
	int i;
	int j;
	for (i=0;i<=nLineNr;i++) {
		str_cpy(res,"");
		j = file_str_readto(myHandle,res, "\r\n", 1000);
		if (j == -1) {
			file_seek(myHandle,oldPosition,0);
			return "";
		}
		else
		{
			if (i == nLineNr) {
				file_seek(myHandle,oldPosition,0);
				return res;
			}
		}
	}
}



EDIT:
In addition a function to read the line count of a text file:
Code:
int file_count_lines(var myHandle) {
	if (!myHandle) return -1;
	
	var oldPosition = file_seek(myHandle,0,4);
	
	file_seek(myHandle,0,0);
	
	int res = 0;
	int j = 0;
	STRING* tempStr = str_create("#1000");
	while (1) {
		j = file_str_readto(myHandle,tempStr,"\r\n", 1000);
		if (j == -1) {
			break;
		}
		else
		{
			res +=1;
		}
	}
	file_seek(myHandle,oldPosition,0);
	return res;
}



Last edited by PadMalcom; 10/02/10 12:55.