저는 Reflections in IDX에서 VBA에서 일하고 있습니다. 루프에 들어갈 수는 있지만 루프를 벗어날 수는 없습니다.VBA MACRO 루프에 갇혀 있습니다
While returnValue = osCurrentScreen.WaitForString3(LF & "Reload Run ", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
If (returnValue <> ReturnCode_Success) Then
While returnValue = osCurrentScreen.WaitForString3(LF & "Load new Run for date ", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
Wend
Else
osCurrentScreen.SendKeys "N"
osCurrentScreen.SendControlKey ControlKeyCode_Return
End If
Wend
루프에 들어가지만 멈 춥니 다.
나는 do loop
, do while
및 while wend
을 사용하려고 시도했습니다. 내가 프롬프트에 대한 말씨를 변경하고, 때로는 루프를 입력하지 않았거나, 루프에 걸렸거나, 루프를 모두 건너 뛰었습니다.
번째 시도 - 같은 결과는 루프를 입력하지만 떠나 내가 문제가 실제로 프롬프트를 읽고 그냥 건너 뛰는 아니에요이라고 생각
Do
If returnValue = osCurrentScreen.WaitForString3(LF & "Reload Run ", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes) Then
osCurrentScreen.SendKeys "N"
osCurrentScreen.SendControlKey ControlKeyCode_Return
Else
'how do i add end loop here? end exit and wend do not work
End If
Loop
다음 단계로 이동하지 않습니다 원하는대로해라.
Do While returnValue = osCurrentScreen.WaitForString3(LF & "Reload Run ", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
'returnValue = osCurrentScreen.WaitForString3(LF & "Reload Run ", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
If returnValue = ReturnCode_Success Then
osCurrentScreen.SendKeys "N"
osCurrentScreen.SendControlKey ControlKeyCode_Return
'returnValue = osCurrentScreen.WaitForString3("? N=> ", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
' Exit Do
' returnValue = osCurrentScreen.WaitForString3(LF & "Load new Run for date ", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
Else
osCurrentScreen.SendKeys "Y"
osCurrentScreen.SendControlKey ControlKeyCode_Return
End If
Exit Do
Loop
전체 코드
Sub Main()
Const NEVER_TIME_OUT = 0
Const DIALOG_TITLE = "idxlog"
Dim filedata As String
Dim row As Integer
Dim singleFile As String
Dim strdate As String
strdate = Format(Date, "mmddyyyy")
Dim osCurrentScreen As Screen
Dim osCurrentTerminal As Terminal
Dim returnValue As Integer
Set osCurrentTerminal = ThisFrame.SelectedView.control
Set osCurrentScreen = osCurrentTerminal.Screen
NUL = Chr(0)
LF = Chr(10)
CR = Chr(13)
ESC = Chr(27)
singleFile = Dir$("C:\CHG" + strdate + ".DAT")
If singleFile <> "" Then
FileCopy "C:\CHG" + strdate + ".DAT", "C:\ CHG" + strdate + ".SAVE"
End If
If canceled Then Exit Sub
With Application
'log into TEST
'SELECT BAR
'FOR TEST UNCOMMENT
osCurrentScreen.SendKeys "1"
'FOR LIVE UNCOMMENT
'osCurrentScreen.SendKeys "3"
osCurrentScreen.SendControlKey ControlKeyCode_Return
'Wait for a string on the host screen before continuing
returnValue = osCurrentScreen.WaitForString3(LF & "Enter Group: ", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
If (returnValue <> ReturnCode_Success) Then
Err.Raise 11001, "WaitForString3", "Timeout waiting for string.", "VBAHelp.chm", "11001"
End If
'SELECT GROUP
osCurrentScreen.SendKeys "3"
osCurrentScreen.SendControlKey ControlKeyCode_Return
'Wait for a string on the host screen before continuing
returnValue = osCurrentScreen.WaitForString3(LF & "Select Function: ", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
If (returnValue <> ReturnCode_Success) Then
Err.Raise 11001, "WaitForString3", "Timeout waiting for string.", "VBAHelp.chm", "11001"
End If
'Step 5
'SELECT SIU INTERFACES
osCurrentScreen.SendKeys "36"
osCurrentScreen.SendControlKey ControlKeyCode_Return
'Wait for a string on the host screen before continuing
returnValue = osCurrentScreen.WaitForString3(LF & "Select Activity: ", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
If (returnValue <> ReturnCode_Success) Then
Err.Raise 11001, "WaitForString3", "Timeout waiting for string.", "VBAHelp.chm", "11001"
End If
'Step 6
'SELECT CHARGE TO TES INTERFACE ACTIVITIES
osCurrentScreen.SendKeys "50"
osCurrentScreen.SendControlKey ControlKeyCode_Return
'Wait for a string on the host screen before continuing
returnValue = osCurrentScreen.WaitForString3(BS & ESC & "[25;1H", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
If (returnValue <> ReturnCode_Success) Then
Err.Raise 11001, "WaitForString3", "Timeout waiting for string.", "VBAHelp.chm", "11001"
End If
'Step 7
'TYPE L TO LOAD INTERFACE
osCurrentScreen.SendKeys "L"
'Wait for a string on the host screen before continuing
returnValue = osCurrentScreen.WaitForString3(LF & "Charge Interface Run Date: ", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
If (returnValue <> ReturnCode_Success) Then
Err.Raise 11001, "WaitForString3", "Timeout waiting for string.", "VBAHelp.chm", "11001"
End If
'Step 8
'DATE T=TODAY
osCurrentScreen.SendKeys "T"
osCurrentScreen.SendControlKey ControlKeyCode_Return
'While returnValue = osCurrentScreen.WaitForString3(LF & "Reload Run ", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
'While returnValue = Ture
While returnValue = osCurrentScreen.WaitForString3(LF & "Reload Run ", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
' (returnValue = osCurrentScreen.WaitForString3("? N=> ", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes))
' returnValue = osCurrentScreen.WaitForString3(LF & "Load new Run for date ", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
If (returnValue <> ReturnCode_Success) Then
' Exit Do
While returnValue = osCurrentScreen.WaitForString3(LF & "Load new Run for date ", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
Wend
Else
osCurrentScreen.SendKeys "N"
osCurrentScreen.SendControlKey ControlKeyCode_Return
End If
' Loop
Wend
' Wait (1)
'STEP 9
'LOAD NEW RUN
'Wait for a string on the host screen before continuing
returnValue = osCurrentScreen.WaitForString3("? N=> ", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
If (returnValue <> ReturnCode_Success) Then
Err.Raise 11001, "WaitForString3", "Timeout waiting for string.", "VBAHelp.chm", "11001"
End If
osCurrentScreen.SendKeys "Y"
osCurrentScreen.SendControlKey ControlKeyCode_Return
'Step 10
'SERIAL NUMBER
'Wait for a string on the host screen before continuing
returnValue = osCurrentScreen.WaitForString3(LF & "Serial Number: ", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
If (returnValue <> ReturnCode_Success) Then
Err.Raise 11001, "WaitForString3", "Timeout waiting for string.", "VBAHelp.chm", "11001"
End If
osCurrentScreen.SendKeys strdate
osCurrentScreen.SendControlKey ControlKeyCode_Return
'Wait for a string on the host screen before continuing
returnValue = osCurrentScreen.WaitForString3(LF & "Description: ", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
If (returnValue <> ReturnCode_Success) Then
Err.Raise 11001, "WaitForString3", "Timeout waiting for string.", "VBAHelp.chm", "11001"
End If
'Description and Device Prompts
osCurrentScreen.SendKeys "CONTEXT"
osCurrentScreen.SendControlKey ControlKeyCode_Return
'Wait for a string on the host screen before continuing
returnValue = osCurrentScreen.WaitForString3(LF & "Device: ", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
If (returnValue <> ReturnCode_Success) Then
Err.Raise 11001, "WaitForString3", "Timeout waiting for string.", "VBAHelp.chm", "11001"
End If
osCurrentScreen.SendControlKey ControlKeyCode_Return
'Wait for a string on the host screen before continuing
returnValue = osCurrentScreen.WaitForString3(" Right margin: ", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
If (returnValue <> ReturnCode_Success) Then
Err.Raise 11001, "WaitForString3", "Timeout waiting for string.", "VBAHelp.chm", "11001"
End If
'Wait for a string on the host screen before continuing
returnValue = osCurrentScreen.WaitForString3("=> ", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
If (returnValue <> ReturnCode_Success) Then
Err.Raise 11001, "WaitForString3", "Timeout waiting for string.", "VBAHelp.chm", "11001"
End If
osCurrentScreen.SendControlKey ControlKeyCode_Return
'Wait for a string on the host screen before continuing
'Step 12 -15
'Set source file
returnValue = osCurrentScreen.WaitForString3(LF & "Enter RMS file source (CCA/CONTEXT): ", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
If (returnValue <> ReturnCode_Success) Then
Err.Raise 11001, "WaitForString3", "Timeout waiting for string.", "VBAHelp.chm", "11001"
End If
osCurrentScreen.SendKeys "CONTEXT"
osCurrentScreen.SendControlKey ControlKeyCode_Return
'Wait for a string on the host screen before continuing
'Step 16
'Process runs
'Step 17
'Reflections will wait on Prompt "Do you Wish To Continue?" (Y)es
returnValue = osCurrentScreen.WaitForString3(LF & "Do you wish to continue ? Y=> ", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
If (returnValue <> ReturnCode_Success) Then
Err.Raise 11001, "WaitForString3", "Timeout waiting for string.", "VBAHelp.chm", "11001"
End If
osCurrentScreen.SendControlKey ControlKeyCode_Return
'Wait for a string on the host screen before continuing
returnValue = osCurrentScreen.WaitForString3(LF & "Press <ENTER> to Continue: ", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
If (returnValue <> ReturnCode_Success) Then
Err.Raise 11001, "WaitForString3", "Timeout waiting for string.", "VBAHelp.chm", "11001"
End If
osCurrentScreen.SendControlKey ControlKeyCode_Return
'Wait for a string on the host screen before continuing
returnValue = osCurrentScreen.WaitForString3("r" & ESC & "[16;1H" & ESC & "[1C" & ESC & "[1;7m ", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
If (returnValue <> ReturnCode_Success) Then
Err.Raise 11001, "WaitForString3", "Timeout waiting for string.", "VBAHelp.chm", "11001"
End If
'Wait for a string on the host screen before continuing
returnValue = osCurrentScreen.WaitForString3(" Selected F", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
If (returnValue <> ReturnCode_Success) Then
Err.Raise 11001, "WaitForString3", "Timeout waiting for string.", "VBAHelp.chm", "11001"
End If
'Wait for a string on the host screen before continuing
returnValue = osCurrentScreen.WaitForString3("Q-Quit F", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
If (returnValue <> ReturnCode_Success) Then
Err.Raise 11001, "WaitForString3", "Timeout waiting for string.", "VBAHelp.chm", "11001"
End If
'Wait for a string on the host screen before continuing
returnValue = osCurrentScreen.WaitForString3("-OK <HELP>-Help F", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
If (returnValue <> ReturnCode_Success) Then
Err.Raise 11001, "WaitForString3", "Timeout waiting for string.", "VBAHelp.chm", "11001"
End If
'Wait for a string on the host screen before continuing
returnValue = osCurrentScreen.WaitForString3("-More Keys " & ESC & "[0m" & ESC & "[78D" & ESC & "[25;1H", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
If (returnValue <> ReturnCode_Success) Then
Err.Raise 11001, "WaitForString3", "Timeout waiting for string.", "VBAHelp.chm", "11001"
End If
'Step 20 Process Context file
'send "p" to process
osCurrentScreen.SendKeys "P"
'Wait for a string on the host screen before continuing
returnValue = osCurrentScreen.WaitForString3(LF & "Charge Interface Date: ", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
If (returnValue <> ReturnCode_Success) Then
Err.Raise 11001, "WaitForString3", "Timeout waiting for string.", "VBAHelp.chm", "11001"
End If
'step 21
'send date
osCurrentScreen.SendKeys strdate
osCurrentScreen.SendControlKey ControlKeyCode_Return
'Wait for a string on the host screen before continuing
returnValue = osCurrentScreen.WaitForString3(LF & "Process run ", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
If (returnValue <> ReturnCode_Success) Then
Err.Raise 11001, "WaitForString3", "Timeout waiting for string.", "VBAHelp.chm", "11001"
End If
'Wait for a string on the host screen before continuing
returnValue = osCurrentScreen.WaitForString3(" ? N=> ", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
If (returnValue <> ReturnCode_Success) Then
Err.Raise 11001, "WaitForString3", "Timeout waiting for string.", "VBAHelp.chm", "11001"
End If
osCurrentScreen.SendControlKey ControlKeyCode_Return
'Wait for a string on the host screen before continuing
returnValue = osCurrentScreen.WaitForString3(LF & "Charge Interface Date: ", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
If (returnValue <> ReturnCode_Success) Then
Err.Raise 11001, "WaitForString3", "Timeout waiting for string.", "VBAHelp.chm", "11001"
End If
osCurrentScreen.SendKeys "T"
osCurrentScreen.SendControlKey ControlKeyCode_Return
'Wait for a string on the host screen before continuing
returnValue = osCurrentScreen.WaitForString3(LF & "Process run ", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
If (returnValue <> ReturnCode_Success) Then
Err.Raise 11001, "WaitForString3", "Timeout waiting for string.", "VBAHelp.chm", "11001"
End If
'Wait for a string on the host screen before continuing
returnValue = osCurrentScreen.WaitForString3(" ? N=> ", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
If (returnValue <> ReturnCode_Success) Then
Err.Raise 11001, "WaitForString3", "Timeout waiting for string.", "VBAHelp.chm", "11001"
End If
osCurrentScreen.SendKeys "Y"
osCurrentScreen.SendControlKey ControlKeyCode_Return
'Wait for a string on the host screen before continuing
'Step 24
'Do you want to Queue this activity? (N)o
returnValue = osCurrentScreen.WaitForString3(LF & "Do you want to queue this activity? No=> ", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
If (returnValue <> ReturnCode_Success) Then
Err.Raise 11001, "WaitForString3", "Timeout waiting for string.", "VBAHelp.chm", "11001"
End If
'might not need
'osCurrentScreen.SendKeys "N"
osCurrentScreen.SendControlKey ControlKeyCode_Return
'Wait for a string on the host screen before continuing
returnValue = osCurrentScreen.WaitForString3(LF & "Device: ", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
If (returnValue <> ReturnCode_Success) Then
Err.Raise 11001, "WaitForString3", "Timeout waiting for string.", "VBAHelp.chm", "11001"
End If
'Step 25
'Set Dir to DList2 and File Name
osCurrentScreen.SendKeys "IDXSTAFF:CONTEXT" + strdate + ".TXT"
osCurrentScreen.SendControlKey ControlKeyCode_Return
'Wait for a string on the host screen before continuing
returnValue = osCurrentScreen.WaitForString3(" Parameters: ""RWSN"" => ", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
If (returnValue <> ReturnCode_Success) Then
Err.Raise 11001, "WaitForString3", "Timeout waiting for string.", "VBAHelp.chm", "11001"
End If
'Process is complete from Step 25
osCurrentScreen.SendControlKey ControlKeyCode_Return
'Wait for a string on the host screen before continuing
returnValue = osCurrentScreen.WaitForString3("r" & ESC & "[16;1H" & ESC & "[1C" & ESC & "[1;7m ", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
If (returnValue <> ReturnCode_Success) Then
Err.Raise 11001, "WaitForString3", "Timeout waiting for string.", "VBAHelp.chm", "11001"
End If
'Wait for a string on the host screen before continuing
returnValue = osCurrentScreen.WaitForString3(" Selected F", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
If (returnValue <> ReturnCode_Success) Then
Err.Raise 11001, "WaitForString3", "Timeout waiting for string.", "VBAHelp.chm", "11001"
End If
'Wait for a string on the host screen before continuing
returnValue = osCurrentScreen.WaitForString3("Q-Quit F", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
If (returnValue <> ReturnCode_Success) Then
Err.Raise 11001, "WaitForString3", "Timeout waiting for string.", "VBAHelp.chm", "11001"
End If
'Wait for a string on the host screen before continuing
returnValue = osCurrentScreen.WaitForString3("-OK <HELP>-Help F", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
If (returnValue <> ReturnCode_Success) Then
Err.Raise 11001, "WaitForString3", "Timeout waiting for string.", "VBAHelp.chm", "11001"
End If
'Wait for a string on the host screen before continuing
returnValue = osCurrentScreen.WaitForString3("-More Keys " & ESC & "[0m" & ESC & "[78D" & ESC & "[25;1H", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
If (returnValue <> ReturnCode_Success) Then
Err.Raise 11001, "WaitForString3", "Timeout waiting for string.", "VBAHelp.chm", "11001"
End If
'EXIT DONE
' Press VtF7 (Perform the Vt F7 function).
osCurrentScreen.SendControlKey ControlKeyCode_F7
osCurrentScreen.SendKeys "Q"
'Wait for a string on the host screen before continuing
returnValue = osCurrentScreen.WaitForString3(LF & "Select Activity: ", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
If (returnValue <> ReturnCode_Success) Then
Err.Raise 11001, "WaitForString3", "Timeout waiting for string.", "VBAHelp.chm", "11001"
End If
osCurrentScreen.SendControlKey ControlKeyCode_Return
'Wait for a string on the host screen before continuing
returnValue = osCurrentScreen.WaitForString3(LF & "Select Function: ", NEVER_TIME_OUT, WaitForOption.WaitForOption_AllowKeystrokes)
If (returnValue <> ReturnCode_Success) Then
Err.Raise 11001, "WaitForString3", "Timeout waiting for string.", "VBAHelp.chm", "11001"
End If
osCurrentScreen.SendControlKey ControlKeyCode_Return
Exit Sub
End With
End Sub
에 오신 것을 환영합니다 SO합니다. 질문을 더 이해하기 쉽도록하려면 코드 들여 쓰기를 수정해야 할 수도 있습니다. –
더 나은 품질 감사합니다 – JStiner
코드에 < > 표지판을 다시 삽입하는 것 같습니다. 제발 삼가주세요. 예를 읽을 수 없게 만듭니다. –