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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Endless looping

Status
Not open for further replies.

southpaw81

Programmer
Feb 19, 2004
16
0
0
US
Ok, I am so close to finishing this code. Currently I am telling the macro to search through my entire hier, if you see something in row 15,16 columns 8-19 of my session that matches V1, L1, etc, then put an M by it and continue with the code.

The problem is the macro keeps skipping past the V1, L1 on the account, it doesnt even write them to file *per the code*, it just keeps pressing enter and cycling through the accounts eternally?

Can anyone assist




*---------------------------------------*

' Global Subroutine Declarations
Declare Sub GetSystem
Declare Sub AddToMacroLog

' Global variable declarations
Global g_HostSettleTime%
Global Session As Object
Global System As Object
Global Screen As Object
Global Sess0 As Object
Global MacroName As String

Sub Main()
Dim ListsList(100) as String
GetSystem
' AddToMacroLog

Begin Dialog newdlg 175, 53
TextBox 15, 25, 90, 15, .TextBox1
OkButton 115, 10, 50, 14
CancelButton 115, 25, 50, 14
Text 15, 10, 85, 10, "Enter H1 or L1 account ID"
End Dialog
Dim dMain as newdlg

iDone = FALSE
While iDone = FALSE
nRet = Dialog(dMain)
Select Case nRet
Case -1
iDone = TRUE
AcctID = dMain.TextBox1
Filenum% = Freefile
Filename$ = "c:\" + acctID + "_VACFList.txt"
Open Filename$ for Output as Filenum%
Print # Filenum%, "Account ID ;Account Name ;List ID ;Code ;Status"
Close Filenum%
Sess0.Screen.Row = 21
Sess0.Screen.Col = 8
Sess0.Screen.Sendkeys(AcctID)
Sess0.Screen.Sendkeys("<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
'changing from (6, 56, 6, 57)
acctType = Sess0.Screen.Area(6, 56, 6, 57)
If ((acctType = "VN") or (acctType = "TC") or (acctType = "VC") or (acctType = "L9") or (acctType = "V1")) then
acctType = "L1"
End If
Select Case acctType
Case "H1"
Sess0.Screen.Row = 22
Sess0.Screen.Col = 18
Sess0.Screen.Sendkeys("HIER<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
'here its messing up
h1Count = 0
hiEnd = FALSE
While hiEnd = FALSE
For hiStep = 8 to 19
acType = Sess0.Screen.Area(hiCount, 15, hiCount, 16, , xBlock)
If ((acType = "VN") or (acType = "TC") or (acType = "VC") or (acType = "L9") or (acType = "V1")) then
acType = "L1"
End If
Select Case acType
Case "H1"
h1Count = h1Count + 1
If h1Count > 1 then
hiEnd = TRUE
hiStep = 19
End If
Case " "
hiEnd = TRUE
hiStep = 19
Case "L1"
Sess0.Screen.Row = hiStep
'changed 4 to 3
Sess0.Screen.Col = 4
Sess0.Screen.Sendkeys("M<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
'------------------------------------------------------------------------
Filenum% = Freefile
Filename$ = "C:\" + acctID + "_VACFList.txt"
Open Filename$ for append as Filenum%
Sess0.Screen.Row = 22
Sess0.Screen.Col = 18
Sess0.Screen.Sendkeys("AF L D<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
ListsFound = 0
listEnd = FALSE
While not listEnd
For listStep = 12 to 19
listStat = Sess0.Screen.Area(listStep, 28, listStep, 28)
If listStat = "A" then
ListsFound = ListsFound + 1
ListsList(ListsFound) = Sess0.Screen.Area(listStep, 11, listStep, 14)
End If
If listStat = " " then
listEnd = TRUE
listStep = 19
End If
If ((listStep = 19) and (Sess0.Screen.Area(1, 2, 1, 20) = "End of data reached")) then
listEnd = TRUE
End If
Next
If not listEnd then
Sess0.Screen.Sendkeys("<PF8>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
End If
Wend
If listsFound > 0 then
For listStep = 1 to ListsFound
Sess0.Screen.Row = 22
Sess0.Screen.Col = 18
Sess0.Screen.Sendkeys("AF L M<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Row = 21
Sess0.Screen.Col = 39
Sess0.Screen.Sendkeys(ListsList(ListStep))
Sess0.Screen.Sendkeys("<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
svcID = Sess0.Screen.ARea(21, 18, 21, 26)
acctName = Sess0.Screen.ARea( 6, 8, 6, 57)
Digits = Val(Sess0.Screen.Area(9, 42, 9, 43))
Sess0.Screen.Sendkeys("<PF5>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Row = 13
Sess0.Screen.Col = 27
Sess0.Screen.Sendkeys(svcID)
Sess0.Screen.Row = 13
Sess0.Screen.Col = 37
Sess0.Screen.Sendkeys(ListsList(listStep))
Sess0.Screen.Row = 13
Sess0.Screen.Col = 42
Sess0.Screen.Sendkeys("0")
If digits > 1 then
Sess0.Screen.Sendkeys("0")
End If
If digits > 2 then
Sess0.Screen.Sendkeys("0")
End If
If digits > 3 then
Sess0.Screen.Sendkeys("0")
End If
If digits > 4 then
Sess0.Screen.Sendkeys("0")
End If
If digits > 5 then
Sess0.Screen.Sendkeys("0")
End If
If digits > 6 then
Sess0.Screen.Sendkeys("0")
End If
If digits > 7 then
Sess0.Screen.Sendkeys("0")
End If
If digits > 8 then
Sess0.Screen.Sendkeys("0")
End If
If digits > 9 then
Sess0.Screen.Sendkeys("0")
End If
Sess0.Screen.Sendkeys("<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
codeEnd = FALSE
While codeEnd = FALSE
For codeStep = 13 to 19
If not (Sess0.Screen.Area(codeStep, 14, codeStep, 23) = " ") then
acctBuff = svcID + " ;" + AcctName + ";" + ListsList(listStep) + " ;" + Sess0.Screen.Area(codeStep, 14, codeStep, 23) + " ;" + Sess0.Screen.Area(codeStep, 9, codeStep, 9)
Print # Filenum%, acctBuff
End If
If not (Sess0.Screen.Area(codeStep, 54, codeStep, 63) = " ") then
If not (codeStep = 19) then
acctBuff = svcID + " ;" + acctName + ";" + ListsList(listStep) + " ;" + Sess0.Screen.Area(codeStep, 54, codeStep, 63) + " ;" + Sess0.Screen.Area(codeStep, 49, codeStep, 49)
Print # Filenum%, acctBuff
End If
End If
Next
If Sess0.Screen.Area(19, 54, 19, 63) = " " then
codeEnd = TRUE
End If
If not codeEnd then
nextCode = Sess0.Screen.Area(19, 54, 19, 63)
Sess0.Screen.Row = 21
Sess0.Screen.Col = 60
Sess0.Screen.Sendkeys("<EraseEOF>")
Sess0.Screen.Sendkeys(nextCode)
Sess0.Screen.Sendkeys("<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
End If
Wend
Next
End If
Close Filenum%
Sess0.Screen.Row = 22
Sess0.Screen.Col = 18
Sess0.Screen.Sendkeys("HIER<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
hiStep = 8
'-------------------------------------------------------------------------
End Select
Next
If not hiEnd then
Sess0.Screen.Sendkeys("<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
End If
Wend
Sess0.Screen.Row = 22
Sess0.Screen.Col = 76
Sess0.Screen.Sendkeys("/CSD<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Case "L1"
'-------------------------------------------------------------------------
Filenum% = Freefile
Filename$ = "C:\" + acctID + "_VACFList.txt"
Open Filename$ for append as Filenum%
Sess0.Screen.Row = 22
Sess0.Screen.Col = 18
Sess0.Screen.Sendkeys("AF L D<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
ListsFound = 0
listEnd = FALSE
While not listEnd
For listStep = 12 to 19
listStat = Sess0.Screen.Area(listStep, 28, listStep, 28)
If listStat = "A" then
ListsFound = ListsFound + 1
ListsList(ListsFound) = Sess0.Screen.Area(listStep, 11, listStep, 14)
End If
If listStat = " " then
listEnd = TRUE
listStep = 19
End If
If ((listStep = 19) and (Sess0.Screen.Area(1, 2, 1, 20) = "End of data reached")) then
listEnd = TRUE
End If
Next
If not listEnd then
Sess0.Screen.Sendkeys("<PF8>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
End If
Wend
If listsFound > 0 then
For listStep = 1 to ListsFound
Sess0.Screen.Row = 22
Sess0.Screen.Col = 18
Sess0.Screen.Sendkeys("AF L M<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Row = 21
Sess0.Screen.Col = 39
Sess0.Screen.Sendkeys(ListsList(ListStep))
Sess0.Screen.Sendkeys("<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
svcID = Sess0.Screen.ARea(21, 18, 21, 26)
acctName = Sess0.Screen.ARea( 6, 8, 6, 57)
Digits = Val(Sess0.Screen.Area(9, 42, 9, 43))
Sess0.Screen.Sendkeys("<PF5>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Row = 13
Sess0.Screen.Col = 27
Sess0.Screen.Sendkeys(svcID)
Sess0.Screen.Row = 13
Sess0.Screen.Col = 37
Sess0.Screen.Sendkeys(ListsList(listStep))
Sess0.Screen.Row = 13
Sess0.Screen.Col = 42
Sess0.Screen.Sendkeys("0")
If digits > 1 then
Sess0.Screen.Sendkeys("0")
End If
If digits > 2 then
Sess0.Screen.Sendkeys("0")
End If
If digits > 3 then
Sess0.Screen.Sendkeys("0")
End If
If digits > 4 then
Sess0.Screen.Sendkeys("0")
End If
If digits > 5 then
Sess0.Screen.Sendkeys("0")
End If
If digits > 6 then
Sess0.Screen.Sendkeys("0")
End If
If digits > 7 then
Sess0.Screen.Sendkeys("0")
End If
If digits > 8 then
Sess0.Screen.Sendkeys("0")
End If
If digits > 9 then
Sess0.Screen.Sendkeys("0")
End If
Sess0.Screen.Sendkeys("<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
codeEnd = FALSE
While codeEnd = FALSE
For codeStep = 13 to 19
If not (Sess0.Screen.Area(codeStep, 14, codeStep, 23) = " ") then
acctBuff = svcID + " ;" + acctName + ";" + ListsList(listStep) + " ;" + Sess0.Screen.Area(codeStep, 14, codeStep, 23) + " ;" + Sess0.Screen.Area(codeStep, 9, codeStep, 9)
Print # Filenum%, acctBuff
End If
If not (Sess0.Screen.Area(codeStep, 54, codeStep, 63) = " ") then
If not (codeStep = 19) then
acctBuff = svcID + " ;" + acctName + ";" + ListsList(listStep) + " ;" + Sess0.Screen.Area(codeStep, 54, codeStep, 63) + " ;" + Sess0.Screen.Area(codeStep, 49, codeStep, 49)
Print # Filenum%, acctBuff
End If
End If
Next
If Sess0.Screen.Area(19, 54, 19, 63) = " " then
codeEnd = TRUE
End If
If not codeEnd then
nextCode = Sess0.Screen.Area(19, 54, 19, 63)
Sess0.Screen.Row = 21
Sess0.Screen.Col = 60
Sess0.Screen.Sendkeys("<EraseEOF>")
Sess0.Screen.Sendkeys(nextCode)
Sess0.Screen.Sendkeys("<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
End If
Wend
Next
End If
Close Filenum%
Sess0.Screen.Row = 22
Sess0.Screen.Col = 18
Sess0.Screen.Sendkeys("CS D<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
'-------------------------------------------------------------------------
Case Else
MsgBox "You must enter an H1 or L1 account Only!"
iDone = FALSE
End Select
Case 0
iDone = TRUE
End Select
Wend


End Sub

Sub GetSystem
'--------------------------------------------------------------------------------
MacroName = "VACF List"
Set System = CreateObject("EXTRA.System")
If (System is Nothing) Then
Msgbox "Could not create the EXTRA System object."
STOP
End If
Set Session = System.ActiveSession
If (Session is Nothing) Then
Msgbox "Could not create the Sessions collection object."
STOP
End If
g_HostSettleTime = 0250 ' milliseconds
OldSystemTimeout& = System.TimeoutValue
If (g_HostSettleTime > OldSystemTimeout) Then
System.TimeoutValue = g_HostSettleTime
End If
Set Sess0 = System.ActiveSession
If (Sess0 is Nothing) Then
Msgbox "Could not create the Session object."
STOP
End If
If Not Sess0.Visible Then Sess0.Visible = TRUE
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Set Screen = System.ActiveSession.Screen
stConfirm = Sess0.Screen.Area( 3, 32, 3, 58, , xBlock)
'--------------------------------------------------------------------------------
End Sub

Sub AddToMacroLog
'--------------------------------------------------------------------------------
On Error GoTo StopSub

Begin Dialog newdlg 125, 69
TextBox 10, 25, 105, 15, .TextBox1
Text 10, 10, 89, 9, "Please Enter Your User ID:"
OkButton 10, 45, 50, 14
CancelButton 65, 45, 50, 14
End Dialog
Dim dUser as newdlg

iDone = FALSE
While iDone = FALSE
nRet = Dialog(dUser)
Select Case nRet
Case -1
iDone = TRUE
User = dUser.TextBox1
filenum% = FreeFile
FileName$ = "\\10.146.226.21\BSPMacro\MacroLog.txt"
Open Filename$ For Append as Filenum%
Print # Filenum%, MacroName + " ;" + Date + " ;" + User
Close Filenum%
Case 0
STOP
End Select
Wend

StopSub:
'--------------------------------------------------------------------------------
End Sub
 
Those not wanting to read through all the code, I believe the problem is in this section:

*********************************************
' Global Subroutine Declarations
Declare Sub GetSystem
Declare Sub AddToMacroLog

' Global variable declarations
Global g_HostSettleTime%
Global Session As Object
Global System As Object
Global Screen As Object
Global Sess0 As Object
Global MacroName As String

Sub Main()
Dim ListsList(100) as String
GetSystem
' AddToMacroLog

Begin Dialog newdlg 175, 53
TextBox 15, 25, 90, 15, .TextBox1
OkButton 115, 10, 50, 14
CancelButton 115, 25, 50, 14
Text 15, 10, 85, 10, "Enter H1 or L1 account ID"
End Dialog
Dim dMain as newdlg

iDone = FALSE
While iDone = FALSE
nRet = Dialog(dMain)
Select Case nRet
Case -1
iDone = TRUE
AcctID = dMain.TextBox1
Filenum% = Freefile
Filename$ = "c:\" + acctID + "_VACFList.txt"
Open Filename$ for Output as Filenum%
Print # Filenum%, "Account ID ;Account Name ;List ID ;Code ;Status"
Close Filenum%
Sess0.Screen.Row = 21
Sess0.Screen.Col = 8
Sess0.Screen.Sendkeys(AcctID)
Sess0.Screen.Sendkeys("<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
'changing from (6, 56, 6, 57)
acctType = Sess0.Screen.Area(6, 56, 6, 57)
If ((acctType = "VN") or (acctType = "TC") or (acctType = "VC") or (acctType = "L9") or (acctType = "V1")) then
acctType = "L1"
End If
Select Case acctType
Case "H1"
Sess0.Screen.Row = 22
Sess0.Screen.Col = 18
Sess0.Screen.Sendkeys("HIER<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
'here its messing up
h1Count = 0
hiEnd = FALSE
While hiEnd = FALSE
For hiStep = 8 to 19
acType = Sess0.Screen.Area(hiCount, 15, hiCount, 16, , xBlock)
If ((acType = "VN") or (acType = "TC") or (acType = "VC") or (acType = "L9") or (acType = "V1")) then
acType = "L1"
End If
Select Case acType
Case "H1"
h1Count = h1Count + 1
If h1Count > 1 then
hiEnd = TRUE
hiStep = 19
End If
Case " "
hiEnd = TRUE
hiStep = 19
Case "L1"
Sess0.Screen.Row = hiStep
'changed 4 to 3
Sess0.Screen.Col = 4
Sess0.Screen.Sendkeys("M<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
 
I could really use some help on this if anyone can assist. Basically the problem is, it doesnt find the (V1, L1, etc) it just keeps hitting enter

Select Case acctType
Case "H1"
Sess0.Screen.Row = 22
Sess0.Screen.Col = 18
Sess0.Screen.Sendkeys("HIER<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

h1Count = 0
hiEnd = FALSE
While hiEnd = FALSE
For hiStep = 8 to 19
acType = Sess0.Screen.Area(hiCount, 15, hiCount, 16, , xBlock)

'********************************
'Here it should be searching for the acType below
'It seems to not be finding them, it just catches in
'a loop, the actual acType "VC, TC" is in 08,15
'through 19,15

If ((acType = "VN") or (acType = "TC") or (acType = "VC") or (acType = "L9") or (acType = "V1")) then
acType = "L1"

End If

Select Case acType
Case "H1"
h1Found = h1Found + 1
If h1Found > 1 then
hiEnd = TRUE
hiCount = 19
End If
Case " "
hiEnd = TRUE
hi = 19
Case "L1"
'*********************
'Right here it should have found the V1, L1 and
'put an M by it, instead it just keep looping, its not
'finding the V1
'*************************

Sess0.Screen.Row = hiCount

Sess0.Screen.Col = 3
Sess0.Screen.Sendkeys("M<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
 
South I think you need to do a little good old fashion debugging to find out what it is that the acType is being populated with. use the watch varible feature of the macro editor and step through you code to the point where that varible is being read.
 
Here is the fix for the problem:
----------------------------------


The following changes (*** marks lines with changes)

*** h1Found = 0
hiEnd = FALSE
While hiEnd = FALSE
*** For hiCount = 8 to 19
acType = Sess0.Screen.Area(hiCount, 15, hiCount, 16, , xBlock)
If ((acType = "VN") or (acType = "TC") or (acType = "VC") or (acType = "L9") or (acType = "V1")) then
acType = "L1"
End If
Select Case acType
Case "H1"
h1Found = h1Found + 1
If h1Found > 1 then
hiEnd = TRUE
hiCount = 19
End If
Case " "
hiEnd = TRUE
*** hiCount = 19
Case "L1"
'change hiCount
Sess0.Screen.Row = hiCount
Sess0.Screen.Col = 3
Sess0.Screen.Sendkeys("M<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top