Re: External predicates : file handling

From: Warwick Harvey <>
Date: Thu 26 Feb 2004 02:29:10 PM GMT
Message-ID: <>
Hi Eddie,

On Thu, Feb 26, 2004 at 09:08:13AM +0200, wrote:
> I am building an application in eclipse in which i use external predicates
> (written in C).
> These predicates access some files (always the same files).
> To do this every time i call an external predicate, i use
> fopen() and fclose() to access the files.
> Is there any way to keep the files open as long as eclipse is running?
> (either by opening a stream in eclipse and passing as an argument to
> external predicate, or by putting the file pointers in global variables),

I've not done it with file pointers, but anything you put into a C static
variable should still be there the next time an external predicate is called
(as long as it doesn't refer to any ECLiPSe data structures, since they can
move around in memory).

So in theory you should be able to write an external predicate which opens
the files, sets everything up, and stores everything you want to refer to
later in static variables, and another one which closes all the files and
cleans up.  The rest of your predicates can then assume the files are open,
and can gain access to them via the static C variables.  As long as you call
the initialisation predicate first (and preferably, your clean-up predicate
last ;), then it should work fine.

Anyway, that's probably the simplest approach, if you're not averse to using
global variables in this fashion (from what you describe, it sounds

Received on Thu Feb 26 14:31:35 2004

This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:27 PM GMT GMT