[erlang-questions] CAM43=SMSS_eooFxjfhVhReZTik82gwb9VQ_bg7EfjA2iv5G-+Q@REDACTED

Peter J Etheridge petergi@REDACTED
Tue May 14 09:50:56 CEST 2019


Thank you for your guidance Dan & Mikael.
Implementing your improvements;
in the wx module pw.erl

export_usr(Pw, Un, Pwv, Unv, Usr) -> 
case wxPasswordEntryDialog:connect(Pw, command_button_clicked,
[{userData, Pwv}]) of
  ok ->
    case wxTextEntryDialog:connect(Un, command_button_clicked,
[{userData, Unv}]) of
      ok ->
        io:format("~p: ~p ~n", [Usr, [#usr_record{un = Unv, pas
= Pwv}]]),
    Pid = spawn(usrdb, handle_usr, [Usr]),
      register(usrdb, Pid),
      Pid ! {self(), Usr}
    end 
end,
export_usr(Pw, Un, Pwv, Unv, Usr).

Trying to send this value of Usr to;

the mnesia module usrdb.erl

handle_usr(Usr) when is_record(Usr, usr_record)-> 
    io:format("~p ~n", [Usr]),
        {atomic, [Usr]} = mnesia:transaction(fun() ->
            mnesia:write(usr_table, Usr, write) end),
    Usr.

While this runs, no record in mnesia is found.
The first pw.erl function builds the window to gather user data before
wx:show(Frame).
In the second function export_usr/5, wxPasswordEntryDialog etc is a
repetition. 
A variable can only be given a value once in its scope. 
Does its scope end at wx:show(Frame)? (At the ' . ' of the first
function?)
If so, what is the correct procedure to copy a variable's value to a
subsequent function in a wx module?
Is there a better method for writing user data from a wx module into
an mnesia table?
Thank you once again in advance for your insights.
Peter


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20190514/c1ca101d/attachment.htm>


More information about the erlang-questions mailing list