MBaas wrote:Hmmm, I'm also struggling with UCMDs and Namespaces atm, trying to reuse some utilities from a scripted namespace
:Namespace dlstools
∇Z←A OVER B;S
:Access Shared Public
.
.
.
:EndNamespace
which is stored in a file dlstools.dyalog in my UCMDs-folder (the same as the actual UCMD trying to use this ns with ":include dlstools").
However, when trying to launch my ucmd ]ucmd or call help for it, the status-window comes up with this msg:
line(3,9) : error AC0556: include target can only be a namespace ":include dlstools"
^
Complete: 1 error.
I was hoping it would be namespace! (I also tried storing that namespace's .dyalog-file in SALT, SALT/SALT)
Michael: :Include assumes the namespace you want to include in the class resides in the same location as the class.
When you run a UCMD it runs INSIDE the Spice (aka UCMD) framework.
In order to include a ns in a class used for a ucmd you need to bring it in BEFORE the class is defined.
There is no way for you to do that by yourself. However, from the start, SALT has had the ability to bring in namespaces if they are required by recognizing a special comment that you include in the class. This comment is ⍝∇:require and can be used this way:
⍝∇:require path/incl
Usually you would use
⍝∇:require =/incl
instead where '=' means "from the same location as this class". Thus if you were to write a UCMD needing a ns to be included you should do something like
:Namespace in
∇ z←subTest
z←'works!'
∇
:EndNamespace
Save this in spice/MBincl.dyalog
:class myCmdGrp
:include in ⍝∇:require =/MBincl
∇ r←List
:Access public shared
r←⎕NS¨1⍴⊂⍬
r.Name←⊂'MBt1'
...
∇
∇ r←Run(Cmd Line)
:Access public shared
...
r←subTest
∇
:Endclass
Now if you call ]MBt1 it should call <subTest> without any problem.
That being said I don't recommend you do that in general as it is untidy. You need to keep track of both the UCMD file AND its included namespaces.
You could also separate them but you would have to hardcode the path into the class and any change in location would render the ucmd useless.
I try to keep my UCMDs smalll.
I have a couple of cases where a LOT of code has to be brought in. In that case I COPY (using []CY) the whole workspace I need or I bring in (using SALT) another space. This is similar to the :include case and the day my script moves my UCMD will stop to work.
But it's a tradeoff.
You decide.
/Dan