Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 [Tutorial][Blitz]Type
Index -> Programming, Visual Basic and Other Basics -> Other Basics
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Cervantes




PostPosted: Sat Feb 21, 2004 12:30 pm   Post subject: [Tutorial][Blitz]Type

Type


What it is?
Type is simply a way of creating lots of variables under the same category. It's kinda like creating files under a folder. It keeps things neat and organized. Imagine having all the files on your computer on the C: drive without any folders!!
ex. Type can be used to store the x and y position of an alien

Syntax
code:

Type alien
    Field x
    Field y
End Type

Now we have declared what variables (or files) will be created when we call on the alien type.

code:

Global boss.alien = New alien

Now we have created a 'folder' called boss that holds the 'files' x and y (integers).
We can use these new variables like so:
code:

boss\x = 100
boss\y = 200


It doesn't have to be an integer that you use in the type. It can be real (floating point) or string or boolean. However, I can't find how to make a type of arrays. Thinking
lil help? Razz
Sponsor
Sponsor
Sponsor
sponsor
jonos




PostPosted: Sat Feb 21, 2004 10:44 pm   Post subject: (No subject)

i think i understand this. id ask if this is similar to records in turing, but i hvaen't learned those yet.

you create the fields in the type thing, then you have to declare the variables and then access them by:

variableName\type you chose

is this right? im trying to firmly understand everything unlike how i began turing.

also, can i add you to msn, you seem to be the only other person really wanting to learn blitz?
wtd




PostPosted: Sun Feb 22, 2004 12:41 am   Post subject: (No subject)

jonos wrote:
i think i understand this. id ask if this is similar to records in turing, but i hvaen't learned those yet.


Though I'm not familiar with Turing, I'd tend to say yes, based on other languages that use "records". This is also similar to "struct"s in C (though not C++).

The next evolution of this concept is the class, where we not only put data into a container, but also functions and procedures for dealing with those pieces of data. In an ideal situation, we make sure no one can see those pieces of data, but just manipulates them with the functions.
jonos




PostPosted: Sun Feb 22, 2004 12:50 am   Post subject: (No subject)

thanks for the help, i don't think ill be using types anytime soon though.
wtd




PostPosted: Sun Feb 22, 2004 1:07 am   Post subject: (No subject)

jonos wrote:
thanks for the help, i don't think ill be using types anytime soon though.


Don't write the idea off. Custom data types make such a nice way of moving information around inside a program.

Consider a set of functions that deal with information about a person. Do you want to pass name/age/sex/address information to every function every time, or do you want to just pass one argument each time, and not have to worry about mixing the wrong name with the wrong address and such?

It's a powerful tool.
Display posts from previous:   
   Index -> Programming, Visual Basic and Other Basics -> Other Basics
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: