CAM43=SMSS_eooFxjfhVhReZTik82gwb9VQ_bg7EfjA2iv5G-+Q@mail.gmail.com

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

CAM43=SMSS_eooFxjfhVhReZTik82gwb9VQ_bg7EfjA2iv5G-+Q@mail.gmail.com

Peter J Etheridge
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




_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions