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!

Extensive Macro Example 2

Status
Not open for further replies.

pseudoman

Programmer
Jan 8, 2004
16
US
Hello guys, I have been given alot of help in this forum so I figured it would make sense to give alittle back, as my company is dumping attachmate all together and building their own database app... It'd be a shame to let the code go to waste. So here it is you can all take a look and maybe better your own macro, or get some ideas or if your new see the code in action... understand I had to make this on coffee breaks so the code isn't the best but you should get the idea... Thx again to calculus was a big help in learning the stuff...he is a true guru ask him if you need help.

Code:
Global g_HostSettleTime%
Global g_szPassword$

Sub Main()

        Dim Sessions As Object
	Dim System As Object
	Set System = CreateObject("EXTRA.System")	
	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 = 100		
	System.TimeoutValue = g_HostSettleTime



	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)
 
        
        'Original Code and Concept Created By JC 02/07/05.
'___________________________________________________________________________________________


Sess0.KeyboardLocked = True       

     

        Dim Pagename As Integer

            Pagename = Sess0.Screen.WaitForString ("CMSD1180",1,2)
            
            Do While Sess0.Screen.OIA.Xstatus <> 0
	       DoEvents
            Loop  
            
        If Pagename Then 
        
            Do While Sess0.Screen.OIA.Xstatus <> 0
	       DoEvents
            Loop        
            
        Else
         
            MsgBox "There was a error navigating to the Page."
            Sess0.KeyboardLocked = False 
            Exit Sub
            
        End If
        
        Sess0.Screen.Sendkeys("<Pf10>")
            Do While Sess0.Screen.OIA.Xstatus <> 0
	       DoEvents
            Loop  
                    
        Dim ErrorMsg As String
        
        ErrorMsg = Sess0.Screen.GetString (23,1,60)
           Do While Sess0.Screen.OIA.Xstatus <> 0
	       DoEvents
           Loop  
        
        If Left(ErrorMsg,8) = "DC912926" Then
            
                    Msgbox "Please check if you entered P for Payment."
                    Sess0.KeyboardLocked = False
                    Exit Sub
        End If
        
            Select Case Trim(ErrorMsg)
              Case "DC912879 CLAIM LEVEL CVQ, PAYMENT INVALID"
            
                    Msgbox "Please Call or Email as this Feat has a CVQ."
                    Sess0.Screen.Sendkeys("<Pf3><Pf14>")
                        Do While Sess0.Screen.OIA.Xstatus <> 0
	                   DoEvents
                        Loop  
                    Sess0.KeyboardLocked = False
                    Exit Sub

              Case "DC912879 FEATURE LEVEL CVQ, PAYMENT INVALID"
            
                    Msgbox "Please Call or Email the as this Feat has a CVQ."
                    Sess0.Screen.Sendkeys("<Pf3><Pf14>")
                        Do While Sess0.Screen.OIA.Xstatus <> 0
	                   DoEvents
                        Loop  
                    Sess0.KeyboardLocked = False
                    Exit Sub
                    
              Case "DC912701 LAST PAGE"
            
                    Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
                    
              Case "DC912665 FIRST PAGE"
            
                    Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
                    
              Case "DC912747 ONLY PAGE"
            
                    Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
                    
              Case "DC912878 SELECTION REQUIRED"
            
                    Msgbox "Please make a selection for the bill."
                    Sess0.KeyboardLocked = False
                    Exit Sub                    
                    
              Case "DC912980 ONLY ONE SELECTION ALLOWED"
            
                    Msgbox "Please make sure there is only 1 selection for this bill."
                    Sess0.KeyboardLocked = False
                    Exit Sub   
                    
              Case "DC912879 FEATURE NOT OPEN, PAYMENT INVALID"
            
                    Msgbox "This Feature is not open, please open it and try again."
                    Sess0.Screen.Sendkeys("<Pf3><Pf3><Pf5><Pf15>")
                        Do While Sess0.Screen.OIA.Xstatus <> 0
	                   DoEvents
                        Loop  
                    Sess0.KeyboardLocked = False
                    Exit Sub 
                    
                 
              Case "DC912879 SELECTION AND FUNCTION ARE INVALID"
            
                    Msgbox "Please make sure you selected the right bill."
                    Sess0.KeyboardLocked = False
                    Exit Sub 
                    
                    
                 
              Case "DC912879 PAYMENT AMOUNT IS ZERO, SELECTION INVALID"
            
                    Msgbox "Please make sure the payment amount is not zero."
                    Sess0.KeyboardLocked = False
                    Exit Sub
                    
                    
              Case "DC912878 PAYMENT SELECTION IS REQUIRED"
            
                    Msgbox "Please make sure selected a payment."
                    Sess0.KeyboardLocked = False
                    Exit Sub
                    
              Case "DC912879 BILL ALREADY PAID, SELECTION INVALID"

                    Msgbox "This Bill has already been paid."
                    Sess0.KeyboardLocked = False
                    Exit Sub              
                     
            End Select            

        Pagename = Sess0.Screen.WaitForString ("CMSD2030",1,2)
            
            
        If Pagename Then 
        
            Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
            
        Else
         
            MsgBox "There was a error navigating to the Page."
            Sess0.KeyboardLocked = False
            Exit Sub
            
        End If
        
        Dim Status As String
        Dim Atty As String
        Dim Subro As String
        Dim ContactError As String
        Dim SubroError As String
        Dim Claimant As String
        Dim MPTEST As String
        
        MPTEST = Sess0.Screen.GetString (6,19,10)
                        Do While Sess0.Screen.OIA.Xstatus <> 0
	                   DoEvents
                        Loop               
        Status = Sess0.Screen.GetString (4,52,6)
                        Do While Sess0.Screen.OIA.Xstatus <> 0
	                   DoEvents
                        Loop 
        Atty = Sess0.Screen.GetString (20,75,1)
                        Do While Sess0.Screen.OIA.Xstatus <> 0
	                   DoEvents
                        Loop 
        Subro = Sess0.Screen.GetString (21,19,1)
                        Do While Sess0.Screen.OIA.Xstatus <> 0
	                   DoEvents
                        Loop 
        Claimant = Sess0.Screen.GetString (05,19,26)
                        Do While Sess0.Screen.OIA.Xstatus <> 0
	                   DoEvents
                        Loop 
    
        If Trim(status) = "OPEN" OR Trim(status) = "CLSD" Then
        
        Sess0.Screen.MoveTo 16,19
                        Do While Sess0.Screen.OIA.Xstatus <> 0
	                   DoEvents
                        Loop 
        Sess0.Screen.Sendkeys("P")
                        Do While Sess0.Screen.OIA.Xstatus <> 0
	                   DoEvents
                        Loop 
        Sess0.Screen.MoveTo 20,75
                        Do While Sess0.Screen.OIA.Xstatus <> 0
	                   DoEvents
                        Loop 
       
        ElseIf (status = "INACTV" OR status = "ACTIVE") Then
        
                Sess0.Screen.MoveTo 16,19
                        Do While Sess0.Screen.OIA.Xstatus <> 0
	                   DoEvents
                        Loop 
                Sess0.Screen.Sendkeys("S")
                        Do While Sess0.Screen.OIA.Xstatus <> 0
	                   DoEvents
                        Loop 
                Sess0.Screen.MoveTo 20,75
                        Do While Sess0.Screen.OIA.Xstatus <> 0
	                   DoEvents
                        Loop 
        End If
        
        If (atty = "Y" OR atty = "N") Then
        
        Sess0.Screen.MoveTo 21,19
                        Do While Sess0.Screen.OIA.Xstatus <> 0
	                   DoEvents
                        Loop 

            ElseIf (atty = " ") Then
            
            Sess0.Screen.Sendkeys("N")
                        Do While Sess0.Screen.OIA.Xstatus <> 0
	                   DoEvents
                        Loop 
            Sess0.Screen.MoveTo 21,19
                        Do While Sess0.Screen.OIA.Xstatus <> 0
	                   DoEvents
                        Loop 
        
        End If    
            
               
        If (Subro = "Y" OR Subro = "N") Then
        
        Sess0.Screen.Sendkeys("<ENTER>")
                        Do While Sess0.Screen.OIA.Xstatus <> 0
	                   DoEvents
                        Loop 
            
            ElseIf (Subro = " ") Then
            
            Sess0.Screen.Sendkeys("N")
                        Do While Sess0.Screen.OIA.Xstatus <> 0
	                   DoEvents
                        Loop 
            Sess0.Screen.Sendkeys("<ENTER>")
                        Do While Sess0.Screen.OIA.Xstatus <> 0
	                   DoEvents
                        Loop 
        
        End If
        
        ContactError = Sess0.Screen.GetString (23,1,9)
                        Do While Sess0.Screen.OIA.Xstatus <> 0
	                   DoEvents
                        Loop 
            
        If Trim(ContactError) = "DC912605" Then
            
            Msgbox "Please Email/Call as this feature has no contact date set."
            Sess0.KeyboardLocked = False
            Exit Sub            
        End If   
        
        SubroError = Sess0.Screen.GetString (23,1,35)
                        Do While Sess0.Screen.OIA.Xstatus <> 0
	                   DoEvents
                        Loop 
            
        If Trim(SubroError) = "DC912767 PAYMENT TYPE INVALID" Then
            
            Sess0.Screen.MoveTo 16,19
                        Do While Sess0.Screen.OIA.Xstatus <> 0
	                   DoEvents
                        Loop 
            Sess0.Screen.Sendkeys("S<ENTER>")
                        Do While Sess0.Screen.OIA.Xstatus <> 0
	                   DoEvents
                        Loop 
        End If 
             
        Pagename = Sess0.Screen.WaitForString ("CMSD2040",1,2)
            
            
        If Pagename Then 
        
            Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
            
        Else
         
            MsgBox "There was a error navigating to the Page."
            Sess0.KeyboardLocked = False
            Exit Sub
        End If

