Ooops
October 26, 2020, 01:22:21 AM

Author Topic: Using Blitz3D Types  (Read 294 times)

Offline JBR

  • Full Member
  • ***
  • Posts: 113
Using Blitz3D Types
« on: June 06, 2020, 08:42:40 PM »
Hi,

Couple of questions about what a type can hold.

Type T_MyType
     field a%
     field array[20]                  same as dim array(20)
end type

In the above I'm using the 'secret array method' and the type of the array can be a type e.g. array.T_Type[20]

Is what I'm doing ok? And why not just use [ ] all the time?

Thanks, Jim.

Offline hosch

  • Jr. Member
  • **
  • Posts: 83
Re: Using Blitz3D Types
« Reply #1 on: June 06, 2020, 09:19:54 PM »
Yes, types within types can be used that way.

But
Code: [Select]
array[20] is not the same as
Code: [Select]
DIM array(20)
An array defined by square brackets is a Blitz Array. Blitz Arrays can only be
  • one dimensional
  • defined as global or local (as opposed to an array created by Dim, which is always global)
  • can be used as a parameter for a function
  • can be used to hold a type

The method you choose depends on what you are planning to do with the data. I usually go for types and loop through them with "Each", I rarely use an array as a type.

Offline JBR

  • Full Member
  • ***
  • Posts: 113
Re: Using Blitz3D Types
« Reply #2 on: June 07, 2020, 11:11:42 PM »
Thanks man, getting there slowly but surely!

Jim

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal