Creating A Global Procedure

You may want global access to subroutines and functions if you use them frequently. iFIX provides global subroutines and functions, such as OpenPicture, ToggleDigitalPoint, and OnScan, that you can use in your pictures and schedules. You can also include your own global subroutines and functions in the User page.

To add a global subroutine to the User page:

  1. Open the Visual Basic Editor.
  2. If the Project Explorer is not already displayed in the VBE, select Project Explorer from the View menu.
  3. In the Project Explorer, select the Project_User project.
  4. On the Insert menu, click Module. You need to store your code in a module and not in the Project_User page itself.
  5. Enter the following code in the Code window:

Public Sub DisplayMyMessage()

     MsgBox "This is my message box."

End Sub

  1. Close the Code window and create a rectangle in your picture.
  2. Right-click the rectangle and select Edit Script from the pop-up menu. VBE opens the Code window for the rectangle's Click event. Enter the following in the Code window:

DisplayMyMessage

  1. When you click the rectangle in the run-time environment, the message box that was stored in the Project_User page appears.

How Do I...