[comp.sys.amiga.programmer] DOSBase

specter@disk.uucp (Byron Max Guernsey) (06/13/91)

Does the dos library always need to be opened? I normally open it, but I noticed
that I forgot one time and it worked fine with the DOS calls. (I think I was
using Delay() ) I guess it is poor practice not to open it, since if all dos
using processes were gone you would be out of luck correct?

Byron
-- 
Byron 'Maxwell' Guernsey                      |       ///  //\\
specter@disk.UUCP     or                      |      ///  //  \\
uunet!ukma!corpane!disk!specter               |  \\\///  //====\\
"All we are, is dust in the wind dude!" - Ted |   \\\/  //      \\ m i g a

S_ASCHMIDT@iravcl.ira.uka.de (|S| Angela Schmidt) (06/13/91)

In <1991Jun13.072854.12241@disk.uucp> specter@disk.uucp writes:

> Does the dos library always need to be opened? I normally open it, but I noticed
> that I forgot one time and it worked fine with the DOS calls. (I think I was
> using Delay() ) I guess it is poor practice not to open it, since if all dos
> using processes were gone you would be out of luck correct?
> 
> Byron

The dos.library will be opened while executing the bootblock of a booting
disk. So it is open when your program starts. But you should open it
yourselve, since otherwise you can't tell OpenLibrary which versionnumber
you need. And it's no nice style not to open and close it. Even if some
C-startups think it's not necerssary to close it....

> -- 
> Byron 'Maxwell' Guernsey

Bye

Angela




---------------------------------------------------------+---------------------
Angela Schmidt   Internet: S_ASchmidt@iravcl.ira.uka.de  |        //
(Nessy in IRC)   BITNET:   UK8B@DKAUNI2.BITNET           | Amiga //
                 Phone:    +49 731 712316 & 721 6904-263 |   \\ // only 1000
                           MEZ: (10am-9pm)  (12pm-10pm)  |    \X/ the real one!
---------------------------------------------------------+---------------------

mks@cbmvax.commodore.com (Michael Sinz) (06/14/91)

In article <1991Jun13.072854.12241@disk.uucp> specter@disk.uucp (Byron Max Guernsey) writes:
>Does the dos library always need to be opened? I normally open it, but I noticed
>that I forgot one time and it worked fine with the DOS calls. (I think I was
>using Delay() ) I guess it is poor practice not to open it, since if all dos
>using processes were gone you would be out of luck correct?

The reason you may have worked is because you are a C program with standard
startup.  Most startup code for C (?can I say all?) automatically set up
DOSBase for you.  (They also set up SysBase...)  So in C, you normally would
not need to open DOSBase.

/----------------------------------------------------------------------\
|      /// Michael Sinz  -  Amiga Software Engineer                    |
|     ///                   Operating System Development Group         |
|    ///   BIX:  msinz      UUNET:  rutgers!cbmvax!mks                 |
|\\\///                                                                |
| \XX/     "I don't think so" said Ren'e Descartes, then he vanished.  |
\----------------------------------------------------------------------/

jdickson@jato.jpl.nasa.gov (Jeff Dickson) (06/14/91)

In article <1991Jun13.120849.26251@ira.uka.de> S_ASCHMIDT@iravcl.ira.uka.de (|S| Angela Schmidt) writes:
>In <1991Jun13.072854.12241@disk.uucp> specter@disk.uucp writes:
>
>> Does the dos library always need to be opened? I normally open it, but I noticed
>> that I forgot one time and it worked fine with the DOS calls. (I think I was
>> using Delay() ) I guess it is poor practice not to open it, since if all dos
>> using processes were gone you would be out of luck correct?
>> 
>> Byron
>
>The dos.library will be opened while executing the bootblock of a booting
>disk. So it is open when your program starts. But you should open it
>yourselve, since otherwise you can't tell OpenLibrary which versionnumber
>you need.

	I think that the more important point here is that opening the DOS
library prevents it from going away. 

 And it's no nice style not to open and close it. Even if some
