Array Record Variables 
Author Message
 Array Record Variables

Is it possible to have an array record variable type, I've done it in C and
C++ it might go something like this:

dim personel {
    lastname as string
    firstname as string
    phonenumber as string
    age as integer
    address as string
    zip as integer
    } (25)

It is kind of a poor man's database.
To access record 10 of personel, you might do something like this:

firstnameEdit.text = personel.firstname(10)

Does this exist in RealBasic?

--
Bruce Johnson



Sat, 29 May 2004 03:13:25 GMT  
 Array Record Variables

writes:

Quote:
>Is it possible to have an array record variable type, I've done it in C and
>C++ it might go something like this:

>dim personel {
>    lastname as string
>    firstname as string
>    phonenumber as string
>    age as integer
>    address as string
>    zip as integer
>    } (25)

Sort of. I guess the best way to do this is to create a new class. If you
don't add any methods to it--just properties--it's essentially like a
C-style struct. Although you'll probably come up with some good methods
to stick in there too, which is even better. In the above example, how
about a "NameToString" method that returns the first and last name,
concatenated and formatted correctly? Or a "SetPhoneNumber" method that
ensures the phone number you're trying to assign is valid?

Anyway, let's say you call your class "clsRecord" then you can have an
array of type clsRecord, just as you would have an array of Integers or
Strings.

Quote:
>To access record 10 of personel, you might do something like this:

>firstnameEdit.text = personel.firstname(10)

Remember, that arrays are zero-based by default in RB. That'll actually
get you record 11. ;-)

 - Jeff



Sat, 29 May 2004 09:03:32 GMT  
 Array Record Variables
it does, but instead of an 'array record variable type' you want a 'class'.

From the File menu, select New Class
Add properties to the class (Edit:New Property) for lastname, firstname,
etc.

When you want to create a 'personnel' class, initiate it by saying

Quote:
>dim p as personnelclass

>p=New personnelclass

You can access the properties in the same way as you describe using dot
notation.

hope this helps.

pp.

Quote:

> Organization: Prodigy Internet http://www.prodigy.com
> Newsgroups: comp.lang.basic.realbasic
> Date: Mon, 10 Dec 2001 19:13:25 GMT
> Subject: Array Record Variables

> Is it possible to have an array record variable type, I've done it in C and
> C++ it might go something like this:

> dim personel {
> lastname as string
> firstname as string
> phonenumber as string
> age as integer
> address as string
> zip as integer
> } (25)

> It is kind of a poor man's database.
> To access record 10 of personel, you might do something like this:

> firstnameEdit.text = personel.firstname(10)

> Does this exist in RealBasic?

> --
> Bruce Johnson




Sun, 30 May 2004 04:22:10 GMT  
 Array Record Variables

Quote:


> writes:
[..]
> >To access record 10 of personel, you might do something like this:

> >firstnameEdit.text = personel.firstname(10)

> Remember, that arrays are zero-based by default in RB. That'll actually
> get you record 11. ;-)

Actually, it'll get you record 10, which is the eleventh record.


Sun, 30 May 2004 09:46:11 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. An array of records within an array of records (Still a problem)

2. an array of records within an array of records

3. records containing variable length arrays [long]

4. Variable Record, Variable Block

5. array name in variable variable

6. Variable Size arrays Was: Indeterminate arrays??

7. array command and non-existent variables/arrays

8. how to access arrays with variable for array names and index

9. accessing to a variable by ref (variable is an array)

10. access to array if name of array is variable

11. HOWTO: reference elements of an array if array name is in a variable

12. Record Array

 

 
Powered by phpBB® Forum Software