
-----------------------------------
Cervantes
Sat Feb 21, 2004 12:30 pm

[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

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.


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:

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. :think:
lil help?  :P

-----------------------------------
jonos
Sat Feb 21, 2004 10:44 pm


-----------------------------------
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
Sun Feb 22, 2004 12:41 am


-----------------------------------
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
Sun Feb 22, 2004 12:50 am


-----------------------------------
thanks for the help, i don't think ill be using types anytime soon though.

-----------------------------------
wtd
Sun Feb 22, 2004 1:07 am


-----------------------------------
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.
