我正在使用3270终端大型机。我的屏幕有30个位置,我需要从文本文件中读取内容并将A列中的值粘贴到屏幕上的30个不同位置。文本文件可以具有任意数量的行,但是每次迭代我只能粘贴30个位置。填充完这30个位置后,我单击Enter,将清除屏幕,然后我可以粘贴另外30个,依此类推。如果再粘贴30个,则可能少于30个。
文本文件中只有一列(A列)。文本文件的A列第1行将粘贴到第1个位置。 A列第2行将粘贴到第二个位置,依此类推...
我创建了一个循环,该循环从我的文本文件读取并将值拉入我的代码,并且能够将值粘贴到该第一个位置。然后,我需要移至下一行并将下一个值粘贴到下一个位置。我正在尝试这样做,而不必创建30个不同的Do..Until
循环。
这是我的循环,它从文本文件中读取内容,
Sub sub_Run_Loop
i = 0
CountLoans = 0
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
arrFields = Split(strLine, ",")
subDoWork (i)
i = i + 1
Loop
End Sub
Sub subDoWork (i)
ColumnA = arrFields(0)
CurrentRow = i
ActualRow = CurrentRow - 1
For CurrentRow = 1 To ActualLoans
subMoveCursor 13, 4
subEnterData ColumnA
CountLoans = CountLoans + 1
Next
i = i + 1
'At Right here, I need to move to the next value in Column A
'from the text file and paste to the next position
subMoveCursor 14, 4
subEnterData ColumnA
CountLoans = CountLoans + 1
CountLoans = CountLoans + 1
If CountLoans >= ActualLoans Then
subEndScript
End If
End Sub
我试图从一行移动到另一行,同时将值粘贴到不同的位置,而不必创建30个不同的循环。
答案 0 :(得分:0)
我解决了这个问题。我所做的是在三列上设置了一个阈值,该阈值保留了我需要粘贴的位置,并在每次重复30次之后将该阈值增加了10(每列10行)。我还重新组织了循环中的计数,似乎已经解决了顺序移动三列中的行的问题。
Sub sub_Run_Loop
Column1Threshold = 10
Column2Threshold = 20
Column3Threshold = 30
CountButtonClicks = 0
ClickTime = 30
i = 1
CountLoans = 1
Column = 13
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
arrFields = Split(strLine,",")
subDoWork (i)
i = i + 1
CountLoans = CountLoans + 1
Column = Column + 1
If Column > 22 Then
Column = 13
End If
If CountLoans > ClickTime Then
subPressKey "@E"
Column1Threshold = Column1Threshold + 10
Column2Threshold = Column2Threshold + 10
Column3Threshold = Column3Threshold + 10
ClickTime = ClickTime + 30
CountButtonClicks = CountButtonClicks +1
End If
If CountLoans > ActualLoans Then
subEndScript
End If
Loop
End Sub
Sub subDoWork (i)
ColumnA = arrFields(0)
CurrentRow = i
If CountLoans <= Column1Threshold Then
Row = 4
End If
If CountLoans > Column1Threshold Then
Row = 31
End If
If (CountLoans >= Column2Threshold) and (CountLoans <=
Column3Threshold) Then
Row = 58
End If
subMoveCursor Column, Row
subEnterData ColumnA
End Sub