🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #12143

Re: Variable Addresses in AmigaBasic

#12143
From: The POSTMAN
Date: Fri, 07 Apr 1989 23:23
68 lines
3057 bytes
In article <38410@bbn.COM>, cosell@bbn.com (Bernie Cosell) writes:
> [are you allowed to ask "basic" questions in the .tech group... I guess I'll
> find out..:-)]
> 
> I have a bunch of Basic programs which have the need to move LARGE quantities
> of data in and out.  I was looking at an old ABasiC program and I noticed that
> _it_ used a thing called "bload".  Now I don't exactly know what that does, but
[Stuff Deleted]

> will be mostly useless by tthe time I get around to the xRead().  Two
> questions:
>   a) is there some way to _beat_ the var-moving problem?  Passing in the
>   memory-address explicitly is surely the most convenient scheme, if I could
>   make it work, and

The easiest way to do this is actually using routines from EXEC to do this
for you.  As like in 'C' just allocate the memory you need.  The operating
system returns a pointer to the memory you just allocated.  Something like
this:

LIBRARY "exec.library"   'This will get open the exec.library for you to use
			 ' note the 'exec.bmap must be in the current dir.

DECLARE FUNCTION AllocMem& LIBRARY	'I think this is the right syntax ??

Mem_Pointer& = AllocMem(Size (in bytes),Flags)

Note: Mem_Pointer has to be a long (32-bit)
      Size is in bytes (Exec will round it up to the nearest 8 byte block)
      Flags - things like CHIP or FAST or CLEAR (etc..), values can be found
	      in any C/asembler include files

The result is a chunk of memory at location Mem_Pointer to play with your
hearts content.

>   b) if not, how then could I declare that subroutine?  I'm OK with the program
>   always reading into a array (hard to imagine that this is all that useful for
>   reading in a single value, and even then you can just set up a one-long
>   array).  BUT: how to get the *types* to match???  I can easily do:
>       SUB BLoad (FileName$, Array()) STATIC
>   and do the VARPTR inside the subroutine, but how do I handle arry-of-shorts
>   versus array-of-floats, etc.

This way you can easily have a SUB declared passing it the FileName, Pointer
and probably the size.

> 
> Thanks

You're Welcome!

>    __
>   /  )                              Bernie Cosell
>  /--<  _  __  __   o _              BBN Sys & Tech, Cambridge, MA 02238
> /___/_(<_/ (_/) )_(_(<_             cosell@bbn.com


Lenny Post
University of Calgary

Member/Executive of AMUC (The AMiga Users of Calgary)

"The Cat came back, the very next day!"
"I will not buy this record, It is scratched" - Monty Python



"No.  Amiga is not dead.  Hell, it's not even tired." --- Leo. L. Schwab
Technical Details
Message-ID: <1064@cs-spool.calgary.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!shadooby!accuvax.nwu.edu!tank!shamash!nic.MR.NET!umn-d-ub!rutgers!att!alberta!calgary!cpsc!post
References: <38410@bbn.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!shadooby!accuvax.nwu.edu!tank!shamash!nic.MR.NET!umn-d-ub!rutgers!att!alberta!calgary!cpsc!post
From: post@cpsc.ucalgary.ca (The POSTMAN)
Newsgroups: comp.sys.amiga.tech
Subject: Re: Variable Addresses in AmigaBasic
Summary: Basic STuff
Message-ID: <1064@cs-spool.calgary.UUCP>
Date: 7 Apr 89 23:23:50 GMT
References: <38410@bbn.COM>
Sender: news@calgary.UUCP
Lines: 68