different pointer same type

Blitz3D Forums/Blitz3D Programming/different pointer same type

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

My method of choice for accessing and assigning data from type objects.

Const SHIP_MAX%=32 ;Pre determined Limitation
Dim shipID.ship(SHIP_MAX%) ;<-- array of types used as a pointer to specific object by primary key.

Type ship
	Field id% ;<-- primary key
	Field hull%
End Type

Function shipNew.ship(id%,hull%)
	this.ship=New ship
	this\id%=id%
	this\hull%=hull%
	shipID(this\id%)=this ;<-- Pointer to specific ship by ID
	Return this
End Function

;create some ships
s.ship=shipNew(1,30) ;s.ship has id value of 1
t.ship=shipNew(2,40) ;t.ship has id value of 2

;examples of accessing the data from different places
ship.ship=shipID(1) ;assign s.ship to another pointer
tshiphull%=shipID(2)\hull% ;access the hull value from t.ship

;display values
Print ship\hull%
Print tshiphull%