Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sun Oct 22, 2017 11:31 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Can I define Types in RB ?
PostPosted: Sat Oct 20, 2012 3:59 pm 
Offline
User avatar

Joined: Thu Dec 29, 2011 6:46 pm
Posts: 191
Location: Edmonton, AB, Canada
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

_________________
Regards,
TomazVDaSilva


Clean Code: Robert C. Martin
It is not the language that makes programs appear simple.
It is the programmer that make the language appear simple!


Top
 Profile  
Reply with quote  
 Post subject: Re: Can I define Types in RB ?
PostPosted: Sat Oct 20, 2012 4:08 pm 
Offline
User avatar

Joined: Wed May 10, 2006 2:42 pm
Posts: 2985
Location: Germany
Declare a new class named bk and add the properties.
Integer instead of long.

Greetings
Christian

_________________
See you in Orlando, Florida for Real World 2013
More details and registration here:
http://www.realsoftware.com/community/realworld.php


Top
 Profile  
Reply with quote  
 Post subject: Re: Can I define Types in RB ?
PostPosted: Sat Oct 20, 2012 4:15 pm 
Offline

Joined: Mon May 30, 2011 12:56 am
Posts: 702
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()


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group