SV: Erlang Nested Records

DANIESC SCHUTTE DANIESC.SCHUTTE@REDACTED
Wed Mar 19 06:56:04 CET 2003


You are completely right :)   thanks - 
<skulks off into a corner for missing the obvious> - 

>>> "Peter Lund" <peter@REDACTED> 03/19/03 07:56AM >>>
You seem to have forgot a "=". Look below:

NewAdditionalAmountRecord =
   AdditionalAmountRecord#additional_amounts{
      data_length = 1,
      additional_amount_data_1 =   %% HERE you forgot the "="
           #additional_amount_data{
                account_type = lists:sublist(AdditionalAmountData, 1, 2),
                amount_type  = lists:sublist(AdditionalAmountData, 3, 2),
                currency_code = lists:sublist(AdditionalAmountData, 5, 3),
                amount_sign   = lists:sublist(AdditionalAmountData, 8, 1),
                amount        = lists:sublist(AdditionalAmountData, 9, 12)
           }
   },


/Peter

> -----Ursprungligt meddelande-----
> Fran: owner-erlang-questions@REDACTED 
> [mailto:owner-erlang-questions@REDACTED]For DANIESC SCHUTTE
> Skickat: den 19 mars 2003 05:31
> Till: <
> Amne: Erlang Nested Records
> 
> 
> Morning to everyone,
> 
> I have got a question about adressing nested records - is there a 
> standard rule of thumb :) that can be used.
> 
> given the following record formats:
> 
> 
> %% ========================================================== 
> record formats begin
> 
> -record( additional_amount_data, {
> 	 account_type,
> 	 amount_type,
> 	 currency_code,
> 	 amount_sign,
> 	 amount }).
> 
> -record( additional_amounts, {
> 	 data_length,
> 	 additional_amount_data_1 = #additional_amount_data{},
> 	 additional_amount_data_2 = #additional_amount_data{},
> 	 additional_amount_data_3 = #additional_amount_data{},
> 	 additional_amount_data_4 = #additional_amount_data{},
> 	 additional_amount_data_5 = #additional_amount_data{},
> 	 additional_amount_data_6 = #additional_amount_data{}
> 	 }).
> 
> %% ========================================================== 
> record formats end
> 
> 
> how would one assign values to additional amounts internal 
> records? the following syntax yielded a syntax error - 
> the assignment can be done by first assigning the data_length 
> attribute and then in another Record assign the additional amount 
> data.  But is there a more elegant "single" assignment statement 
> that works - I tried a few without success - so I now know which 
> DOES NOT work :)
> 
> %% ========================================================== 
> record assignment code (syntax error) begin
> 
> 
>          case RecordNumber of
>             1 -> NewAdditionalAmountRecord = 
> AdditionalAmountRecord#additional_amounts{ data_length = 1,
>                                                             
> additional_amount_data_1#additional_amount_data{
>                                                                
> account_type  = lists:sublist(AdditionalAmountData, 1, 2),
>                                                                
> amount_type   = lists:sublist(AdditionalAmountData, 3, 2),
>                                                                
> currency_code = lists:sublist(AdditionalAmountData, 5, 3),
>                                                                
> amount_sign   = lists:sublist(AdditionalAmountData, 8, 1),
>                                                                
> amount        = lists:sublist(AdditionalAmountData, 9, 12)}},
>                  unpack_additional_amounts(DataLength-20, 
> lists:nthtail(20,AdditionalAmountData), 2, NewAdditionalAmountRecord);
> 
> %% ========================================================== 
> record assignment code (syntax error) end.
> 
> Thanks to everyone helping and responding
> 
> 
> 
> Danie Schutte
> Phone: +27 - 11 - 203 - 1615
> Mobile: 084-468-3138
> e-Mail: Daniesc@REDACTED 
> 
> ##################################################################
> ###################
> The information contained in this message and or attachments is intended
> only for the person or entity to which it is addressed and may contain
> confidential and/or privileged material.  Any review, retransmission,
> dissemination or other use of, or taking of any action in reliance upon,
> this information by persons or entities other than the intended recipient
> is prohibited. If you received this in error, please contact the 
> sender and
> delete the material from any system and destroy and copies.
> ##################################################################
> ###################
> 

#####################################################################################
The information contained in this message and or attachments is intended
only for the person or entity to which it is addressed and may contain
confidential and/or privileged material.  Any review, retransmission,
dissemination or other use of, or taking of any action in reliance upon,
this information by persons or entities other than the intended recipient
is prohibited. If you received this in error, please contact the sender and
delete the material from any system and destroy and copies.
#####################################################################################



More information about the erlang-questions mailing list