![]() Chapter Contents |
![]() Previous |
![]() Next |
| SAS Component Language: Reference |
First, rewrite the class specification, using the following code:
class ddata; /* Data */ public string dname; public string mode; protected num fid; protected num nvars; /* Constructor method */ ddata: method n: string m:string nv:num / (scl='sasuser.a.constr.scl'); /* FETCH method */ read: method return=num / (scl='sasuser.a.read.scl'); /* GETVARC method */ cpy: method n: num return=string / (scl='sasuser.a.cpy.scl'); /* CLOSE method */ _term: method / (state='O', scl='sasuser.a.trm.scl'); endclass;The method implementations are removed, and the method declaration statements are modified to indicate which SCL entry contains each method implementation. This new class specification should be compiled with the SAVECLASS command.
useclass ddata;
/* Constructor method */
ddata: method n: string m:string nv:num;
fid = open(n, m);
dname = n;
mode = m;
nvars = nv;
endmethod;
enduseclass;SASUSER.A.READ.SCL should contain
useclass ddata;
/* FETCH method */
read: method return=num;
dcl num rc;
rc = fetch(fid);
return rc;
endmethod;
enduseclass;SASUSER.A.CPY.SCL should contain
useclass ddata;
/* GETVARC method */
cpy: method n: num return=string;
dcl string c = "";
if (vartype(fid, n) = 'C') then
c = getvarc(fid, n);
return c;
endmethod;
enduseclass;SASUSER.A.TRM.SCL should contain
useclass ddata;
/* CLOSE method */
_term: method /(state='O');
if (fid) then close(fid);
_super();
endmethod;
enduseclass;
![]() Chapter Contents |
![]() Previous |
![]() Next |
![]() Top of Page |
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.