English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 21 October 2018, 21:30   #1
guy lateur
Registered User

guy lateur's Avatar
 
Join Date: May 2017
Location: Belgium
Age: 45
Posts: 279
Opening a library 'globally'

So let's say you wanted to output some info about your data structures, to the screen and/or to some file. You might open 'dos.library' and put in some _LVOVPrintf() calls. You'd close the library when you're done. If you needed to do this in multiple modules/files/'classes', you might repeat the above procedure in every output routine in every module. But that's probably not the best way to do it.

You should probably write an output module, that opens the library (only once, as a singleton) in some init() routine. Your main application should probably do this, at program startup. Same goes for closing the library. Maybe put some xdef's in the output module, and some xref's in the calling code?

Good idea? Better ideas? How to 'open and close dos only once'?
guy lateur is offline  
Old 21 October 2018, 22:01   #2
meynaf
son of 68k
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 45
Posts: 3,245
You answer your own question. Just create a module for dos stuff.
meynaf is offline  
Old 21 October 2018, 22:14   #3
guy lateur
Registered User

guy lateur's Avatar
 
Join Date: May 2017
Location: Belgium
Age: 45
Posts: 279
Quote:
Originally Posted by meynaf View Post
You answer your own question.
Well that was indeed my intention, yes. Still, it's nice to know at least one other person finds it a good answer to the question, so thanks for confirming my plan!

Edit: I have a tendency to overthink things, I think. Please don't let it bother you..
guy lateur is offline  
Old 22 October 2018, 01:40   #4
alkis
Registered User

 
Join Date: Dec 2010
Location: Athens/Greece
Age: 47
Posts: 448
Usually this OpenLibrary/CloseLibrary thing goes in the "startup" code. You then have variables like _DOSBase which you use in every module you want to use dos. You don't OpenLibrary the dos library every time.

So, the usual startup is like (in some weird pseudocode)
Code:
  OpenLibrary dos
  HandleError or store library pointer
  OpenLibrary whatever
  HandleError or store library pointer
  bsr yoursuperduperprogram
  CloseLibrary dos
  CloseLibrary whatever
  rts
alkis is offline  
Old 22 October 2018, 13:08   #5
guy lateur
Registered User

guy lateur's Avatar
 
Join Date: May 2017
Location: Belgium
Age: 45
Posts: 279
Quote:
Originally Posted by alkis View Post
So, the usual startup is like (in some weird pseudocode)
Code:
  OpenLibrary dos
  HandleError or store library pointer
  OpenLibrary whatever
  HandleError or store library pointer
  bsr yoursuperduperprogram
  CloseLibrary dos
  CloseLibrary whatever
  rts
Yep, that's what I thought. Thank you both for your inputs!
guy lateur is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
is there any way to make path assign globally? chocsplease support.Apps 7 06 March 2017 16:42
AmigaGuide.library not opening correctly. Stuart support.WinUAE 6 18 November 2014 20:27
HELP: Opus5, KingCON, SysInfo.library (Sysmon.library) triangle Michael support.Apps 6 10 March 2014 15:08
Mediator - openpci.library and pci.library mardn78 support.Hardware 1 01 February 2014 12:11
Making a shared library from a gcc .a library JoJo Coders. General 1 10 March 2003 20:06

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 04:23.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.
Page generated in 0.11070 seconds with 15 queries