Hi, I'm trying to get the hang of "if...then...else" statements in an EXTRA! AS400 emulator macros. The simple code below is supposed to find the command line and type "FOUND IT"; but if it can't find the command line then it'll go to the given coordinates and type "NO GO":
When the IF condition is FALSE and goes to the ELSE statement, the macro works just fine.
The problem is: When the IF condition is TRUE, an error message pops up in the macro saying:
"Type Mismatch -- Line Number 12 -- Stopping Macro Playback" (The red line is the culprit), then pauses the macro. If I hit GO to continue, then the macro will pick up where it left off and finish normally.
I'm trying to figure out what the error is on that line that stops the macro.
Thanks a million,
Mark
Code:
Sub Main()
Dim Sys As Object, Sess As Object, MyScreen As Object, MyArea As Object
Set Sys = CreateObject("EXTRA.System")
' Assumes an open session
Set Sess = Sys.ActiveSession
Set MyScreen = Sess.Screen
MyScreen.MoveTo 1, 1
Set MyArea = MyScreen.Search("==>")
[COLOR=red]If MyArea Then[/color]
MyScreen.MoveTo MyArea.Bottom, MyArea.Right + 2 'found the command line
Sess.Screen.Sendkeys "FOUND IT"
Else
MyScreen.MoveTo 6, 53 'could not find the commmand line
Sess.Screen.Sendkeys "NO GO"
End If
End Sub
When the IF condition is FALSE and goes to the ELSE statement, the macro works just fine.
The problem is: When the IF condition is TRUE, an error message pops up in the macro saying:
"Type Mismatch -- Line Number 12 -- Stopping Macro Playback" (The red line is the culprit), then pauses the macro. If I hit GO to continue, then the macro will pick up where it left off and finish normally.
I'm trying to figure out what the error is on that line that stops the macro.
Thanks a million,
Mark