Hi 
I have a script that reads from a list of employees and writes their
allowance amounts to the employee's timecard. I need to evaluate two things:


1. If the script gets an "Employee Terminated" warning and 
2. If the employee doesn't have a timecard (no Ctrl Hours posted)

I have written an If/Else statement that firsts looks for the warning:  If
At ("[EMAIL PROTECTED],1) Then..... do some stuff and go on to the next employee.
If there is no warning it next looks for a blank Ctrl Hour field:  ElseIf
Trim(View(2, 1, 3)) = "" Then.... do some different stuff and go on to the
next employee.
Finally, if everything is okay it writes the allowance value to the
timecard:    Else Tab_ ""  ... and do more stuff and go onto the next
employee.

The script is very inconsistent when it runs. Sometimes it goes to the
correct If statement and sometimes it doesn't. In my test population I had
one employee with no timecard and it put allowances on the card. Another had
hours and it evaluated it as no timecard. The one that it stumbles over the
most is when an employee has been termed it goes to the Else statement and
trys to put allowances on the card. 

When I originally wrote this script I didn't have the "Termed" condition in
it, and I still had a lot of problems getting the script to evaluate the
Ctrl Hour field for consecutive employees. I added a Key "@_CLEAR" before
the Do Until loop and that seemed to fix it. I've tried added another one
just before the script enters the employee's ID. It's still inconsistent.
I've only been able to get the script to run correctly through my entire
test population of 12 employees once. 

Attached are the script, the source file, and the exception file from a
successful run. Any suggestions are welcome. 
Okay, I'm really just looking to do the least amount of QA at the end of the
script as I have to!

Thanks

Michelle Barker

617-665-3432
Clinical Application Analyst
CHA Information Technology
[EMAIL PROTECTED]


 <<TimecardScript.txt>>  <<EmployeeList.prn>>  <<ExceptionTCH.txt>> 
Dim strFile, strRec, strEmpNumb, strEmpName, strAmt As String
Dim F As Integer
Dim fso, txtfile

Sub TimecardScript()
    ChDir "C:\Program Files\Meditech\MagicCS\Client\"

    F = FreeFile
    strFile = "EmployeeList.prn" 'read from this file
    Open strFile For Input As F

    Set fso = CreateObject("Scripting.FileSystemObject")
    Set txtfile = fso.CreateTextFile("C:\ExceptionTCH.txt", True) ' edit this file 
name for each payroll & date
        
    Connect "C:\Program Files\Meditech\MagicCS\Client\Vmagic.exe", stMeditechCS
    Wait 2
    Enter "ZBOSTON"
    Pause "@21,34"
    Enter "*******"
    Pause "@22,34"
    Wait 1
    Enter "CAM.TEST53"
    Pause "HIS - All Applications [EMAIL PROTECTED],1"
    Key "{DOWN}"
    Key "{DOWN}"
    Key "{DOWN}"
    Key "{DOWN}"
    Key "{RIGHT}"
    Key "{RIGHT}"
    Enter ""
    Pause "MEDITECH Payroll/Personnel Main [EMAIL PROTECTED],1"
    Key "{DOWN}"
    Key "{DOWN}"
    Key "{RIGHT}"
    Enter ""
    Key "{DOWN}"
    Key "{DOWN}"
    Key "{RIGHT}"
    Key "{DOWN}"
    Key "{DOWN}"
    Key "{DOWN}"
    Enter ""
    Pause "Enter/Edit [EMAIL PROTECTED],1"
    Pause "@4,1"
    Enter "TCH"     'ENTER THE NAME OF THE PAYROLL
    Key "@_CLEAR"
' @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

    Do Until EOF(F)
        Line Input #F, strRec
        strEmpNumb = Trim$(Mid(strRec, 30, 11))    ' data col = 30, len = 11
        strEmpName = Trim$(Mid(strRec, 1, 25))   ' data col = 1, len = 25
        strAmt = Trim$(Mid(strRec, 60, 7))   ' data col = 60, len = 7

        Pause "@4,13"  'pausing at Employee prompt
        Key "@_CLEAR"
        Enter strEmpNumb   ' read then write employee id from EmployeeList.prn
        Stable 2
               
        '     ??????????????????????????????? TERM ????????????????????????????????????
        '     if there is a warning write the employee info to log and exit
            If At("[EMAIL PROTECTED],1") Then
                Key "O"  'key the OK button
                txtfile.WriteLine strEmpNumb + ";" + strEmpName + ";" + strAmt + ";" + 
"TERM" 'write a line with a new line character
                Pause "@4,13"    ' Do Until EOF - enter next Employee ID


        '     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ CTRL HOURS BLANK ^^^^^^^^^^^^^^^^^^^^^^
        '     evaluate the CTL HOURS field: tab past it if there is a value; exit from 
timecard if blank

            ElseIf Trim(View(2, 1, 3)) = "" Then
                Pause "@4,78"  'pausing at CTL Hours prompt
                txtfile.WriteLine strEmpNumb + ";" + strEmpName + ";" + strAmt + ";" + 
"NO-TIMECARD" 'write a line with a new line character
                Key "{ESC}"
                Pause "[EMAIL PROTECTED],1"
                Pause "[EMAIL PROTECTED],1"
                Key "Y"  'key the Yes button to Exit
                Pause "@4,13"    ' Do Until EOF - enter next Employee ID


        '     ############################ Okay? Enter Allowances #####################

            Else 
                Tab_ ""  ' tab past CTL HOURS field and enter allowance
                Pause "@10,6" 'pausing at the first line of the Earnings prompt
                Key "{PgDn}"   'page down to first available line under Earnings prompt
                Enter "46"  ' enter earning code (44-retro, 46-FLSA, 
47-cleaing/clothing)
                Enter "0" 'enter zero for hours
                Tab_ "" 'tab past Shf field
                Tab_ "" 'tab past Job Code field
                Tab_ "" 'tab past Department field
                Stable   'stable cursor at the Amount prompt before writing allowance
                Enter strAmt  '  read and write allowance amount from EmployeeList.prn
                Stable   'stable cursor at the Amount prompt after writing allowance
                Key "{F12}"
                Pause "[EMAIL PROTECTED],1"
                Pause "[EMAIL PROTECTED],1"
                Key "Y"  'key the Yes button to File
                Pause "@4,13"    ' Do Until EOF - enter next Employee ID
            
            End If
            
      Loop

' @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

      txtfile.Close

      Key "{ESC}"
      Key "{ESC}"
      Key "{ESC}"
      Key "{ESC}"

      MsgBox "!!! Script Completed !!!"

End Sub



Sub HaltScript()
    Halt_
End Sub

Attachment: EmployeeList.prn
Description: Binary data

0001;BARKER,MICHELLE;1000.00;NO-TIMECARD
000-11-9999;JONES,MICHAEL;50.00;TERM
100;ZZPP,EMPLOYEE#1;375.98;TERM
022-55-6666;JOHNSON,TED;66.90;TERM
33333;MEDITEST,JILLIAN;34.75;TERM
111-22-3333;SMART,WILLIAM;45.68;TERM
555-63-8989;CH,FIVE;90.00;NO-TIMECARD
999-99-9999;CHA,CHARLIE;99.99;NO-TIMECARD

Reply via email to