Wrapper around a bank

BlitzMax Forums/BlitzMax Programming/Wrapper around a bank

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.

an alternative would be to extend your wrapper type and define Type constants (or global if you want):
Type herobank Extends BankWrap
	Const HP:Int=0
	Const MANA:Int=1
	
	Method getByte:Byte(idx:Int)
		If idx>=layout_arr.length Then RuntimeError "Invalid Index"
		Return bank.PeekByte(get_offset(idx))
	EndMethod
	Method getDouble:Double(idx:Int)
		If idx>=layout_arr.length Then RuntimeError "Invalid Index"
		Return bank.PeekDouble(get_offset(idx))
	EndMethod
	Method getFloat:Float(idx:Int)
		If idx>=layout_arr.length Then RuntimeError "Invalid Index"
		Return bank.PeekFloat(get_offset(idx))
	EndMethod
	Method getInt:Int(idx:Int)
		If idx>=layout_arr.length Then RuntimeError "Invalid Index"
		Return bank.PeekInt(get_offset(idx))
	EndMethod
	Method getLong:Long(idx:Int)
		If idx>=layout_arr.length Then RuntimeError "Invalid Index"
		Return bank.PeekLong(get_offset(idx))
	EndMethod
	Method getShort:Short(idx:Int)
		If idx>=layout_arr.length Then RuntimeError "Invalid Index"
		Return bank.PeekShort(get_offset(idx))
	EndMethod
	
	Method setByte(idx:Int,val:Byte)
		If idx>=layout_arr.length Then RuntimeError "Invalid Index"
		bank.PokeByte(get_offset(idx),val)		
	EndMethod
	Method setDouble(idx:Int,val:Double)
		If idx>=layout_arr.length Then RuntimeError "Invalid Index"
		bank.PokeDouble(get_offset(idx),val)		
	EndMethod
	Method setFloat(idx:Int,val:Float)
		If idx>=layout_arr.length Then RuntimeError "Invalid Index"
		bank.PokeFloat(get_offset(idx),val)		
	EndMethod
	Method setInt(idx:Int,val:Int)
		If idx>=layout_arr.length Then RuntimeError "Invalid Index"
		bank.PokeInt(get_offset(idx),val)		
	EndMethod
	Method setLong(idx:Int,val:Long)
		If idx>=layout_arr.length Then RuntimeError "Invalid Index"
		bank.PokeLong(get_offset(idx),val)		
	EndMethod
	Method setShort(idx:Int,val:Short)
		If idx>=layout_arr.length Then RuntimeError "Invalid Index"
		bank.PokeShort(get_offset(idx),val)		
	EndMethod
	
EndType

your calls then look something like:
save.setInt(herobank.HP,23)
save.setInt(herobank.MANA,150)
...
Local hero_hp:Int=save.getInt(herobank.HP)
Local hero_mana:Int=save.getInt(herobank.MANA)