Created On:  28 April 2011
 
There is no in-built function that allows a user to switch between the Classic and Open Agents, as SilkTest is able to automatically determine which agent should be used to replay a particular 4Test statement. However, should a user want to ensure that they are connected to a particular Agent before replaying a block of 4Test code the following function can be used:

     [-] void ChangeAgent(String sAgent)
           [ ] List of HANDLE lhAgents = GetConnected()
           [ ] 
           [ ] HANDLE hAgent
           [ ] 
           [-] for each hAgent in lhAgents
                 [-] if(GetMachineAgentType(hAgent) == sAgent)
                       [ ] SetMachine(hAgent)
                       [ ] break


The following simple testcase can be used to verify that the above function works as expected

     [-] testcase verifyConnected() appstate none
           [ ] DisconnectAll()
           [ ] Connect("(local)",CLASSIC_AGENT)
           [ ] Connect("(local)",OPEN_AGENT)
           [ ] 
           [ ] ChangeAgent(CLASSIC_AGENT)
           [ ] print(GetMachineAgentType())
           [ ] 
           [ ] ChangeAgent(OPEN_AGENT)
           [ ] print(GetMachineAgentType())