I've been charged with writing some macros for Extra! Attachmate at work. Attachmate's macros use Extra Basic, which I am told is very similar to Visual Basic. I am a total noobie at both. I've managed to get most of what I want down, but am running in to a problem in one area. First, here is my code.
The problem I am having is with the radio option buttons (in bold). I can't figure out how to define what they mean. I want something like
If OptionGroup1.AR Then "AR"
If OptionGroup1.AP Then "AP"
If OptionGroup2.Remailed Then "Remailed"
If OptionGroup2.Unable Then "Unable to remail"
The desired effect being the line--
Sess0.Screen.Sendkeys mydialog1.OptionGroup1
--would send "AR" or "AP" and the line--
Sess0.Screen.Sendkeys mydialog1.OptionGroup2
--would send "Remailed" or "Unable to remail", depending on what the user selected for each option. Right now those two lines will only enter 0 or 1, I assume because I haven't defined what they should mean.
Code:
' Global variable declarations
Global g_HostSettleTime%
Global g_szPassword$
Sub Main()
'--------------------------------------------------------------------------------
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
'--------------------------------------------------------------------------------
g_HostSettleTime = 500 ' milliseconds
g_HostSettleTime2 = 100 ' milliseconds
OldSystemTimeout& = System.TimeoutValue
If (g_HostSettleTime > OldSystemTimeout) Then
System.TimeoutValue = g_HostSettleTime
End If
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)
Begin Dialog userdialog1 291, 148
[b]OptionGroup .OptionGroup1
OptionButton 5, 5, 29, 10, "AR", .AR
OptionButton 5, 15, 25, 15, "AP", .AP[/b]
Text 50, 5, 65, 10, "Enter the form name."
TextBox 50, 15, 150, 10, .FormName
Text 50, 30, 90, 10, "Enter the date on form."
TextBox 50, 40, 55, 10, .Date
Text 50, 55, 175, 10, "Enter the USPO reason the form was returned."
Text 50, 65, 145, 10, "(For example: Not deliverable as addressed.)"
TextBox 50, 75, 210, 10, .Return
[b]OptionGroup .OptionGroup2
OptionButton 10, 90, 50, 10, "Remailed.", .Remailed
OptionButton 10, 100, 70, 10, "Unable to remail.", .Unable[/b]
Text 50, 115, 60, 10, "Enter your initials."
TextBox 50, 125, 75, 10, .Initials
OkButton 216, 9, 50, 14
CancelButton 216, 26, 50, 14
End Dialog
dim mydialog1 as userdialog1
dialog mydialog1
Sess0.Screen.Sendkeys("narr<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("<Tab><Tab><Pf6>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("ge001")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime2)
Sess0.Screen.Sendkeys("ot")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime2)
Sess0.Screen.Sendkeys("wc<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("rcvd returned ")
[b]Sess0.Screen.Sendkeys mydialog1.OptionGroup1[/b]
Sess0.Screen.Sendkeys(" ")
Sess0.Screen.Sendkeys mydialog1.FormName
Sess0.Screen.Sendkeys(", dated ")
Sess0.Screen.Sendkeys mydialog1.Date
Sess0.Screen.Sendkeys(", due to: ")
Sess0.Screen.Sendkeys mydialog1.Return
Sess0.Screen.Sendkeys(" , ")
[b]Sess0.Screen.Sendkeys mydialog1.OptionGroup2[/b]
Sess0.Screen.Sendkeys(" ")
Sess0.Screen.Sendkeys mydialog1.Initials
System.TimeoutValue = OldSystemTimeout
End Sub
The problem I am having is with the radio option buttons (in bold). I can't figure out how to define what they mean. I want something like
If OptionGroup1.AR Then "AR"
If OptionGroup1.AP Then "AP"
If OptionGroup2.Remailed Then "Remailed"
If OptionGroup2.Unable Then "Unable to remail"
The desired effect being the line--
Sess0.Screen.Sendkeys mydialog1.OptionGroup1
--would send "AR" or "AP" and the line--
Sess0.Screen.Sendkeys mydialog1.OptionGroup2
--would send "Remailed" or "Unable to remail", depending on what the user selected for each option. Right now those two lines will only enter 0 or 1, I assume because I haven't defined what they should mean.