Here is a couple Ive tested fully... efficiencies were only loosly tested...
Code:
//most efficient on files larger than 10kb
var file_var_count_0(STRING* filename)
{	if(!filename)		return(-1);		//ERROR, not valid filename
	long file_len=0, pos, count=0;
	byte* data = file_load(_chr(filename), NULL, &file_len);
	if(!data)			return(-1);		//ERROR, file not found
	for(pos=0; pos<file_len; pos++)		if((long)data[pos]==32)		count++;
	file_load(NULL, data, NULL);
	return(count);
}


and
Code:
//most efficient on files smaller than 50kb
var file_var_count_1(STRING* filename)
{	if(!filename)		return(-1);		//ERROR, not valid filename
	var count=0, file=file_open_read(filename);
	if(!file)			return(-1);		//ERROR, file not found
	while(file_find(file, " ")>=0)	count++;
	file_close(file);	return((var)count);
}




"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial