Read Data from txt-file

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 11/02/2008 at 03:45, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   R10 
Platform:   Windows  ;   
Language(s) :     C++  ;

---------
Hi
i started writing a little plugin to Read Values out of a textfile to an RealArray. It's a command plugin that looks like this:
> Filename fn;
> BaseFile *bf = BaseFile::Alloc();
>
> if(!fn.FileSelect(FSTYPE_ANYTHING,0,NULL))
> {
>
>> MessageDialog("Data Import Cancelled");
> return FALSE;
>
> }
>
> if(bf->Open(fn, GE_READ))
>
>> MessageDialog("Data Import OK");
Now i want to read the values stored in the selected file to an Realarray or an Vectorarray for example. Does anybody know how to do this?
I tried:
> bf->ReadReal(*v);
but i don't know which variable i have to set for *v...
Hope someone knows....

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 11/02/2008 at 06:11, xxxxxxxx wrote:

Is your file a text file or a binary file, becaue if it is a text file ReadReal wont help you. In this case you have to use ReadChar/ReadUChar. As parameter you pass the pointer to a char (or the indexed cell of an array).

cheers,
Matthias

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 11/02/2008 at 12:23, xxxxxxxx wrote:

Hi Matthias,
my file is a text file, tabulator seperated, so it seems that i have to use the ReadChar function. Sorry that i have to ask again, but i really don't know how to use this pointer *v. Can you post a little example code?
Thx

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 11/02/2008 at 14:06, xxxxxxxx wrote:

CHAR c;
bf->ReadChar(&c;);

Your best bet here is to build a class or method that reads the text file and tokenizes by separator. In my case, I use two separate classes, FileReader and StringTokenizer. FileReader reads a line of text (using End-of-line or End-of-File) into a buffer (CHAR array). StringTokenizer than divies up the line into tokens using separator characters (spaces or tabs in most of my cases).

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 12/02/2008 at 03:06, xxxxxxxx wrote:

Thx for that Robert. Wrote a FileReader and some kind of String Tokenizer and it works 🙂