English Amiga Board


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: 4,332
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  
Old 30 November 2014, 04:27   #2
Cylon
Registered User
 
Join Date: Oct 2014
Location: Europe
Posts: 470
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: 4,332
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: 470
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  
 


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Blitz2: Hires laced BippyM Coders. Language 25 06 February 2020 01:07
Blitz2 keyboard issues htdreams Coders. Blitz Basic 2 16 August 2013 15:58
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 17:56.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.11838 seconds with 13 queries