Not sure where to post this: equivalent of C's getc() function in Pascal?
First: I think this is the right group, it's for Pascal right? :)
: I'm trying to convert a bit of C code into some pascal code, and I ran
: into trouble when trying to read data from a .PCX file. In the pascal
: code, I have the following defined:
: FILENAME : file;
: data:integer;
: in C it looks like:
: FILE *filename;
: unsigned char data;
: the function is called like this in C:
: data = (unsigned char)getc(filename);
: I tried doing the following in pascal:
: BlockRead(FILENAME,data,1);
: but I get some sort of file access problem or something. Maybe my
: pascal variables aren't declared right, or maybe BlockRead is the wrong
: function. could someone please help me out here?
Second: It always helps if you incorporate some code (more then you have
done :) ). But I give it a try anyway.
Since you have fileaccess problems (*exactly* what errorcode did you get?)
a problem can be that you don't use assign()/reset() or the file is already
in use by another program. (I hope you you use close(), otherwise you are
going to have to many files open and MessDoze pukes)
Otherwise I can't see where it would go wrong... :-/
One less good thing is that you are using BlockRead(FILENAME,data,1) to
read one record. It's better to use read(filename, data) for that.
Can you send us some of your Pascalcode? It would be easier to find the
problem (I hope... ;) ).
/Jonas
+------------------------------------------------------------------------+
| Who? Me?: Jonas Steverud | If All is One, |
| Home....: http://www.dtek.chalmers.se/%7Ed4jonas | |
+------------------------------------------------------------------------+