Chapter Contents |
Previous |
Next |
SAS/CONNECT User's Guide |
In this example, information is gathered remotely about a class. _GET_METHODS_ is used to return the names of all the methods that are defined for a specific class.
/***************************************/ /* Define rid (remote ID). */ /***************************************/ init: rid = 0; return; main: r_string = ''; c_string = ''; rc=0; remote_c = loadclass('sashelp.connect.robject'); rid = instance(remote_c); /************************************/ /* Define the remote host and */ /* location of the class. */ /************************************/ remval = 'MARS'; classname = 'permdata.roclass.ro2tst.class'; r_string = 'remote//' || remval; /************************************/ /* Create remote instance of class. */ /************************************/ call send(rid, '_createRemoteInstance', r_string, classname, rc); /************************************/ /* Begin method "SEND_METHOD_NUM". */ /************************************/ call send(rid, '_beginMethod', "SEND_METHOD_NUM", rc); /*****************************************/ /* Method "SEND_METHOD_CHR" accepts the */ /* following parameters: */ /* (1) the first parameter must be */ /* the class name, */ /* (2) the second, is the method name */ /* (3) the third, is the result of the */ /* call that is being returned. */ /*****************************************/ /***************************************/ /* Send name of class; mode INPUT. */ /***************************************/ cls = 'permdata.roclass.ro2tst'; c_mode = "I"; c_name = "remote class name"; put "submitting the name of remote class " cls c_mode c_name; call send(rid, '_addMethodArgC', cls, c_mode, rc, c_name); /************************************/ /* Send name of an SCL method to */ /* be used on the remote side; */ /* mode INPUT. */ /************************************/ mth = '_get_methods_'; c_mode = "I"; c_name = "remote method name"; put "submitting the method to remote side " mth c_mode c_name; call send(rid, '_addMethodArgC', mth, c_mode, rc, c_name); /************************************/ /* Update the RESULT parameter to */ /* hold new results; mode OUTPUT. */ /************************************/ result=makelist(); c_mode = "O"; c_name = "result of the remote method"; put "getting the result from remote side " result c_mode c_name; call send(rid, '_addMethodArgL', result, c_mode, rc, c_name); /***************************************/ /* After all the information has */ /* been sent to the remote method, */ /* use INVOKE_METHOD "SEND_METHOD_NUM" */ /***************************************/ put ' '; put 'Invoking SEND_METHOD_NUM method...'; r_list = makelist(); call send(rid, '_invokeMethod', r_list, rc); if (rc eq 0) then do; mrc = getnitemn(r_list, '_mrc', 1, 1, 0); put "method return code= " mrc; /*******************************/ /* After the method is invoked,*/ /* a list is created that holds*/ /* the result. */ /* Fetch the results from that */ /* list and display them to */ /* the log. */ /*******************************/ if (mrc = 0) then do index = 1 to listlen(r_list); select(itemtype(r_list, index)); when('C') do; rem_varc = getitemc(r_list, index); c_name = ''; c_name = nameitem(r_list, index); put 'SEND_METHOD_NUM for character : ' rem_varc c_name; end; when('N') do; rem_varn = getitemn(r_list, index); c_name = ''; c_name = nameitem(r_list, index); put 'SEND_METHOD_NUM for numeric : ' rem_varn c_name; end; when('L') do; rem_varl = getiteml(r_list, index); c_name = ''; c_name = nameitem(r_list, index); put 'SEND_METHOD_NUM for list : ' rem_varl c_name; end; end; end; end; /************************************/ /* _GET_METHODS_ returns a */ /* list; so the result is a list */ /* within r_list (the list that */ /* SEND_METHOD_NUM created). The */ /* remote list needs to be captured,*/ /* and its contents displayed. */ /************************************/ put ' '; if (mrc = 0) then do index = 1 to listlen(rem_varl); select(itemtype(rem_varl, index)); when('C') do; varc = getitemc(rem_varl, index); put '**** character RESULT **** : ' varc ; end; when('N') do; varn = getitemn(rem_varl, index); put '**** numeric RESULT **** : ' varn ; end; when('L') do; varl = getiteml(rem_varl, index); put '**** list RESULT **** : ' varl; end; end; end; /************************************/ /* For clean-up purposes, destroy */ /* the remote instance. */ /************************************/ put 'Destroying remote instance ... '; call send(rid, '_destroyRemoteInstance', rc); return;
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.