BBC BASIC for Windows
Programming >> Operating System >> Programming Windows http://bb4w.conforums.com/index.cgi?board=os&action=display&num=1376182875 Programming Windows
Post by PaoloR on Oct 5th, 2012, 03:14am
I notice that it is possible to program Windows by either using SYS commands to access the Windows API or using the various Windows libraries provided with BBC Basic. It seems to me that the libraries provide a useful abstraction of the API. Why would one use SYS rather than the libraries? Is it because the libraries only contain a sub-set of the API? Are there any other reasons?
I'm still exploring BBC Basic, hence the question.
TIA
Re: Programming Windows
Post by admin on Oct 5th, 2012, 08:43am
Why would one use SYS rather than the libraries? Is it because the libraries only contain a sub-set of the API?
Yes. It would be impractical to wrap every single Windows API in a library (there are many thousands of them!) and it would impact on both program size and speed.
If an API can straightforwardly be called 'inline' from BBC BASIC by means of a simple SYS statement then there is no good reason not to do so. However when the API needs a significant degree of supporting code (perhaps to convert parameters to a different format, or to manage memory buffers, or because some assembler code is required) then wrapping it in a PROC or FN makes sense. If that PROC or FN is likely to be of 'general' use then it is appropriate to put it into a library.
Of course there are very many API calls which aren't straightforward to use but neither is there an existing BB4W library to access them. They are waiting for the need to arise and for somebody to create and submit a suitable library!
Richard.
Re: Programming Windows
Post by PaoloR on Oct 5th, 2012, 09:38am
Richard: thanks. That seems like a sensible division if responsibilities between 'simple' and complex.