首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >IBM反射编程- MoveCursor函数问题

IBM反射编程- MoveCursor函数问题
EN

Stack Overflow用户
提问于 2016-08-23 21:00:32
回答 1查看 1.8K关注 0票数 0

在IBM反射主机中,我试图运行一个VBA宏,用于遍历不同的屏幕,并填充所需的信息(在预定义的模板类型的屏幕中),以便在系统中创建订单。

在此过程中,我试图使用"Session.MoveCursor“和"Session.CursorRow”、"Session.CursorColumn“函数将光标移动到所需的位置,然后读取光标位置信息(在主屏幕上写入数据之前验证位置)。

代码:

代码语言:javascript
复制
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

我试图写一些信息到主机在所需的光标位置,并遍历到下一个屏幕。在适当的程序中,我来回地填写多个项目的信息(一次一个)。

有时,我面临的问题是执行上述逻辑(代码),光标仍然处于旧位置(而不是在所需的新行、列位置),程序开始以旧位置而不是期望的/目标位置写入数据,从而导致编程错误(例如,'Session.CursorRow‘和'Session.CursorColumn’正在输出新的所需的光标位置,当光标实时地在主机屏幕上的旧位置时)。

如果有人以前遇到过这个问题和/或有任何解决方案,请你分享同样的。谢谢。

下面的注释粘贴代码

这里是vba程序代码中使用的延迟函数。

代码语言:javascript
复制
Public Sub DelayScript(Seconds As Integer) 
   Dim PauseTime, START 
   PauseTime = Seconds 
   START = Timer ' Set start time. 
   Do While Timer < START + PauseTime 
      DoEvents ' Yield to other processes. 
   Loop 
End Sub

IBM主机编程参考:http://docs.attachmate.com/reflection/14.x/prog-ref/ibm/

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-08-23 21:20:20

如果我正确理解您的问题,底层连接中的延迟会干扰代码的计时。通常,您应该使用DoEvents或定时代码,而不是使用Wait*方法,让反射来处理您的时间安排。我猜你更需要这样的东西:

代码语言:javascript
复制
With Session
    .MoveCursor targetRowPos, targetColPos 
    '10 second timeout.
    .WaitForEvent rcEnterPos, "10", "", targetRowPos, targetColPos 
    'Verify that you didn't time out.
    If targetRowPos = .CursorRow And targetColPos = .CursorColumn Then
        Session.TransmitANSI "xyz" 'write xyz on HOST screen
    End If
End With

另外(假设它是一个字段),您可以在rcEnterField上而不是rcEnterPos上等待。见这里的文件

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39110600

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档