Board index » delphi » User defined types...Help

User defined types...Help

Haven't been usinf Delphi to long and am trying to find out how to declare
a user defined data type.
Under VB I would do this:
(this is taken from a database I prototyped in VB and want to do the
final in Delphi)

Type TechDataInfo
    TechType As String * 30
    TechSerial As String * 30
    TechAccount As String * 20
    TechFrom As String * 20
    TechTime As String * 15
    TechDate As String * 15
    TechTech As String * 15
    TechCond As String * 6
    TechRep As String * 6
    TechNotes As String * 1024
End Type
Global TechData As TechDataInfo

How do I go about doing this in Delphi. Or at least tell me which manual
this info is in.

Thanks

 

Re:User defined types...Help


Quote
Robert D. Jones wrote:

> Haven't been usinf Delphi to long and am trying to find out how to declare
> a user defined data type.
> Under VB I would do this:
> (this is taken from a database I prototyped in VB and want to do the
> final in Delphi)

> Type TechDataInfo
>     TechType As String * 30
>     TechSerial As String * 30
>     TechAccount As String * 20
>     TechFrom As String * 20
>     TechTime As String * 15
>     TechDate As String * 15
>     TechTech As String * 15
>     TechCond As String * 6
>     TechRep As String * 6
>     TechNotes As String * 1024
> End Type
> Global TechData As TechDataInfo

> How do I go about doing this in Delphi. Or at least tell me which manual
> this info is in.

> Thanks

For this purpose you can use a record type (as in VB) or an object.
Place this in the Type section:

  TechDataInfo=record
  {alternatively - TechDataInfo=class(TObject) }
    TechType: string[30];
    TechSerial: string[30];
    TechAccount: string[20];
    TechFrom: string[20];
    TechTime: string[15];
    TechDate: string[15];
    TechTech: string[15];
    TechCond: string[6];
    TechRep: string[6];
    TechNotes: string[255]; {the maximum size of a string is 255 chars}
  end;

And in the Var section:

  TechData: TechDataInfo;

If you choose to use an object, you will also have to create an instance of the
object before you can use it:

  TechData:=TechDataInfo.create;

Hope this helps - good luck!

Gu

Re:User defined types...Help


robe...@scs.unr.edu (Robert D. Jones) wrote:

Quote
>Haven't been usinf Delphi to long and am trying to find out how to declare
>a user defined data type.
>Under VB I would do this:
>(this is taken from a database I prototyped in VB and want to do the
>final in Delphi)

>Type TechDataInfo
>    TechType As String * 30
>    TechSerial As String * 30
>    TechAccount As String * 20
>    TechFrom As String * 20
>    TechTime As String * 15
>    TechDate As String * 15
>    TechTech As String * 15
>    TechCond As String * 6
>    TechRep As String * 6
>    TechNotes As String * 1024
>End Type
>Global TechData As TechDataInfo

>How do I go about doing this in Delphi.

type
        TOneType = record
                AField:integer;
                AnotherField:string[40];
        end;

        TAnotherType = record
                {etc}
        end;

var
        SomeStuff,SomeMoreStuff:TOneType;
        EvenMoreStuff:TAnotherType;

begin
        SomeThing.Do;
end;

        The word "type" denotes the beginning of a section of
type declarations (as opposed to denoting a type declaration
as it does where you come from); you declare variables in
a "var" section.

David Ullrich

Other Threads