Chapter Contents |
Previous |
Next |
IMPORT |
Category: | Catalog, Object Oriented |
Syntax | |
Details | |
Examples | |
Example 1: Defining a Search Path | |
Example 2: Importing a Class from Another Catalog | |
See Also |
Syntax |
IMPORT class-specification; |
Details |
The IMPORT statement defines a search path for CLASS entry references in an SCL program so that you can refer to CLASS entries with one- or two-level names instead of having to use a four-level name in each reference. The current catalog is always the first catalog to be searched for a one- or two-level class name, regardless of whether there are any imported catalogs. References to CLASS entries are resolved by the SCL compiler at compile time. The SEARCH function can be used to define a search path that will resolve at run time.
Examples |
Define a MYLIB.MYCAT as a search path for the program.
/* All the program's classes */ /* are defined in MYLIB.MYCAT * IMPORT mylib.mycat; /* collobj1 is defined in */ /* mylib.mycat.collection.class */ DECLARE Collection c1=_new_ Collection(); /* collobj2 is defined in */ /* mylib.mycat.OrderedCollection.class */ DECLARE OrderedCollection c2=_new_ OrderedCollection();
This example imports class X from another catalog. Class Y is in the current catalog.
X.SCL class work.cat.x; public num n; endclass; Y.SCL import work.cat2; class y; m: method o: x; o.n=99; endmethod; endclass; Z.SCL init: import work.cat2; dcl y yobj=_new_ y(); dcl x xobj=_new_ x(); yobj.m(xobj); put xobj.n=; return;
This example should produce the following output:
xobj.n=99
See Also |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.