Call a compiled Beam module
Thu May 8 10:35:41 CEST 2003
On Thu, 8 May 2003, Jilani Khaldi wrote:
>That's Ok, but it loads only the module but not the "*.gif"
>images inside "c:/abc" that the module uses, and it aborts.
An OTPish way of doing things would be to organize your code
into applications like in the OTP code tree:
You can then use the function code:priv_dir(myapp) and find
$MYROOT/lib/myapp-1.0/priv/. From there, you can e.g. slap
on an imgs/ subdirectory and fetch your files.
Another method would be to maintain a variable pointing to
your personal files. This can be done in many ways.
- If you want to specify an OS environment variable, you can
do so, and fetch the location using os:getenv(Variable)
- If you want to specify the location as an argument to
the 'erl' command, you are free to do so:
#: erl -mydir /foo
Erlang (BEAM) emulator version 18.104.22.168 [source] [threads:0]
Eshell V22.214.171.124 (abort with ^G)
- You can store a value in Mnesia, of course
You can also use code:which(?MODULE) in your code to find
the location of your .beam file. This is a questionable
tactic, since it will be misleading if the module has been
loaded from a patch directory.
I'm sure there are other, perhaps better, ways, but those
were some alternatives off the top of my head.
Ulf Wiger, Senior Specialist,
/ / / Architecture & Design of Carrier-Class Software
/ / / Strategic Product & System Management
/ / / Ericsson AB, Connectivity and Control Nodes
More information about the erlang-questions