Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
Matto
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location:
Posted: 6th Jan 2003 01:01
I remember a while ago reading about Types in dbpro, I remeber them being similar to Arrays but more elastic and saw them being usefull in the right place, at the time I had no place for them so kinda forgot about them. Now I have a need for them but I have no idea where I read the infomation regarding them, I have looked through the help files in dbpro to see where they are but there seems to be nothing on them at all.. I have upgraded to the latest patch since first reading about them and I have no idea whether they were in the help files before the patch(patch 3) or if I read about them elsewhere?

Could anyone help me here with info on where I can read about DB's Types Please, whether in dbpro help files or else where.. many thanks for any help it's driving me insane trying to think where I last read it..
1ghz Cel,512 sdram 133,Gf2 MX 400 64,SBL 5.1,Win98
Best Upcoming MMOG - http://WWW.Atriarch.com
Project: Card Game with No Name
Steve Fash
21
Years of Service
User Offline
Joined: 31st Dec 2002
Location: Doncaster, UK
Posted: 18th Jan 2003 22:45
Yeah, I thought DBPro had types....I'm used to using them in Blitz and was sure that DBpro had them too...I know DB could have them using the 113 enhancements and Guys Dark Edit....
What about types anyone ? Does DBpro have em, and if so, wheres the docs for em ?

haggisman
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 18th Jan 2003 22:58
Heres a nice big chunk of info that can be found both in the user manual and in the help files.:-


USER DEFINED TYPES

If the current set of datatypes is inadequate for your needs, you can can create your own data types
using user-defined-type. User defined types are useful for storing data using logical fields rather than the
unfriendly list of subscripts used by arrays.

To create a user defined type, you must first declare it at the top of your program. To do so, you would
give your type a name and a list of fields it contains:

TYPE MyType
Fieldname1
Fieldname2
Fieldname3
ENDTYPE
The above code creates a type called MyType with three fields contained within it. As the fields have no
declaration, they are assumed to be integers. The same code could also be truncated to a single line like
so:

TYPE MyType Fieldname1 Fieldname2 Fieldname3 ENDTYPE
To use your type, you simply create a variable and declare it with your new type. To declare a variable as
a specific type, you would use the AS statement:

MyVariable AS MyType
You can then assign data to your variable as normal, with the added bonus of the fields you have given
your variable like so:

MyVariable.Fieldname1 = 41
MyVariable.Fieldname2 = 42
MyVariable.Fieldname3 = 43
At the moment, the type is assuming our fields are integers. We may wish to declare our fields as a real
number, string or other datatype. We can do so using the same AS statement within the type definition.
So the following code makes more sense we shall give our type and fields sensible names:

TYPE AccountEntryType
Number AS INTEGER
Name AS STRING
Amount AS FLOAT
ENDTYPE
You can use a type like any other, so creating and using an array of the above is simply a case of
declaring the array with your new type:

DIM Accounts(100) AS AccountEntryType
Accounts(1).Number=12345
Accounts(1).Name="Lee"
Accounts(1).Amount=0.42
As you will eventually discover you can have types within types for more complex data structures so we
can imagine one of the fields contains more than one value. We would define two user defined types, and
then use one of them in the declaration of one of the fields of the section user defined type, as follows:

TYPE AmountsType
CurrentBalance AS FLOAT
SavingsBalance AS FLOAT
CreditCardBalance AS FLOAT
ENDTYPE
TYPE AccountEntryType
Number AS INTEGER
Name AS STRING
Amount AS AmountsType
ENDTYPE
DIM Accounts(100) AS AccountEntryType
Accounts(1).Number=12345
Accounts(1).Name="Lee"
Accounts(1).Amount.CurrentBalance=0.42
Accounts(1).Amount.SavingsBalance=100.0
Accounts(1).Amount.CreditCardBalance=-5000.0
As you can see, user defined types are not only powerful, they make the readability of your programs far
easier. Using named fields instead of a subscript value within an array, you can save yourself many hours
all for the sake of an incorrect subscript value throwing out your program results.

Specs:- 1GHZ athlon, Radeon8500, 192mb ram, winxp
Steve Fash
21
Years of Service
User Offline
Joined: 31st Dec 2002
Location: Doncaster, UK
Posted: 18th Jan 2003 23:03
Cheers dude-I thought I'd seen them somewhere....Just tryin to get to grips with the dbpro language in the demo before I decide to purchase...bit different to BB.....

Shadow
22
Years of Service
User Offline
Joined: 17th Oct 2002
Location: In the shadows
Posted: 19th Jan 2003 21:08
DB wasn't too hot with variables (I noticed that I could do some things with qbasic much better than db and I hadn't programmed in qbasic for years!)

Login to post a reply

Server time is: 2024-11-23 21:27:48
Your offset time is: 2024-11-23 21:27:48