Copy link to clipboard
Copied
Hello,
I want to write a function that can read a file in line by line in FDK. How do I write it. If FDK could not. Is there any the way? Please help.
Thank you,
Thai Nguyen
Copy link to clipboard
Copied
Thai,
You can use the "channel" functions for this. I'm far from an expert on channel programming but I've read files line-by-line successfully by going one character at a time, looking for a carriage return.
You can open up the file channel with something like:
ChannelT chan;
FilePathT *path;
UCharT ptr[1];
IntT numRead;
path = F_PathNameToFilePath("C:\\temp\\mydoc.txt", NULL, FDefaultPath);
if((chan = F_ChannelOpen(path,"r")) == NULL)
return;
//read the first character
numRead = F_ChannelRead(ptr, sizeof(UCharT), 1, chan);
...then you can call F_ChannelRead iteratively to build the string in a buffer, looking for a carriage return (ASCII 13) and stopping there. (that is, ptr[0] == 13).
There might be a better way. This is just the way I've gotten it to work. It probably is not a good method for unicode files.
Russ
Copy link to clipboard
Copied
Hi Russ,
That is the answer I am looking for.
Thank you again.
Best regards,
Thai
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more