= Use Directive = {{{ use use from }}} Specify a namespace whose contents are made available to this module. When using the first form if the compiler cannot immediately locate the namespace,[[BR]] i.e if its not in the default loaded libraries,[[BR]] it will look for a (platform dependent) library-name of the same form as the namespace. If the filename of the library differs from the namespace, you can specify it with the second form.[[BR]] can be a simple identifier, qualified identifier (Foo.Bar) or a string literal. {{{ #!cobra use Foo.Bar from SomeLib }}} You can put single or double quotes around the file name if its components are not legal identifiers [[BR]] (for example, the filename has a space or punctuation mark in it). {{{ #!cobra use Foo.Bar from "My Lib" }}} == Platform == '''For .Net''': There are assumed five implicit "use" directives at the top of a Cobra program: {{{ #!cobra use System use System.Collections.Generic use System.IO use System.Text use Cobra.Core }}} This gives default access to the core of the .Net objects and the cobra runtime Library, !CobraCore. These correspond to access to the following default loaded libraries {{{ mscorlib.dll System.dll Cobra.Core.dll }}} On .Net will refer to a .Net Assembly or dll[[BR]] No ".dll" extension is expected (or allowed) in any of the above syntax. The library name is the namespace with ".dll" appended e.g {{{ #!cobra use Foo.Bar # On .Net will look for the namespace in file Foo.Bar.dll if it is not already available }}} '''For Java''': The namespace names specified refer to java package names (first (caps) letter downcased). Similarly the assumed implicit directives are {{{ use Java.Lang use Java.Io use Java.Util use Java.Text use Cobra.Core }}} which correspond to the most common core java library packages (i.e java.{lang,io,util,text}) and the (java ) cobra runtime library. (These core library packages are read from the standard java runtime system jarfile rt.jar). The refers to a Java jar file (no .jar extension is expected or allowed). The jarfile name is the namespace with ".jar" appended searched for in the places given by the CLASSPATH env variable. == Examples == {{{ #!cobra use System.Windows.Forms use System.Drawing class MyForm inherits Form def init .text = 'Click Me' listen .click, ref .handleClick def handleClick(sender as Object, args as EventArgs) MessageBox.show('You clicked me!', 'Click') class Program def main is shared Application.run(MyForm()) }}} == Notes == In most cases this syntax means you dont need to specify the commandline -reference switch to provide the filename for a referenced namespace. With !MyProg.cobra containing {{{ #!cobra ... use Foo.Bar ... }}} Instead of compilation by {{{ cobra -reference:Foo.Bar MyProg.cobra }}} you can just say: {{{ cobra MyProg.cobra }}}