Work with filestrings read by BaseFile
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 01/12/2005 at 06:03, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 7 XL
Platform: Windows ;
Language(s) : C.O.F.F.E.E ;---------
Hello out there,
I am quite new on coding C.O.F.F.E.E. To start my lessions on filescripting, I am coding a menuplugin to import OBJ-files.
Unfortunately C.O.F.F.E.E, thus plattform independent, is horrible slow (I think because it is an interpreter, although compiling did not make it faster).
Here is the way the file is read:
I read the file into a long string with BaseFile->Readstring. Then I am trying to splitt this string linewise and access data in the line.
Therefore I am searching CRLF-signs in te string with the strstr-function. I got some tipps from other users, that this function is very slow. (Hello Maxon: Is it like this and if, why?)
Does anybody have a tuning-trick to speed up string-operations like these in C.O.F.F.E.E., perhaps using other functions than strstr/strchr?
Or does anybody have a tipp for me, how reading a file could be done quicker?
As I am not very familiar with VC++ and because it would no longer be plattform-idependent I would prefer not to recode in C++-SDK (even if it runs much faster then).
Thanks for help everybody,
COFFEJUNKIE
Ps: Sorry for my English, I did not speak or write it for longer now... -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 10/12/2005 at 04:57, xxxxxxxx wrote:
I don't know about the performance, but this is a function that I have used to extract a line in C.O.F.F.E.E.:
// Remove a line from data and return it // Must be called by reference: getline(&data) getline(data) { var pos = strstr(data, "\n"); var line = strmid(data, 0, pos-1); data = strmid(data, pos+1, sizeof(data)); return line; }
This is an example of how it's used:
main() { // Open file for reading var f = new(BaseFile); f->Open(file); // Read the whole file var data = f->ReadString(f->GetLength()); // Read the number of objects var max_index = evaluate(getline(&data)); // Loop through objects var i; for (i = 0; i < max_index; ++i) { var obj = getline(&data); if (i == index) { // Output the name of obj number 'index' name = obj; } } ... }
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 16/12/2005 at 06:48, xxxxxxxx wrote:
Hello Mikael,
first of all, thanks for your answer. There is only one question I have and do not understand in your code:
Your code to remove the extracted line from the datastring is
data = strmid(data, pos+1, sizeof(data));but I think you have to reduce sizeof(data) by the amount of removed characters like
data = strmid(data, pos+1, sizeof(data)-pos);
or is this wrong? And if so, why (perhaps because of possible unicode?)
Best greetings,
COFFEJUNKIE -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/12/2005 at 10:27, xxxxxxxx wrote:
That's just me being lazy. The docs said that strmid ignored the size going beyond the length of the string, so I didn't bother thinking of what to subtract (pos, pos+1 or pos-1). Your version is better, at least if you've chosen the right amount to subtract...