BBC BASIC for Windows
« Namespace of CALLed Modules »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 10:58pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Namespace of CALLed Modules  (Read 465 times)
Michael Hutton
Developer

member is offline

Avatar




PM

Gender: Male
Posts: 248
xx Namespace of CALLed Modules
« Thread started on: Jun 28th, 2010, 11:29am »

I have read http://bb4w.conforums.com/index.cgi?board=language&action=display&num=1235907869.

I was interested in the last comment made re LOCAL variables being visible GLOBALLY.

I am thinking that it would be a good thing to be able to execute code in a CALLed file (which doesn't have Sub-routines, although I note the possibility of including them) I would like to define LOCAL variables within the CALLED module which would then be deleted on exit (or RETURN), for example create LOCAL structures within the CALLed file which would then be unavailable to the main program.

Would this be possible without reverting to the "tricks" which have been posted in the previous thread? But if it wasn't, I could use the methods posted and define them in a DEF within the CALLed module, but would they be visible on the heap in the main program?

Michael
User IP Logged

admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
xx Re: Namespace of CALLed Modules
« Reply #1 on: Jun 28th, 2010, 1:33pm »

on Jun 28th, 2010, 11:29am, Michael Hutton wrote:
I would like to define LOCAL variables within the CALLED module which would then be deleted on exit (or RETURN), for example create LOCAL structures within the CALLed file which would then be unavailable to the main program.

There's a big difference between variables (which is what you first said) and structures (which you later said) in that respect. I don't know of any reliable way in which regular scalar variables can be 'deleted'; once they're on the heap they're there for good (or until a CLEAR statement). I'm excluding attempts to modify the heap contents directly of course!

Structures are another matter. Although, like variables, once created they remain on the heap indefinitely, when you return from a procedure or function in which a LOCAL structure was used that structure is not visible to the rest of the program. It won't even appear in the List Variables window.

So if your concern is visibility of the 'variables' then putting them in a LOCAL structure solves that; once the routine exits they become invisible (you would of course have to put the 'meat' of your CALLed module in a PROC or FN, which as you say may involve using the 'tricks' in that earlier thread). If your concern is more with memory usage, then you're stuck. As always, the heap grows inexorably and you can't shorten it again.

Richard.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls