Hi David!<br><br>Why not convert the string to the module name directly?<br>zabc = list_to_atom(string:to_lower("ZABC")).<br><br>In that case you'd only need a case to handle if the module is undefined:<br><br>
Module = list_to_atom(string:to_lower(TransactionType)),<br>case code:ensure_loaded(Module) of<br> {module, Module} -><br> Module:process_request(Request);<br> {error, nofile} -><br> error_logger:info_msg("Unknown transaction type")<br>
end,<br><br>Hope this gets you closer to a solution!<br><br>Cheers!<br>Adam<br><br>--<br>Adam Lindberg<br><a href="http://www.erlang-consulting.com">http://www.erlang-consulting.com</a><br><br><div class="gmail_quote">On Wed, Mar 5, 2008 at 10:16 PM, Vlad Dumitrescu <<a href="mailto:vladdu55@gmail.com">vladdu55@gmail.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi!<br>
<div class="Ih2E3d"><br>
<br>
On Wed, Mar 5, 2008 at 9:59 PM, David Mitchell <<a href="mailto:monch1962@gmail.com">monch1962@gmail.com</a>> wrote:<br>
> I've got a block of code that looks like:<br>
> case TransactionType of<br>
> "ZABC" -><br>
> zabc:process_request(Request);<br>
> "Z123" -><br>
> z123:process_request(Request);<br>
> "YPQX" -><br>
> ypqx:process_request(Request);<br>
> ...<br>
> TransactionType -><br>
> error_logger:info_msg("Unknown transaction type")<br>
> end<br>
<br>
</div> You could use something like<br>
<br>
get_handler("ZABC") -><br>
zabc;<br>
get_handler("Z123") -><br>
z123;<br>
.......<br>
get_handler(_) -><br>
error_logger:info_msg("Unknown transaction type"),<br>
error<br>
<br>
and in your code just call<br>
<br>
Module = get_Handler(TransactionType),<br>
case Module of<br>
error -><br>
done;<br>
_ -><br>
Module:process_request(Request);<br>
end,<br>
<br>
best regards,<br>
Vlad<br>
<br>
--<br>
Some people see things that are and ask, Why?<br>
Some people dream of things that never were and ask, Why not?<br>
Some people have to go to work and don't have time for all that.<br>
--- George Carlin<br>
<font color="#888888"><br>
<br>
<br>
--<br>
Some people see things that are and ask, Why?<br>
Some people dream of things that never were and ask, Why not?<br>
Some people have to go to work and don't have time for all that.<br>
--- George Carlin<br>
</font><div><div></div><div class="Wj3C7c">_______________________________________________<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>
</div></div></blockquote></div><br>