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!

Radio Buttons in Extra! Attachmate Macros 1

Status
Not open for further replies.

OhDavey

Technical User
Jan 27, 2006
5
0
0
US
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.

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.
 
Radio buttons are Boolean, 1 being true 0 being false.

how about something like this
Code:
If OptionGroup1.AR Then result = "AR"
If OptionGroup1.AP Then result = "AP"
If OptionGroup2.Remailed Then result = result+" Remailed"
If OptionGroup2.Unable Then result = result+" Unable to remail"
 
Bad me. What a lousy answer I gave you. I didn't even read your code.

The 0 and 1 your getting are the first item in your option group is 0 and the second item is 1 and so on if you had more.

try this
Code:
' Global variable declarations
Global g_HostSettleTime%
Global g_szPassword$

Sub Main()
'--------------------------------------------------------------------------------

    Dim Sessions As Object
    Dim System As Object
    Set System = CreateObject("ACCMGR.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
   OptionGroup .OptionGroup1
      OptionButton  5, 5, 29, 10, "AR", .AR
      OptionButton  5, 15, 25, 15, "AP", .AP
   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
   OptionGroup .OptionGroup2
      OptionButton  10, 90, 50, 10, "Remailed.", .Remailed
      OptionButton  10, 100, 70, 10, "Unable to remail.", .Unable
   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 ")
        If mydialog1.OptionGroup1 = 0 then 
            Sess0.Screen.Sendkeys("AR")         
        Else 
            Sess0.Screen.Sendkeys("AP")
        End if
        Sess0.Screen.Sendkeys mydialog1.OptionGroup1
        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(" , ")
        If mydialog1.OptionGroup2 = 0 then
            Sess0.Screen.Sendkeys("Remailed")         
        Else 
            Sess0.Screen.Sendkeys("Unable to remail")
        End if
        Sess0.Screen.Sendkeys("     ")
        Sess0.Screen.Sendkeys mydialog1.Initials
            

    System.TimeoutValue = OldSystemTimeout
End Sub

I would recomend changing from sendkeys to putstring, it's more reliable.

Sess0.Screen.PutString "text to put",row,column
it would also clear up all the lines.

Sess0.Screen.Sendkeys(" ")

again sorry about the lousy response
 
Excellent. Thank you mgwils!

I'll look in to using the "putstring" command. I am (clearly) very new to this, so I've mostly just stuck with what's worked, regardless of how messy it looks.
 
You'll also want to check out the FileDlgFunction in your EB help files. It could really help you get the most out of your Dialog Box's. It includes a lot of features to handle actions and events as they occur in your DB.

Skie's posted some examples of it in this Forum, it's worth a search.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top