I have some packages that uses database connections inside it, let's call it ConnPackage. The connection IP is a public package variable, and has a default value:
$connectionIP="127.0.0.1".
This variable is used to read database values when the package is loading. So change it value after package load don't solve the problem. The problem is similar to pass args in shell wolfram script, but must be done in the notebook.
The question is:
How could I read the ConnPackage, using Needs[], but setting $connectionIP to be another value?
UPDATE
I can solve the problem defining a variable in System. But I don't feel it's a good pattern. Here is my attempt. Inside ConnPackage I can do:
$connectionIP=If[StringQ[#],#,"127.0.0.1"]&[System`$argConnectionIP]
So, if there is no value in System`$argConnectionIP, the standard IP will be load, otherwise it will use System`$argConnectionIP.
SetDelayedhelp in your case? – Yves Klett Jan 10 '15 at 16:32$connectionIPas it runs to load other definitions. @OleksandrR. I made an update with how I solved it, but I don't fell it's a good way. – Murta Jan 10 '15 at 16:54System`? Cannot you useConnPackage`$connectionIPtoo? Perhaps I don't actually understand what you wish to accomplish; if that's the case pardon me. – Mr.Wizard Jan 10 '15 at 19:34ConnPackage, I forgotBeginPackagereadsSystemand the loaded package. – Murta Jan 10 '15 at 19:45ConnPackage. – Murta Jan 10 '15 at 19:49