INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

goto next loop

goto next loop

(OP)
Hi guys,

I`m copying fields from excel to attachmate, I need to go to next loop if the value already exists in attachmate.

CODE -->

Dim Row As Long
        With xlApp.ActiveSheet
           Set MyRange = .Range("A1:A65536").Resize(xlApp.CountA(.Range("A1:A65536")))
           Set MyRange2 = .Range("B1:B65530").Resize(xlApp.CountA(.Range("B1:B65530")))
        End With
        For Row = 1 To MyRange.Rows.Count
           Sess0.Screen.PutString MyRange.Rows(Row).Value, 7, 4     * insert first string from column A in excel
           Sess0.Screen.WaitHostQuiet 30
           Sess0.Screen.SendKeys "<ENTER>"
           If Sess0.Screen.GetString(20,2,8) = "SVIP210E" Then     * here if the string already exist i need to go to the next row in loop
                
                
           End If     
           Sess0.Screen.WaitHostQuiet 30
           Sess0.Screen.PutString MyRange2.Rows(Row).Value, 8, 33    * enter another string from column B in excel
           Sess0.Screen.SendKeys "<ENTER>"
           Sess0.Screen.WaitHostQuiet 30
           Sess0.Screen.SendKeys("<PF3>")
           Sess0.Screen.WaitHostQuiet 30
           
        Next Row




End Sub 

RE: goto next loop

hi,

Welcome to Tek-Tips y'all!

CODE

'
    Dim Row As Long
    
    With xlApp.ActiveSheet
       Set MyRange = .Range("A1:A65536").Resize(xlApp.CountA(.Range("A1:A65536")))
       Set MyRange2 = .Range("B1:B65530").Resize(xlApp.CountA(.Range("B1:B65530")))
    End With
    
    For Row = 1 To MyRange.Rows.Count
       Sess0.Screen.PutString MyRange.Rows(Row).Value, 7, 4     ' insert first string from column A in excel
       Sess0.Screen.WaitHostQuiet 30
       Sess0.Screen.SendKeys "<ENTER>"
       If Sess0.Screen.GetString(20, 2, 8) <> "SVIP210E" Then   ' here if the string already exist i need to go to the next row in loop
            Sess0.Screen.WaitHostQuiet 30
            Sess0.Screen.PutString MyRange2.Rows(Row).Value, 8, 33    ' enter another string from column B in excel
            Sess0.Screen.SendKeys "<ENTER>"
            Sess0.Screen.WaitHostQuiet 30
            Sess0.Screen.SendKeys ("<PF3>")
            Sess0.Screen.WaitHostQuiet 30
       End If
       
    Next Row 

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: goto next loop

(OP)
Hi,

Thank you :)

I`m now experiencing strange behavior. When i run this step-by-step, it`s working how it should, but when I let it run it seems that the IF line is skipped and is processing lines that are inside if.

Any ideas how to resolve this?

RE: goto next loop

You are interfacing with an asynchronous system. Off goes a command, like...

CODE

Sess0.Screen.SendKeys "<ENTER>" 
...and there is no guarantee when your mainframe will respond, but your code keeps plowing on. So you must WAIT until you get a response.

Some developers like to use...

CODE

Sess0.Screen.SendKeys "<ENTER>"
Do While Sess0.Screen.OIA.XSataus <> 0
   DoEvents
Loop 

I've also used Sess0.Screen.WaitForCursor(r,c) at the screen rest coordinates (r,c)

Check these out in your Extra VB HELP.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: goto next loop

(OP)
Hi,

with your help i managed to get it work almost perfect.
There is however this strange thing: i`m adding IPs, if one already exist, skip it, otherwise add mask. While it skips IPs that are already there, it sometmies (cca every 6th skip ) ad 2 random number after 3rd octet. so instead of checking 10.10.10.1 its checking 10.10.10.06.1
When I delete all record, its working fine and is adding IPs as they are in excel. Any Idea?

Thanks

CODE -->

For Row = 1 To MyRange.Rows.Count
        
          
		
                Sess0.Screen.PutString MyRange.Rows(Row).Value, 7, 4
                Sess0.Screen.WaitHostQuiet 300
                Do While Sess0.Screen.OIA.XStatus <> 0
                 DoEvents
                  Loop
                Sess0.Screen.SendKeys (sendCommand & "<Enter>")
                Sess0.Screen.WaitHostQuiet 300
                Do While Sess0.Screen.OIA.XStatus <> 0
                 DoEvents
                  Loop
                

