Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

two While loops

Status
Not open for further replies.

rajesha24

Technical User
Aug 13, 2012
26
US
I have the below code where there is two While statements the while statement for Input 2 gets looped and then macro gets done, without looping the the while statement for input 1 please advice in this
'--------------------------------------------------------------------------------
' This macro was created by the Macro Recorder.
' Session Document: "SESSION1.EDP"
' Date: Tuesday, August 21, 2012 22:15:53
' User:
'--------------------------------------------------------------------------------

' Global variable declarations
Global g_HostSettleTime%
Global g_szPassword$

Sub Main()
'--------------------------------------------------------------------------------
' Get the main system object
Dim Sessions As Object
Dim System As Object
Set System = CreateObject("EXTRA.System") ' Gets the system object
If (System is Nothing) Then
Msgbox "Could not create the EXTRA System object. Stopping macro playback."
STOP
End If
Set Sessions = System.Sessions

If (Sessions is Nothing) Then
Msgbox "Could not create the Sessions collection object. Stopping macro playback."
STOP
End If
'--------------------------------------------------------------------------------
' Set the default wait timeout value
g_HostSettleTime = 3000 ' milliseconds

OldSystemTimeout& = System.TimeoutValue
If (g_HostSettleTime > OldSystemTimeout) Then
System.TimeoutValue = g_HostSettleTime
End If

' Get the necessary Session Object
Dim Sess0 As Object
Set Sess0 = System.ActiveSession
If (Sess0 is Nothing) Then
Msgbox "Could not create the Session object. Stopping macro playback."
STOP
End If
If Not Sess0.Visible Then Sess0.Visible = TRUE
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

' This section of code contains the recorded events
close

Open "C:\Users\bzxllh\Desktop\New.txt" For Input As #1
Open "C:\Users\bzxllh\Desktop\Part.txt" For Input As #2
'Open "C:\Efiles\Delete\Out Delete.txt" For Output As #2
'Label:
'Input #1, FEWO
'Input #1, Eg1
'Input #1, Eg2
'Input #1, Eg3
'Input #1, Eg4


End_Of_File = Eof(1)

While End_Of_File = 0

Input #1, En


End_Of_Fil = Eof(2)
while End_Of_Fil = 0


Input #2, Pa
Sess0.Screen.MoveTo 04,02
Sess0.Screen.Sendkeys(En &"<tab><EraseEOF><tab><EraseEOF>")
Sess0.Screen.WaitHostQuiet(100)
Sess0.Screen.MoveTo 04,47
Sess0.Screen.Sendkeys(Pa)
'Sess0.Screen.WaitHostQuiet(100)
Sess0.Screen.Sendkeys("<Enter>")
Sess0.Screen.WaitHostQuiet(100)
Sess0.Screen.Sendkeys("<NewLine><NewLine>s<Pf5>")
Sess0.Screen.WaitHostQuiet(100)
NUB = Sess0.Screen.GetString (11, 36, 1)
if NUB = "U" then
Sess0.Screen.WaitHostQuiet(100)
NUE = Sess0.Screen.GetString (13, 17, 4)
Sess0.Screen.WaitHostQuiet(100)
Sess0.Screen.Sendkeys("<NewLine>c<NewLine><NewLine><Tab><Tab><Tab>p<NewLine>gcgzk<EraseEOF>")

If NUE= "WFUO" then

Sess0.Screen.MoveTo 07,03

Sess0.Screen.Sendkeys("c")
Sess0.Screen.MoveTo 13,17

Sess0.Screen.Sendkeys("<EraseEOF>SOP<Tab><Tab><Tab><EraseEOF>")

End If
Sess0.Screen.Sendkeys("<Enter>")

End if
'Sess0.Screen.Sendkeys("<NewLine>c<NewLine><NewLine><Tab><Tab><Tab>p<NewLine>gcgzk<EraseEOF><Enter>")
Sess0.Screen.WaitHostQuiet(100)
Sess0.Screen.Sendkeys("<Enter>")
Sess0.Screen.WaitHostQuiet(100)
Sess0.Screen.Sendkeys("<Pf5>")
Sess0.Screen.WaitHostQuiet(100)

System.TimeoutValue = OldSystemTimeout
Sess0.Screen.WaitHostQuiet(100)


End_Of_Fil = Eof(2)

Wend



End_Of_File = Eof(1)

wend


MsgBox "Macro completed", 0
End Sub
 
This is part of programming that you have to take responsibility for. My must use all the debug tools at your command to observe what is happening and then make appropriate changes, using thoughtful logic.

BTW, your description of what is happening is not at all very clear. FOCUS!

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Hi

It works just added a blank row at the last for two input files

Below is the code
close
Open "C:\Users\bzxllh\Desktop\New.txt" For Input As #1
Open "C:\Users\bzxllh\Desktop\Part.txt" For Input As #2

'Open "C:\Efiles\Delete\Out Delete.txt" For Output As #2
Input #1, Pa
Input #2, En

While EOF(1) = 0


While EOF(2) = 0

Sess0.Screen.MoveTo 3, 14
Sess0.Screen.SendKeys (Pa & "<Enter>")
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.MoveTo 20, 12
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.SendKeys (En)
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)

Input #2, En
Wend

Close #2
Open "C:\Users\bzxllh\Desktop\Part.txt" For Input As #2
Input #2, En

Input #1, Pa
Wend

System.TimeoutValue = OldSystemTimeout
msgbox "macro done"
End Sub

thank you
 
Hi Skip

If input starts from 0 (zero) i,e if input is 09 the 0 is neglected and only 9 is copied. I want 09 to be put at 20,12 in session but instead only 9 appears.
 
So are you stating that your INPUT TEXT file has "09"?

How did you declare En & Pa?

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Input #1
55236681
55242148
55242256

Input #2
14
13
09

In Input #2 after the value 13 at 20,12 in session, I should have a value of 09 in session @ 20,12, but 0 is neglected and only 9 is selected
 
You did not answer my second question.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
ALL variables ought to be declared!!!

Programming 101

Declare those 2 as string

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top