Dialog1:

   Dim Acct As String
   Dim DOS As String
   Dim TIN As String
   Dim FormattedDate As String
   
   On Error Resume Next

Begin Dialog UserDialog 223, 128, "Draft Automation Application" 

  Picture  30, 0, 164, 50, "***********\Dialog Logo.bmp", 0 

  Text  12, 69, 90, 9, "Account #:" 

  Text  12, 43, 90, 9, "Dates of Service:" 

  Text  12, 97, 90, 9, "Tin #:" 

  TextBox  12, 55, 90, 12, .TextBox1 

  TextBox  12, 81, 90, 12, .TextBox2 

  TextBox  12, 109, 90, 12, .TextBox3
  
  OkButton  113, 92, 50, 14 

  CancelButton  165, 92, 50, 14  

End Dialog

   Dim mydialogbox As UserDialog
   
   Dialog mydialogbox

   If Err=102 then
      
      Sess0.KeyboardLocked = False   
      Exit Sub
      
   Else
      Do While Sess0.Screen.OIA.Xstatus <> 0
	   DoEvents
      Loop 
      
      DOS = mydialogbox.TextBox1
      Acct = mydialogbox.TextBox2
      TIN = mydialogbox.TextBox3
        
   End If

       If Len(DOS) = 6 Then
       
            FormattedDate = Format(DOS, "&&/&&/&&")
       
       ElseIf Len(DOS) = 13 Then
       
            FormattedDate = Format(DOS, "&&/&&/&&@&&/&&/&&")
            
       Else
       
            MsgBox "The correct date format is XXXXXX, OR XXXXXX-XXXXXX"
            Goto Dialog1
      
       End If

       If Acct = "" Then 
       
         Acct = Trim(Claimant)
         
       End If
       
       
       If TIN ="" OR Len(TIN) > 9 OR Len(TIN) < 9 Then 
       
          MsgBox "The Tax ID Number must have no more, or less then 9 digits, with no dashes. Or use 111111111 for EIPPAY/PATIENT REIM."
          Goto Dialog1
          
       ElseIf TIN = "111111111" Then 
       
          TIN = "EIPPAY"
          
       End If
       
       If TIN <> "EIPPAY" Then 
       
            Sess0.Screen.MoveTo 8,12
            Sess0.Screen.Sendkeys("<EraseEOF>")
            Sess0.Screen.MoveTo 9,12
            Sess0.Screen.Sendkeys("<EraseEOF>")
            Sess0.Screen.MoveTo 10,12
            Sess0.Screen.Sendkeys("<EraseEOF>")
            Sess0.Screen.MoveTo 12,12
            Sess0.Screen.Sendkeys("<EraseEOF>")
            Sess0.Screen.MoveTo 13,12
            Sess0.Screen.Sendkeys("<EraseEOF>")
            Sess0.Screen.MoveTo 14,8
            Sess0.Screen.Sendkeys("<EraseEOF>")
            Sess0.Screen.MoveTo 14,59
            Sess0.Screen.Sendkeys("<EraseEOF>")
            Sess0.Screen.MoveTo 21,13
            Sess0.Screen.Sendkeys("AS2")
            Sess0.Screen.MoveTo 18,13
            Sess0.Screen.Sendkeys("Y") 
            Sess0.Screen.MoveTo 18,42
            Sess0.Screen.PutString TIN
            Do While Sess0.Screen.OIA.Xstatus <> 0
	           DoEvents
            Loop 
            Sess0.Screen.MoveTo 16,17

      ElseIf TIN = "EIPPAY" Then
      
            Sess0.Screen.MoveTo 21,13
            Sess0.Screen.Sendkeys("AS2")
            Sess0.Screen.MoveTo 18,13
            Sess0.Screen.Sendkeys("N")
            Sess0.Screen.MoveTo 16,17
            
      End If
      
      Sess0.Screen.Sendkeys("NO FAULT ")
      If Trim(MPTEST) = "MEDPAY" Then
             If Len(Acct) > 15 AND Len(DOS) = 13 Then 
             Sess0.Screen.MoveTo 16,17
             Sess0.Screen.Sendkeys("NF ")
             End If
             Sess0.Screen.PutString MPTEST
             Do While Sess0.Screen.OIA.Xstatus <> 0
	          DoEvents
             Loop 
             Sess0.Screen.Sendkeys("<EndOfField> ")              
      ElseIf Trim(MPTEST) = "PIP" OR Trim(MPTEST) = "OPT-BEL" OR _
                Trim(MPTEST) = "ADDL PIP" Then
             If Len(Acct) > 20 AND Len(DOS) = 13 Then 
             Sess0.Screen.MoveTo 16,17
             Sess0.Screen.Sendkeys("NF ")
             End If               
      End If
      
      If Len(Acct) > 16 AND MPTEST <> "MEDPAY" AND Len(DOS) = 13 Then
             Sess0.Screen.Sendkeys("SVCS: ")
      ElseIf Len(Acct) > 10 AND MPTEST = "MEDPAY" AND Len(DOS) = 13 Then
             Sess0.Screen.Sendkeys("SVCS: ")
      Else
             Sess0.Screen.Sendkeys("SERVICES: ")
      End If
      
      
      
      
            Do While Sess0.Screen.OIA.Xstatus <> 0
	           DoEvents
            Loop       

      Sess0.Screen.PutString FormattedDate
             Do While Sess0.Screen.OIA.Xstatus <> 0
	          DoEvents
             Loop
      Sess0.Screen.Sendkeys("<EndOfField>")      
      Sess0.Screen.Sendkeys(" ")       
 
      If Acct = Trim(Claimant) Then
      Sess0.Screen.Sendkeys("FOR: ")
      Sess0.Screen.PutString Acct
             Do While Sess0.Screen.OIA.Xstatus <> 0
	          DoEvents
             Loop
      ElseIf Acct <> Trim(Claimant) Then

      Sess0.Screen.Sendkeys("ACCT: ")
      Sess0.Screen.PutString Acct
             Do While Sess0.Screen.OIA.Xstatus <> 0
	          DoEvents
             Loop
      End If
      Sess0.Screen.MoveTo 8,12
             Do While Sess0.Screen.OIA.Xstatus <> 0
	          DoEvents
             Loop
       
       If TIN <> "EIPPAY" Then  
            Sess0.Screen.Sendkeys("<ENTER>")
             Do While Sess0.Screen.OIA.Xstatus <> 0
	          DoEvents
             Loop
            Dim TinError As String
   
            TinError = Sess0.Screen.GetString (23,1,28)
            Do While Sess0.Screen.OIA.Xstatus <> 0
	       DoEvents
            Loop  
    
            If Trim(TinError) = "DC912865 VENDOR NOT FOUND" Then
            
                    Msgbox "Please add the Tax ID number to the system."
                    Sess0.KeyboardLocked = False
                    Exit Sub 
            End If

       End If

      Sess0.KeyboardLocked = False   
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top