[SOLVED] File_str_readto with char* pointer

Posted By: Reconnoiter

[SOLVED] File_str_readto with char* pointer - 10/17/16 11:28

Howdy,

I want to use a char* pointer for file_str_readto function so I can read-out larger text files (correct me if I misunderstood that).
But I can't seem to get it working with char*. What I basically want to do is read the large text file line by line.

This is what I had when using a STRING* to read the lines:
Code:
function read_line(var fHnd) {
	str_cpy(tmp_str, ""); //reset previous read lines
	file_str_readto(fHnd, tmp_str, "\n", 999999); //read next line
	str_trim(tmp_str); //remove spaces from value
	str_trunc(tmp_str, 1); //remove \n (/remove delimiter)
}



How to change it so file_str_readto use a char* instead of a STRING* and than copy's that read line to the STRING* ?
(I am mainly having difficulties resetting the char* and converting that 1 line to STRING*)

Thanks for taking the time.
Posted By: txesmi

Re: File_str_readto with char* pointer - 10/17/16 17:04

Hi,
as far as I understand from the manual the 10K characters limit applies to the resulting string, not the whole file size. If your text lines are shorter it should not be problems at all, I guess. Are your text lines longer than 10K characters? crazy
Posted By: Reconnoiter

Re: File_str_readto with char* pointer - 10/17/16 19:10

Hi txesmi, tnx for replying, I know what it is now. I added a periodic wait to the function cause the engine can't create >1000 objects with an initialization action at the same time. But in doing so I forgot that in an other function the file got closed. grin blush
Sry for the confusion. Also I pleasantly suprised in the loading speed from a text file, seems only ent_create really eats some fps away which is to be expected with e.g. 2500 ents.

offtopic: by the way do you also have any game projects your are currently working on or planning on to release? I would be interested to see what you can make. wink
Posted By: txesmi

Re: File_str_readto with char* pointer - 10/19/16 14:07

Originally Posted By: Reconnoiter
are currently working on or planning on to release?

Not really, I always lacked the necessary artist. frown

I am looking forward!
Posted By: Reconnoiter

Re: File_str_readto with char* pointer - 10/19/16 19:23

Yeah that is an annoying one. You can try to buy some assets, sometimes they have good deals. But the conversion progress can be a pain (still a time saver for complex models).
Posted By: txesmi

Re: File_str_readto with char* pointer - 10/20/16 05:10

Yes, its a pain. I always got stuck on art part. I recently knew a draftsman interested on game development but he has to learn tons of things and we only meet a couple of times a month. Snail rythm but hopefull grin
© 2024 lite-C Forums