English Amiga Board Amiga Lore


Go Back   English Amiga Board > Coders > Coders. Language > Coders. Blitz Basic

 
 
Thread Tools
Old 25 September 2014, 06:02   #1
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 2,975
Blitz2: Pointer to array

While doing setup of a level, stored as an array of blocks, it would be helpful to have a pointer into that array, but I can't seem to figure out the correct usage of * and & and (), or need I resort to peek and poke?
idrougge is offline  
AdSense AdSense  
Old 30 November 2014, 04:27   #2
Cylon
Registered User

 
Join Date: Oct 2014
Location: Europe
Posts: 447
What are 'blocks'?
The address of an array something() is &something(0), the pointer to the first entry.
Or, do you have a newtype you made your array of?
Anyway:
Code:
; Blitz 2 Array pointer test
CloseEd

as.w=10

Dim array.w (as)      ;words, 2bytes

na.l =0
ona.l=0

NPrint""

For a = 0 To as-1

  na.l = &array(a)

  Print na

  NPrint "(",na-ona," bytes)"

  ona.l=na
Next a

MouseWait
End
Cylon is offline  
Old 24 March 2015, 15:28   #3
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 2,975
What does &array() point at? Some kind of arraybase?
idrougge is offline  
Old 26 March 2015, 21:44   #4
Cylon
Registered User

 
Join Date: Oct 2014
Location: Europe
Posts: 447
Quote:
Originally Posted by idrougge View Post
What does &array() point at? Some kind of arraybase?
Yes.
Quote:
The address of an array something() is &something(0), the pointer to the first entry.
Just keep in mind, that an array is mostly a linear block of memory, the index of an item 1 or 10 is just an offset to the start address (multiplied with the size for each item).
Cylon is offline  
AdSense AdSense  
 


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Blitz2 keyboard issues htdreams Coders. Blitz Basic 2 16 August 2013 15:58
Blitz2: Hires laced BippyM Coders. Language 24 29 July 2012 20:18
Blitz2 Newcommandset BippyM Coders. Language 0 21 July 2012 23:59
Coding my game in Blitz2 r0ber7 Coders. General 103 11 September 2011 20:14
Blitz2 Manual AlfaRomeo Amiga scene 18 01 May 2009 10:53

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 22:51.


Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Page generated in 0.11114 seconds with 12 queries