[comp.sys.atari.st] Fsfirst/Fsnext question

klute%trillian.irb@unido.uucp (Rainer Klute) (08/25/88)

Hello ST-hackers,
 
does anyone know about a 'legal' way to do something like this:
 
 
Routine_A:                    Routine_B:
==========                    ==========
Fsfirst (...);                 .
Fsnext ();                     .
 .                            Fsfirst (...);
 .                            Fsnext ();
Call_Routine_B ();             .
 .                             .
 .                            return;
Fsnext ();
 
 
+---------------------------+------------------------------------------+
|   Rainer Klute            | UUCP:   klute@unido.uucp                 |
|   University of Dortmund  |            (...uunet!mcvax!unido!klute)  |
|   Dept. of CS             | BITNET: klute@unido.bitnet               |
|   P.O. Box 500500         |                                          |
| D-4600 Dortmund 50        |                                          |
+---------------------------+------------------------------------------+
|                     Federal Republic of Germany                      |
+----------------------------------------------------------------------+

leo@philmds.UUCP (Leo de Wit) (08/26/88)

In article <566@laura.UUCP> klute@trillian.UUCP (Rainer Klute) writes:
|Hello ST-hackers,
| 
|does anyone know about a 'legal' way to do something like this:
| 
| 
|Routine_A:                    Routine_B:
|==========                    ==========
|Fsfirst (...);                 .
|Fsnext ();                     .
| .                            Fsfirst (...);
| .                            Fsnext ();
|Call_Routine_B ();             .
| .                             .
| .                            return;
|Fsnext ();

Use Fsetdta(dtabuf); just before each invocation of either Fsfirst() or
Fsnext(); GEMDOS uses the first 21 bytes of the DTA-buffer to keep
track.  There is little overhead in the use of this GEMDOS call, since
it merely sets a pointer to 'dtabuf' in the basepage (you could even do
it yourself 8-).  Of course Routine_A and Routine_B should each use
their own 'dtabuf'.  Note that this 44-byte buffer must be
word-aligned.
I thought that the default DTA-buffer (i.e. if your program does not
set it) is at basepage + 0x80 (yes, writing over your argument string 8-).

                         Leo.

wes@obie.UUCP (Barnacle Wes) (08/28/88)

In article <566@laura.UUCP>, klute%trillian.irb@unido.uucp
(Rainer Klute) writes:

> does anyone know about a 'legal' way to do something like this:

Sure, make your code look like:

Routine_A:			Routine_B:
==========			==========
DTA *save, my_dta;
save = Fgetdta();
Fsetdta(my_dta);
 .
Fsfirst (...);
Fsnext ();
 .
Call_Routine_B ();
 .				DTA *save, local_dta; 
 .				save = Fgetdta();
 .				Fsetdta(local_dta);
 .				 .
 .				Fsfirst (...);
 .				Fsnext ();
 .				 .
 .				Fsetdta(save);
 .				return;
 .
Fsnext();
Fsetdta(save);
return;

In general, it is a good idea to always work with your own DTA.  You can
even use this to advantage in different routines, as long as you are
careful to restore the previous DTA before returning.

CAVEAT: I wrote this off the top of my head, without consulting ANY
manuals at all.  The intent is correct, but I am sure the code wouldn't
compile and run at all.  Look up the calling sequence for Fsetdta and
Fgetdta CAREFULLY before trying this.
-- 
                     {hpda, uwmcsd1}!sp7040!obie!wes
           "Happiness lies in being priviledged to work hard for
           long hours in doing whatever you think is worth doing."
                         -- Robert A. Heinlein --

URZ90@DMSWWU1A.BITNET (Rainer Perske) (09/06/88)

Rainer Klute (mcvax!unido!laura!trillian!klute@uunet.uu.net) asks:
>Hello ST-hackers,
>does anyone know about a 'legal' way to do something like this:
>
>Routine_A:                    Routine_B:
>==========                    ==========
>Fsfirst (...);                 .
>Fsnext ();                     .
> .                            Fsfirst (...);
> .                            Fsnext ();
>Call_Routine_B ();             .
> .                             .
> .                            return;
>Fsnext ();

I've never tried it myself, but it should work, when you build
Routine B like:

...
olddta=Dgetdta();
Dsetdta(newdta);
.
Fsfirst(...);
Fsnext();
.
Dsetdta(olddta);
return;

(I'm not sure I've used the correct names, but you'll know what I mean.)

Rainer

------------------------------------------------------------------------
Rainer Perske                        EARN/BITNET: PERSKE@DMSWWU5P.bitnet
Institut fuer Kernphysik der         EARN/BITNET: URZ90@DMSWWU1A.bitnet
Westfaelischen Wilhelms-Universitaet
Wilhelm-Klemm-Strasse 9
D-4400 Muenster
Federal Republic of Germany          Telephone: +49 251 83 4974
------------------------------------------------------------------------
Disclaimer: If not otherwise stated, all written above is my own opinion