how to reassign or increment a variable in erlang

Chandrashekhar Mullaparthi Chandrashekhar.Mullaparthi@REDACTED
Thu Nov 14 12:08:47 CET 2002


Suresh,

You can do something like this.

-record(myrecord, {a,b}).

mnesia:dirty_write(#myrecord{a=1, b=2}).

[#myrecord{b=BVal}=Rec] = mnesia:dirty_read({myrecord, 1})
mnesia:dirty_write(Rec#myrecord{b=BVal+1}).

If you are specifically looking for counters, look at
mnesia:dirty_update_counter/2

Chandru

-----Original Message-----
From: Suresh S [mailto:sureshsaragadam@REDACTED]
Sent: 14 November 2002 10:20
To: erlang
Subject: how to reassign or increment a variable in erlang


Hi dear,

even though it is not possible to reassing a variable
in erlang,i need to increment a counter(variable),
and assign it to the same variable,
have any other ideas on this issue 
please let me know

i am really looking out for a solution 
to increment an attrbute value in mnesia table

how it can be done

advanced thanx
suresh s



NOTICE AND DISCLAIMER:
This email (including attachments) is confidential.  If you have received
this email in error please notify the sender immediately and delete this
email from your system without copying or disseminating it or placing any
reliance upon its contents.  We cannot accept liability for any breaches of
confidence arising through use of email.  Any opinions expressed in this
email (including attachments) are those of the author and do not necessarily
reflect our opinions.  We will not accept responsibility for any commitments
made by our employees outside the scope of our business.  We do not warrant
the accuracy or completeness of such information.




More information about the erlang-questions mailing list