Skip to content

Tutorial 04 04 Add Traditional Bridge Routines

Steve Ives edited this page May 26, 2020 · 26 revisions

Harmony Core Logo

Tutorial 4: Add Traditional Bridge 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 Traditional Bridge project so that the TraditionalBridgeHost program is 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 routine.

  1. In Solution Explorer right-click on the TraditionalBridge project, select Add > New Folder, and name the folder Methods.

  2. Right-click on the Models folder, select Add > New Item....

Let's add the first routine that we will be exposing. It's a function that has no parameters:

  1. In the Add New Item dialog, select Code File, and set the name of the file to GenEnvironment.dbl before clicking Add.

  2. 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
    
  3. Save the file.

Add GetLogicalName.dbl

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

  1. Right-click on the Models folder, select Add > New Item....

  2. In the Add New Item dialog, select Code File, and set the name of the file to GetLogicalName.dbl before clicking 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 Synergy DBL version number and operating system.
    ;;
    ;;*****************************************************************************
    
    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

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

  1. Right-click on the Models folder, select Add > New Item....

  2. In the Add New Item dialog, select Code File, and set the name of the file to AddTwoNumbers.dbl before clicking 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.

Your Methods folder should now contain three files:

Harmony Core Logo

Build the Code

Before we move on, let's make sure the project builds:

  1. Right-click on the TraditionalBridge project and select Build.

  2. Check the Output window and verify that the build was successful.

1>------ Build started: Project: TraditionalBridge, Configuration: Debug x64 ------
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

Next topic: Add Dispatcher Classes


Clone this wiki locally