SAS SCL programming use skills - object-oriented programming

xiaoxiao2021-03-06  61

SAS SCL programming use skills - object-oriented programming

(Note that the SAS8 version will only support OOP)

SCL is SAS program control language, which also has some of the features of the high-level language, supports the image-oriented programming, let's introduce how to generate classes, objects, and objects with SAS.

1. First create a SCL file, enter the code class name of the following structure; / * Property definition * / public ...; private ...; / * Method definition * / method name: public method parameter ...; ... endMethod; EndMethod; EndClass, a class framework is basically completed, such as saving as a c_test file, then compiling the file, and finally pay attention to the [Save As class] of the menu bar, this will generate a class of c_test.class file SAS. Technologies, also supported by inheritance, method overloading, such as the same method can be written in the same class. As long as the parameters are different, there is no special label class inherit using the following syntax Class subclass name EXTENDS parent class; ... endlcass; For all the non-private methods and properties of the parent class, if you want to overload the parent class, you can use the following syntax parent class method: public method parameter / (state = 'o'); ... _super (..) ; Note that the method is added after the method is added (state = 'o') keyword, if you want to call the same name method of the parent class in the method of overloading the subclass, use the _super () keyword To the initial Attributes, use two methods 1. Assign a value directly on attributes, the syntax is as follows, such as public List showinfolist / (InitialValue = {1, 2, 3, 4}) uses the initialvalue keyword 2. The application class method class generates the configuration of the constructor before, the name of the constructor should be the same name, such as c_test: method; .. endmethod; Note, no return value is now initialized in this method, Note that if the constructor exists in the parent class, you need to overload constructors to release some global resources, overloaded the _TERM () method, which is equivalent to the destructor_Term: method ..; / * Release resource * /. . . Endmethod; Ok, about the writing of the class, please see the help of SAS for details.

2. Class call class cannot be called directly, first generate an object, easy to use, such as DCL C_TEST OBJ1; OBJ1 = _NEW_ C_TEST (); ... Obj1._Term (); note, SAS has a special type Object, Any object can assign him, such as DCL Object Obj1; Obj1 = _new_ c_test (); ... Obj1._Term (); SAS's SCL is a weak type of language, so there is not so much restriction, Heph, you want Why do you do it, if SAS doesn't agree with your thoughts, you will report the wrong OK. About SAS's OOP will introduce this, if there is anything wrong, please also have a lot of Haihan.

转载请注明原文地址:https://www.9cbs.com/read-115158.html

New Post(0)