alexis@ccnysci.UUCP (Alexis Rosen) (04/27/89)
In article <1032@gmdzi.UUCP> yvw@gmdzi.UUCP (Yvo Van Wezemael) writes: >I would like to be able to write a set of external procedures with the >following capabilities: >1) Open a file and due some initialization -> return >2) Call a procedure with gets some values (strings,numbers), and >writes something to the previously opened file. >3) Close the file. > >Now, I know that I can open files in 4D, but this are sequential >files, I need to seek. So the main problem is how to handle an open >file between calls to external procedures, and how to handle "global" >information. Well, you all know how I feel about 4D (although that just might change with V2.0). Still, this isn't too tough. What you really want to know is where to stuff information that you need to preserve between calls to your external. The easiest way to do this is to grab a new handle, move it high, use it, and when you're done pass back the address of the master pointer (which of course won't move). You can put it in an integer or a string (but if in a string, don't try to use the string in the calling program). I forget if 4D's integers are 16 bit or 32, but if they're 16 you can use longints (I seem to recall that 4D has these) or strings. One warning- don't use reals. Some programs may do strange and wonderful things to real numbers on your routine's return, which will blow your mac sky high when you next try to use them as pointers. This may or may not apply to 4D. If you use a lot of memory you should make sure to give 4D extra room under Multifinder. If you're running under MF all the time you might also consider using the MF memory allocation calls, but this may be a Bad Idea- it could fragment MF's memory (there's no MFMHHi that I know of, and even that wouldn't be perfect...). --- Alexis Rosen alexis@ccnysci.{uucp,bitnet} alexis@rascal.ics.utexas.edu (last resort)