Server Reference Guide : ASOLib--OpenROAD Server Library : How You Can Use ASOLib from a Non-OpenROAD Thin Client : Sample VBScript COM Client Code Fragments
 
Share this page          
Sample VBScript COM Client Code Fragments
The following code fragments illustrate how to drive an OpenROAD Server application that uses ASOLib from a non-OpenROAD COM client. The client language chosen in this example is VBA, such as might be found in a Microsoft Word or Excel macro.
                                        '#--------------------------------------#
                                        '# Create a COM ASOSession helper obj   #
                                        '# and connect to the named application #
                                        '#--------------------------------------#
Set MyASOSession = CreateObject(“OpenROAD.ASOSession”)
 MyASOSession.Connect "Demo App 1"
                                        '#--------------------------------------#
                                        '# Declare the required BPM             #
                                        '#--------------------------------------#
MyASOSession.DefineBPM "uc_authors_pm"
                                        '#--------------------------------------#
                                        '# Declare the byref parameters         #
                                        '# for a GSCP call                      #
                                         #--------------------------------------#
Set byrefPDO = CreateObject("OpenROAD.ParameterData")
byrefPDO.DeclareAttribute "b_arr_author" , "UCARRAY"
byrefPDO.DeclareAttribute "b_arr_author.v_name", "STRING" '# Author name #
byrefPDO.DeclareAttribute "b_arr_author.i_age", "INTEGER" '# Author age  #
                                        '#--------------------------------------#
                                        '# Call GSCP and check for user errors  #
                                        '# (fatal errors handled automatically) #
                                        '#--------------------------------------#
MyASOSession.CallPROC "SCP_GetAuthorList",,byrefPDO
If ASOSession.i_error_no <> 0 then
     MsgBox (MyASOSession.v_msg_txt)
     Stop
End If  
                                        '#--------------------------------------#
                                        '# Inspect the data returned            #
                                        '#--------------------------------------#
rows = byrefPDO.LastRow( "b_arr_author" )
 For i = 1 To rows
     v_arr = "b_arr_author[" & i & "]"   '# Current row #
        
MsgBox (byrefPDO.GetAttribute( v_arr + ".v_name" ))
     MsgBox (byrefPDO.GetAttribute( v_arr + ".i_age" ))
 
Next

Set byrefPDO = Nothing
                                        '#--------------------------------------#
                                        '# Destroy persistent session and       #
                                        '# release the connection               #
                                        '#--------------------------------------#
Set MyASOSession = nothing