import -- import a library
The import-statment imports a library. It expects a single argument, which must be the name of a library (without the trailing .yab). This library will then be read and parsed and its subroutines (and variables) will be made available within the main program.
Libraries will first be searched within the current directory (i.e. the directory within which you have invoked yab), then within the special directory /boot/home/config/settings/yab. The location of this second directory may be changed with the option -library.
rem This works ...
rem This works too ..
rem And this.
rem But this not!
Lets say you have a yab-program foo.yab, which imports a library lib.yab.
Now the library lib.yab reads:
rem Make the subroutine x easily available outside this library
export sub x(a)
rem sub y must be referenced by its full name
rem outside this library
This program produces an error:
---Error in foo.yab, line 13: can't find subroutine 'y'
---Dump: sub y() called in foo.yab,13
---Error: Program stopped due to an error
As you may see from the error message, yab is unable to find the subroutine y without specifying the name of the library (i.e. lib.y). The reason for this is, that y, other than x, is not exported from the library lib.yab (using the export-statement).