Mark,
Thank you for your prompt response. The solution is excellent and one I will use. Regards, Stuart -----Original Message----- From: Mark Mills [mailto:[EMAIL PROTECTED] Sent: 20 December 2006 16:02 To: Bullock Stuart Cc: [email protected]; Lyons Neil Subject: Re: [Templates] Multiple Dimension Arrays Bullock Stuart wrote: To Whom It May Concern: I have a problem in attempting to access a matrix style array. If anyone can help I should be very grateful. If I have posted to the wrong email address, my apologies and please advise me of the correct email address to TT2 problems to. Data Structure =========== dataFile = ( name => "Curve Matrix" ,matrix => [ [ 0 , 365 , 1095 , 1825 , 3650 , 2555 ] ,[2.3 , 0.142 , 0 , 0 , 0 , 0 ] ,[2.4 , 0 , 1.72 , 0 , 0 , 1.71 ] ,[2.5 , 0 , 0 , 1.75 , 1.90 , 0 ] ] ); Output ====== What I should like on the output is: 0,365,1095,1825,3650,255 2.3,0.142,0,0,0,0 2.4,0,1.72,0,0,1.71 2.5,0,0,1.75,1.90,0 Naive Attempted Solution ================== [%- USE matrix = iterator(dataFile.matrix) %] [% FOREACH line = matrix %] [%- FOREACH column = line %] [%- %][% column %] [% IF NOT column.last %],[% END %] [%- END %] [% END %] As stated - any help or pointers with the syntax welcome. Regards, Stuart Bullock Here's my solution, slightly simplified. The data: my %vars = ( name => "Curve Matrix." ,matrix => [ [ 0 , 365 , 1095 , 1825 , 3650 , 2555 ] ,[2.3 , 0.142 , 0 , 0 , 0 , 0 ] ,[2.4 , 0 , 1.72 , 0 , 0 , 1.71 ] ,[2.5 , 0 , 0 , 1.75 , 1.90 , 0 ] ] ); The template: [% FOREACH line = matrix -%] [%- line.join(',') %] [% END -%] The output: 0,365,1095,1825,3650,2555 2.3,0.142,0,0,0,0 2.4,0,1.72,0,0,1.71 2.5,0,0,1.75,1.9,0 I suppose, if you wanted to format individual values, you could do this: [% FOREACH line = matrix -%] [% FOREACH item = line -%] [%- item %][% UNLESS loop.last; ","; ELSE; "\n"; END %][% END -%] [% END -%] --mark This message and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this message in error please delete it and any files transmitted with it, after notifying [EMAIL PROTECTED] Any opinions expressed in this message may be those of the author and not necessarily those of the company. The company accepts no responsibility for the accuracy or completeness of any information contained herein. This message is not intended to create legal relations between the company and the recipient. Recipients should please note that messages sent via the Internet may be intercepted and that caution should therefore be exercised before dispatching to the company any confidential or sensitive information. Mizuho International plc Bracken House, One Friday Street, London EC4M 9JA. TEL. 020 72361090. Wholly owned subsidiary of Mizuho Securities Co., Ltd. Member of Mizuho Financial Group. Authorised and regulated by the Financial Services Authority. Member of the London Stock Exchange. Registered in England No. 1203696. Registered office as above.