if Sess0.screen.getstring(20,2,8) <> "SVIP210E" then
if Sess0.screen.getstring(20,2,8) <> "SVIP808E"  then
   
   Sess0.Screen.PutString MyRange2.Rows(Row).Value, 8, 33
   Sess0.Screen.SendKeys (sendCommand & "<Enter>")
   Sess0.Screen.WaitHostQuiet 300
   Do While Sess0.Screen.OIA.XStatus <> 0
                 DoEvents
                  Loop
   Sess0.Screen.SendKeys("<PF3>")
   Sess0.Screen.WaitHostQuiet 300
   Do While Sess0.Screen.OIA.XStatus <> 0
                 DoEvents
                  Loop
end if    
end if           
    
Next Row
End Sub 

RE: goto next loop

The .06 is not popping up from NOTHING!

Your code, I assume, is adding it from SOMETHING!

How do these values come into being?

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: goto next loop

(OP)
That what i`m trying to find out :D

When I change the value in excel, it will change that extra digits also.

72.5.190.1 in excel - 72.5.190.06.1 in attachmate
72.5.190.100 in excel - 72.5.190.1000 in attachmate
72.5.190.5 in excel - 72.5.190.56.0 in attachmate

After I have deleted this line from exel(line 6) now it is changing 165.225.96.0 to 165.225.36.0092 (line 18)
it is also inputing 92 after many IPs ending with 0 wich is not invalid and then adding this ip into system which is not good.
I have checked excel, it seems that formatting is OK in there.

CODE -->

' Global variable declarations
Global g_HostSettleTime%
Global g_szPassword$
 
Sub Main()
'--------------------------------------------------------------------------------
' Get the main system object
    Dim Sessions As Object
    Dim System As Object
    Dim Host 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)
    
'--------------------------------------------------------------------------------
'Declare the Excel Object
        Dim xlApp As Object, xlSheet As Object, MyRange As Object, MyRange2 As Object
        Set xlApp = CreateObject("excel.application")
        xlApp.Application.DisplayAlerts = True
        xlApp.Visible = True
        xlApp.Workbooks.Open FileName:="C:\macros\att\Fetch.xls"
        Set xlSheet = xlApp.activesheet
        Set MyRange = xlApp.activesheet.Range("A:A")
        Set MyRange2 = xlApp.activesheet.Range("B:B")
 
Dim Row As Long
        With xlApp.ActiveSheet
           Set MyRange = .Range("A1:A65536").Resize(xlApp.CountA(.Range("A1:A65536")))
           Set MyRange2 = .Range("B1:B65530").Resize(xlApp.CountA(.Range("B1:B65530")))
        End With
        For Row = 1 To MyRange.Rows.Count
        
          

		
                Sess0.Screen.PutString MyRange.Rows(Row).Value, 7, 4
                Sess0.Screen.WaitHostQuiet 10
                Do While Sess0.Screen.OIA.XStatus <> 0
                 DoEvents
                  Loop
                Sess0.Screen.SendKeys (sendCommand & "<Enter>")
                Sess0.Screen.WaitHostQuiet 10
                Do While Sess0.Screen.OIA.XStatus <> 0
                 DoEvents
                  Loop
                

if Sess0.screen.getstring(20,2,8) <> "SVIP210E" then
if Sess0.screen.getstring(20,2,8) <> "SVIP808E"  then
   
   Sess0.Screen.PutString MyRange2.Rows(Row).Value, 8, 33
   Sess0.Screen.SendKeys (sendCommand & "<Enter>")
   Sess0.Screen.WaitHostQuiet 10
   Do While Sess0.Screen.OIA.XStatus <> 0
                 DoEvents
                  Loop
   Sess0.Screen.SendKeys("<PF3>")
   Sess0.Screen.WaitHostQuiet 10
   Do While Sess0.Screen.OIA.XStatus <> 0
                 DoEvents
                  Loop
end if    
end if           
    
Next Row
End Sub 

RE: goto next loop

(OP)
ok,

I have found the issue, i was not deleting previous record and if new one was shorter the last one, it added the last digits.

Thanks for help :)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close