>C-startups think it's not necerssary to close it....
					  ^^^^

	They're broken then if the DOS library isn't closed when the program
exits.
>
>> -- 
>> Byron 'Maxwell' Guernsey
>
-jeff

carolyn@cbmvax.commodore.com (Carolyn Scheppner - CATS) (06/14/91)

In article <1991Jun13.072854.12241@disk.uucp> specter@disk.uucp (Byron Max Guernsey) writes:
>Does the dos library always need to be opened? I normally open it, but I noticed
>that I forgot one time and it worked fine with the DOS calls. (I think I was
>using Delay() ) I guess it is poor practice not to open it, since if all dos
>using processes were gone you would be out of luck correct?

Generally, due to bad early example code, most programs that
OpenLibrary dos.library themselves put the result in a
variable called DosBase.  This is pretty much a meaningless exercise
since amiga.lib is looking for a variable called DOSBase (note
the capitalization).  The standard amiga and SAS startup codes
(like c.o) OpenLibrary dos.library and put the result in the correctly
named variable (DOSBase) for you.

-- 
==========================================================================
 Carolyn Scheppner -- Tech. Mgr. CATS - Commodore Amiga Technical Support
 PHONE 215-431-9180 {uunet,rutgers}!cbmvax!carolyn  carolyn@commodore.com

 Spice up old code with a dazzling array of pointers to void functions.
==========================================================================

ecarroll@maths.tcd.ie (Eddy Carroll) (06/17/91)

specter@disk.uucp writes:
> [ My program works, even when I forget to open dos.library ]
> 
> Byron

S_ASCHMIDT@iravcl.ira.uka.de (|S| Angela Schmidt) writes:
> The dos.library will be opened while executing the bootblock of a booting
> disk. So it is open when your program starts. But you should open it
> yourselve, since otherwise you can't tell OpenLibrary which versionnumber
> you need.

jdickson@jato.Jpl.Nasa.Gov (Jeff Dickson) writes:
>	I think that the more important point here is that opening the DOS
>library prevents it from going away. 

Everyone seems to be missing the main point here: you need to open dos.library
to get a pointer to DOSBase in a legal manner. Without this pointer, you have
no way of calling the functions in dos.library. (Of course, as Jeff said,
it's important to keep the library open as long as you are using it, or it
may disappear from under your feet.)

Now, the standard startup code used for C compilers will automatically open
dos.library for you and initialise the global DOSBase accordingly. So, as long
as you're writing in C, you don't need to explicitly open dos.library yourself.
The exception is if you're writing for Kickstart 2.0 and making use of the
new DOS functions. In this case, you probably want to open it yourself so
that you can check the version number (as noted by Angela above).

The fact that the bootblock on a disk opens dos.library is irrelevant.

It's bad style to open a library yourself and then forget to close it. You can
get away with it for dos.library at the moment, but it conceivably might cause
problems in the future. (Of course, it's not quite as bad as closing a library
twice by mistake :-)

Eddy
-- 
Eddy Carroll           ----* Genuine MUD Wizard  | "You haven't lived until
ADSPnet:  cbmuk!cbmuka!quartz!ecarroll           |    you've died in MUD!"
Internet: ecarroll@maths.tcd.ie                  |   -- Richard Bartle

steve@wildcat.UUCP (Steve Holland) (06/19/91)

>In article <1991Jun13.072854.12241@disk.uucp> specter@disk.uucp (Byron Max Guernsey) writes:
>Does the dos library always need to be opened? I normally open it, but I noticed
>that I forgot one time and it worked fine with the DOS calls. (I think I was
>using Delay() ) I guess it is poor practice not to open it, since if all dos
>using processes were gone you would be out of luck correct?
  The Lattice/SAS startup code automatically opens the dos.library. If you
use your own startup code, you MUST open it yourself.
--
 ----------->Steve Holland<-----------
 Internet: wildcat!steve@alphalpha.com| "I never let my schooling get in the
 USENET:  ...!alphalpha!wildcat!steve | way of my education" -Mark Twain