Author Topic: Whats Faster?[BB2D]  (Read 4245 times)

0 Members and 1 Guest are viewing this topic.

Offline mike_g

  • Amiga 1200
  • ****
  • Posts: 435
  • Karma: 34
    • View Profile
Whats Faster?[BB2D]
« on: January 12, 2007 »
I am having a go at using the Data statement for the first time and I was wondering, what would be faster:

Reading the data each loop, or reading the data once and writing it to an array then reading the array each loop. Or  maybe it dosent make any difference.
« Last Edit: July 21, 2007 by Shockwave »

Offline slinks

  • A little bit strange
  • DBF Aficionado
  • ******
  • Posts: 3964
  • Karma: 44
    • View Profile
Re: Whats Faster?
« Reply #1 on: January 12, 2007 »
I think it's the arrays mate. That's what I was taught to use, anyway.
I love semi-colons way too much ^^;
Challenge Trophies Won:

Offline mike_g

  • Amiga 1200
  • ****
  • Posts: 435
  • Karma: 34
    • View Profile
Re: Whats Faster?
« Reply #2 on: January 12, 2007 »
Cool, I'll be doing that then  :)

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: Whats Faster?
« Reply #3 on: January 12, 2007 »
In answer to your question on how to read in data dude.

You'd be right in using arrays to store the information, and generally you'd read and store any data before the main part / loop of your program.

This is just a quick snippet that I've made off the top of my head, and should give you a general idea dude.

Code: [Select]
Dim ImInHere(10)

Restore DataTable1 ; Tells blitz to start reading data at the label called 'DataTable1'

For a=0 to 9

    Read ImInHere(a)

Next

While Not Keyhit(1)
Cls
      ;What ever takes your fancy!
Flip
Wend

.DataTable1
Data 2,30,10,5,8,30,2,1,0,10

Cheers & Hope it's of use to you,
Clyde.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline mike_g

  • Amiga 1200
  • ****
  • Posts: 435
  • Karma: 34
    • View Profile
Re: Whats Faster?
« Reply #4 on: January 12, 2007 »
Thanks Clyde, thats more or less what i'm doing at the moment.

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
Re: Whats Faster?
« Reply #5 on: January 12, 2007 »
An alternative would be to use a bank and read the data into that. Then using peek and poke you can read/alter the data on the fly. The arrays are probably the easier way out. Banks provide interesting options in that images can be read as a bank and you can copy banks easily. Its all a matter of preference, and what you feel comfortable with using. But in any case, its always favorable to read the data beforehand since its a bit on the slow side resetting the read point and reading data in, if I remember correctly.