Skip to content

Tutorial 04 04 Add Traditional Bridge Routines

Matt Linder edited this page Jun 5, 2023 · 26 revisions

Harmony Core Logo

Tutorial 4: Add Traditional Synergy Routines

The next step in the process is to add the traditional Synergy routines that you want to expose to the TraditionalBridge project. In your actual environment, you may have existing routines in existing libraries, in which case you would add references to those libraries in the TraditionalBridge project so that the TraditionalBridgeHost program would be linked against those libraries. But for the purpose of this tutorial, we will start by adding the code for a single routine directly in the TraditionalBridge project.

Add GetEnvironment.dbl

The first routine we will add has no parameters, but is a function that returns an alpha value. The return value will be the output from the Synergy %versn function.

  1. In Solution Explorer right-click on the Methods folder (TraditionalBridge > Source > Methods) and select Add > New Item from the context menu.

  2. In the Add New Item dialog, select Code File, and then set the name of the file to GetEnvironment.dbl. Then click Add.

  3. Copy and paste the following code into the new source file:

    ;;*****************************************************************************
    ;;
    ;; Title:       GetEnvironment.dbl
    ;;
    ;; Description: An example routine being exposed by Traditional Bridge.
    ;;              Returns the Synergy DBL version number and operating system.
    ;;
    ;;*****************************************************************************
    
    function GetEnvironment, a
    proc
        freturn %versn
    endfunction
    
  4. Save the file.

Add GetLogicalName.dbl

Now let's add a second routine. This one will be a little more complicated because it has an in parameter that will be used to pass in the name of a logical. The return value of the function will be the translation of that logical name in the traditional Synergy environment.

  1. Right-click the Methods folder and select Add > New Item.

  2. In the Add New Item dialog, select Code File, set the name of the file to GetLogicalName.dbl, and then click Add.

  3. Copy and paste the following code into the new source file:

    ;;*****************************************************************************
    ;;
    ;; Title:       GetLogicalName.dbl
    ;;
    ;; Description: An example routine being exposed by Traditional Bridge.
    ;;              Returns the translation of a logical name.
    ;;
    ;;*****************************************************************************
    
    function GetLogicalName, a
        required in aLogicalName, a
        stack record
            translation,    a1024
            length,         i4
        endrecord
    proc
        xcall getlog(aLogicalName,translation,length)
    
        if (length)
            freturn translation(1:length)
     
        freturn ""
    
    endfunction
    
  4. Save the file.

Add AddTwoNumbers.dbl

Now we'll add a third routine, which will be a subroutine with three parameters. The first two parameters will be in parameters and will be used to pass numeric values. The third parameter will be an out parameter. The routine will add the values of the first two parameters and store the resulting value in the third parameter.

  1. Right-click the Methods folder and select Add > New Item.

  2. In the Add New Item dialog, select Code File, set the name of the file to AddTwoNumbers.dbl, and then click Add.

  3. Copy and paste the following code into the new source file:

    ;;*****************************************************************************
    ;;
    ;; Title:       AddTwoNumbers.dbl
    ;;
    ;; Description: An example routine being exposed by Traditional Bridge.
    ;;              Calculates and returns the sum of two numbers.
    ;;
    ;;*****************************************************************************
    
    subroutine AddTwoNumbers
        required in  number1, n
        required in  number2, n
        required out result,  n
    proc
        result = number1 + number2
        xreturn
    endsubroutine   
    
  4. Save the file.

The Methods folder should now contain three files:

Methods folder

Add the BridgeMethods Interface

Next, we'll add the BridgeMethods interface from the SMC. This interface defines the three routines we just added.

  1. Open a Windows command prompt and navigate to the directory with the .sln file for your Harmony Core solution. Then enter the following command to open the Harmony Core GUI tool:

    harmonycore gui
    
  2. When the "Loading Solution" message disappears, select Interfaces to open the Interfaces screen, and then click Add interfaces in the status bar.

  3. In the "Add interfaces" dialog, select BridgeMethods and then click OK. BridgeMethods will now be displayed on the Interfaces screen:

    BridgeMethods interface

  4. Select File > Save from the menu to save the setting you just added.


Next topic: Add Dispatcher Classes


Clone this wiki locally