Real Software Forums
http://forums.realsoftware.com/

Can I define Types in RB ?
http://forums.realsoftware.com/viewtopic.php?f=13&t=45655
Page 1 of 1

Author:  TomazVDaSilva [ Sat Oct 20, 2012 3:59 pm ]
Post subject:  Can I define Types in RB ?

How do I define Types in Realbasic ?
Should I use "structure"?

Does anyone know how to convert this code below to RB ?

Public Bak(3) As Sprite, BakD(3) As bk

Type bk
r As Long
v As Long
n As Long
End Type

Sub bkA(i As Long, x As Long, y As Long)
Dim n As Long
n = getPt
If n = ptMax Then Exit Sub
With pt(n)
.v = True
.t = 20
.x = x
.y = y
.p1 = 0
.r = BakD(i).r
.p2 = BakD(i).v
.p3 = BakD(i).n
.p4 = i
End With
End Sub

Author:  MonkeybreadSoftware [ Sat Oct 20, 2012 4:08 pm ]
Post subject:  Re: Can I define Types in RB ?

Declare a new class named bk and add the properties.
Integer instead of long.

Greetings
Christian

Author:  kermit [ Sat Oct 20, 2012 4:15 pm ]
Post subject:  Re: Can I define Types in RB ?

unless you need to pass the type to an external dll.
In which case a struct or a memoryblock will be what you need.

A struct simply allocates memory to hold data.
A class adds the ability to augment the data with methods and inheritance.

eg a struct can hold a double called balance.
A Piggybank class can have an internal storage of type double, and methods such as addmoney(), remove money()

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/