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!

steping through code problems

Status
Not open for further replies.

smiler44

Technical User
Sep 18, 2009
83
GB
i want to step through my code.
I have one sub routine calling another sub routine. i can step through the first sub routine one line at a time.
when the first sub calls the second sub, the second sub just seems to go off and run where as i want to step through it. I also dont understand why in the second sub, "max" i need the first 16 lines of code but if i dont it seems to get stuck in a loop and keeps sending an S.

how can I step through my second sub?
Why do I need so much code in the second sub, is there a better way, what is it?
thank you smiler44



' Global variable declarations
Global g_HostSettleTime%
Global g_szPassword$
declare sub max()

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)
max
end sub


sub max()

'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

' Get the necessary Session Object
Dim Sess0 As Object
Set Sess0 = System.ActiveSession

Sess0.Screen.Sendkeys("s")
End Sub

 
Hey

Don't why you can't step through your second sub, but if you put your 'Dim' statements outside the sub, the variables will become public for all Subs and Functions to use, so you won't need to define and assign the values a second time.

The assignments need to be inside a Function or Sub, but 'Dim' can be outside.

Lakare
 
Hmmm?

all that max does is set attachmate system/session objects.

If you declared these as global, then the only statement in max would need to be...
Code:
Sub max()
    Sess0.Screen.SendKeys ("s")
End Sub


Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Global.... right I'll try that, thank you SkipVought

smiler44
 
Lakare, thank you is Set System = CreateObject("EXTRA.System") ' Gets the system object the assingment?

smiler44
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top