Previous Page | Next Page

SAS Component Language Dictionary

_NEO_



Creates an object
Category: Object Oriented

Syntax
Details
Example
See Also

Syntax

object-id=_NEO_ class-name(<init-arg<,new-arg-1<, . . . ,new-arg-n>>>);

object-id

contains the identifier for the new object.

Type: Numeric or Object

class-name

is the name of the class from which to create the object. This can be a one- to four-level name. If class-name is a one- or two-level name, and if the CLASS entry that defines class-name is not in the application catalog, then class-name must exist in one of the catalogs defined by the IMPORT statement. Otherwise, the compiler produces an error message.

init-arg

is the argument to pass to the _init method for the new object.

Type: Character

new-arg

are additional arguments to pass to the _new method of the new object.

Type: Character


Details

The _NEO_ operator provides a faster and more direct way to create an object. It combines the actions of loading a class with LOADCLASS and initializing the object with the _new method, which invokes the object's _init method.


Example

Create a frame and enter the following source code:

import sashelp.classes;

init:
  dcl list AttrList RegionList;
  dcl checkbox_c c;

  AttrList   = makelist();
  RegionList = makelist();

  startcol=10;  startrow=10;
  rc = setniteml(AttrList, RegionList, '_region_');
  rc = setnitemn(AttrList, -1, 'num');
  rc = setnitemn(RegionList, startcol, 'ulx');
  rc = setnitemn(RegionList, startrow, 'uly');
  rc = setnitemc(RegionList, 'simple', 'border_style');
  rc = setnitemn(RegionList, 5, 'border_width');
  rc = setnitemc(RegionList, 'red', 'border_color');

  c = _neo_ checkbox_c(attrlist);
  return;

Note that you cannot use the _NEW_ operator to do this, because _NEW_ passes its arguments to a constructor, whereas _NEO_ passes them to the _new method (which is what you want in this case). Even if you created a constructor for the check box, it would not work with the _NEW_ operator because the check box will be displayed before the constructor has a chance to run. Therefore, you must either resort to the old behavior using CALL SEND, or use the _NEO_ operator as shown above.


See Also

DECLARE

IMPORT

INSTANCE

LOADCLASS

Previous Page | Next Page | Top of Page