Connect
Previous  Next

Tries to open an asynchronously connection with the device.
The application will not stop waiting for the connection.
You can use the Connected and Disconnected events to do something after the connection or you can create a time limited loop which waits for the connection.
Syntax: Connect

Example: Connecting using a time limited loop.
'Add a RAPIDesktop object named rapi.
Sub Globals


End Sub

Sub App_Start
      Form1.Show
      rapi.New1
      rapi.Connect
      t = now '3 seconds timeout.
      do until rapi.IsConnected = true
            doevents
            if (now - t)/cTicksPerSecond > 3 then
                  msgbox("Cannot connect to device.")
                  appclose
            end if
      loop
      if rapi.DeviceFileExists("\My Documents\MyApp.exe") = true then
            rapi.CopyFileToDevice1(AppPath & "\data.dat","\My Documents")
            rapi.DeviceShell("MyApp.exe","")
      end if
End Sub

Example: Connecting using Connected event.

'Add a RAPIDesktop object named rapi.
Sub Globals


End Sub

Sub App_Start
      Form1.Show
      rapi.New1
      rapi.Connect   
End Sub


Sub rapi_Connected
      if rapi.DeviceFileExists("\My Documents\MyApp.exe") = true then
            rapi.CopyFileToDevice1(AppPath & "\data.dat","\My Documents")
            rapi.DeviceShell("MyApp.exe","")
      end if
End Sub