[DUG] Uninitialised variables/Constants
Rohit Gupta
rohit at cfl.co.nz
Thu Feb 1 09:14:26 NZDT 2007
John,
I find this rather tedious and almost never use this method. I either
declare each field as an array on its own so that I dont have to specify
the field name. Or, I populate the array at run time by calling a
procedure with all the field values. You could also read it from a
file, from the database or a resource.
>
>
>> I am interested particularly in an uninitialised field in a constant
>>
> record
>
>> like:
>>
>> type
>> TSampleRecord = record
>> SampCode: Integer;
>> SampName:string[30];
>> SampAddress1:array[1..3] of string[20];
>> iValue: integer;
>> end;
>>
>> const
>> ConstArr: array [0..5] of TSampleRecord =(
>> (SampCode: 0; SampName:'Nought';
>> SampAddress1:('A01','A02','A03');iValue: 10),
>> (SampCode: 1; SampName:'First';
>>
> SampAddress1:('A11','A12','A13');iValue:
>
>> 11),
>> (SampCode: 2; SampName:'Second';
>> SampAddress1:('A21','A22','A23');iValue: 12),
>> (SampCode: 3; SampName:'Third';
>>
> SampAddress1:('A31','A32','A33');iValue:
>
>> 13),
>> (SampCode: 4; SampName:'Fourth';
>> SampAddress1:('A41','A42','A43');iValue: 14),
>> (SampCode: 5; SampName:'Five missing iValue';
>> SampAddress1:('A51','A52','A53'))
>> );
>>
>> In this case the uninitialised ConstArr[5].iValue behaves as being 0,
>>
> which
>
>> is nice. I am setting up some constant records like this and it would be
>> convenient if I do not have to explicitly initialise every last field
>>
> value
>
>> especially if I know I won't be using that particular one...what is "best
>> practice"?
>>
>>
>> John
>>
>
> _______________________________________________
> Delphi mailing list
> Delphi at ns3.123.co.nz
> http://ns3.123.co.nz/mailman/listinfo/delphi
>
>
>
--
*Rohit Gupta*
* B.E. Elec. M.E. Mem IEEE Associate IEE*
*Technical Manager*
*Computer Fanatics Limited*
**
*Tel* +64 9 4892280
*Fax* +64 9 4892290
*Email *rohit at cfl.co.nz <mailto:rohit at cfl.co.nz>**
*Web *www.cfl.co.nz <http://www.cfl.co.nz/>
------------------------------------------------------------------------
This email and any attachments contain information, which is
confidential and may be subject to legal privilege and copyright. If you
are not the intended recipient, you must not use, distribute or copy
this email or attachments. If you have received this in error, please
notify us immediately by return email and then delete this email and any
attachments.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://ns3.123.co.nz/pipermail/delphi/attachments/20070201/43540cc3/attachment.html
More information about the Delphi
mailing list