title: IBM Reflection programming- MoveCursor function issue
body: <p>In IBM Reflection host, i am trying to run a VBA macro for traversing through different screens and fill required information (in a predefined template kind of a screen) to create orders in the system.</p>
  
  <p>In the process, i am trying to utilise the functions- "Session.MoveCursor" and "Session.CursorRow", "Session.CursorColumn" for moving the cursor to a desired position and then reading the cursor position information (to verify the position before writing data on HOST screen)</p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>Dim currRowPos as Integer
  Dim currColPos as Integer
  Session.MoveCursor targetRowPos, targetColPos ' move cursor position
  DoEvents ' custom logic to wait or inlcude delay 1 sec or more, mentioned only single code statement here 
  currRowPos = Session.CursorRow 'get cursor current row position
  currColPos = Session.CursorColumn 'get cursor current column position
  'check current cursor position and write data onto HOST screen
  If targetRowPos = currRowPos And targetColPos = currColPos Then
      Session.TransmitANSI "xyz" 'write xyz on HOST screen
  End If
  </code></pre>
  
  <p>I am trying to write some information on to Host at the desired cursor position and traverse to next screen. In the due process, i am going going back and forth to fill information for multiple items (one at a time).</p>
  
  <p>Sometimes I am facing an issue where the above logic (code) is executed and the cursor is still in old position (not in the desired new row, column position) and the program started writing data in the old position rather than the desired/ target position resulting in a programming error (i.e. 'Session.CursorRow' and 'Session.CursorColumn' are outputting new desired cursor position, when in real time the cursor in its old position on HOST screen).</p>
  
  <p>If anyone has encountered this issue before and/ or have any solution in mind, can you please share the same . Thank you.</p>
  
  <blockquote>
    <p><strong>Pasted Code from comments below</strong></p>
  </blockquote>
  
  <p><strong>here is the delay function being used in the vba program- code</strong> </p>
  
  <pre><code>Public Sub DelayScript(Seconds As Integer) 
     Dim PauseTime, START 
     PauseTime = Seconds 
     START = Timer ' Set start time. 
     Do While Timer &lt; START + PauseTime 
        DoEvents ' Yield to other processes. 
     Loop 
  End Sub
  </code></pre>
  
  <p><em>IBM HOST Programming Reference: <a href="http://docs.attachmate.com/reflection/14.x/prog-ref/ibm/" rel="nofollow">http://docs.attachmate.com/reflection/14.x/prog-ref/ibm/</a></em></p>