doh. thanks. <br><br><div class="gmail_quote">On Sat, Apr 25, 2009 at 9:42 PM, Paul Fisher <span dir="ltr"><<a href="mailto:pfisher@alertlogic.com">pfisher@alertlogic.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Nothing to do with records. You need commas at the end of statements<br>
within the function, and period on last statement.<br>
<br>
--<br>
paul<br>
<div><div></div><div class="h5"><br>
On Apr 25, 2009, at 8:35 PM, "Larry White" <<a href="mailto:ljw1001@gmail.com">ljw1001@gmail.com</a>> wrote:<br>
<br>
> I'm on my second day of erlang and getting a compiler error while<br>
> experimenting with Records. Could someone steer me right?<br>
><br>
> -module(money).<br>
> -export([add/2]).<br>
><br>
> -record(money, { currency = usd, amount = 0 }).<br>
><br>
> add(Money1, Money2) -><br>
>        #money{currency=Cur1, amount=Amt1} = Money1.<br>
>        #money{currency=Cur2, amount=Amt2} = Money2.<br>
>        %% TODO: Check to see that the currencies are the same and<br>
> throw<br>
> exception if not<br>
>        Total = Amt1 + Amt2.<br>
>        #money{currency=Cur1,amount=<br>
> Total}.<br>
><br>
> The error I get is:<br>
> ./money.erl:9: syntax error before: '#'<br>
> ./money.erl:11: syntax error before: Total<br>
> ./money.erl:12: syntax error before: '#'<br>
><br>
> The statement " #money{currency=Cur1, amount=Amt1} = Money1." seems to<br>
> work fine from the command line.<br>
><br>
> Also, I tried a number of variants: using a guard for example in the<br>
> function header, but couldn't figure out the right syntax for two<br>
> guards : when record(Money1, money) ...?... (Money2, money).<br>
><br>
> Also I tried using C1 = Money1#money.currency.  - but the next line<br>
> caused a syntax error.<br>
><br>
> Finally, apologies if this gets double posted. I sent one about 6<br>
> hours ago but i don't think my subscription was active then.<br>
</div></div>> _______________________________________________<br>
> erlang-questions mailing list<br>
> <a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
> <a href="http://www.erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div><br>