Forum Discussion

Vahan's avatar
Vahan
Contributor
13 years ago

Error when calling one function from another

I have to scripts: A & B. Each script has only one function in it. I want the function in script A to call the function in script B. I have also added the 'USEUNIT B to the beginning of script A. When I run script A I get an error message "Object doesn't support this property or method: '<functionname>'" . Can anyone tell me where I am going wrong?

Here is the code:

Script A


'USEUNIT CheckCurrentAllergiesForItem

Function SetAndCheckCommonAllergies(object, action)

  DIM grid, match

  SET grid = Aliases.Amazing_Charts.frmPatientAllergies.CurrentAllergy_fra.gridPatientAllergies

  select Case object.Text

    case "Ace Inhibiters" item = "angiotensin converting enzynme inhibitor"

    case "Codeine" item = "codeine"

    case "Penicillins" item = "penicillin"

  End Select

  If action = TRUE Then

    If object.wState = cbUnchecked Then       'If checkbox is unchecked then click it, if not then do nothing

      object.Click  

    End if    

  Else

    If object.wState = cbChecked Then       'If checkbox is checked then click it, if not then do nothing

      object.Click  

    End if

  End if

  SetAndCheckCommonAllergies = CheckCurrentAllergiesForItem(item,TRUE)

End Function



Script B


Function CheckCurrentAllergiesForItem (Allergy, Logic)

  DIM grid, match

  SET grid = Aliases.Amazing_Charts.frmPatientAllergies.CurrentAllergy_fra.gridPatientAllergies

  match = FALSE

  For row = 0 to grid.RowCount()-1

    Set Cell = grid.wValue(row,2)

    CellValue = Cell.OleValue

    if Allergy = CellValue Then

      match = TRUE

    End IF

  Next

  If Logic = TRUE Then

    If match = TRUE then

      CheckCurrentAllergiesForItem = TRUE

    Else

      CheckCurrentAllergiesForItem = FALSE

    End if

  Else

    If match = TRUE then

      CheckCurrentAllergiesForItem = FALSE

    Else

      CheckCurrentAllergiesForItem = TRUE

    End if

  End If

End Function

11 Replies