Phone800.366.3472 SupportGet Support DocumentationDocumentation Resource CenterResource Center
search
close
Open Menu

Synergex Blog


Dig into Synergy/DE 9.5 – Using CodeExchange

By William Hawkins, Posted on November 19, 2010 at 12:46 pm

Avatar

Like many of you, I’ve been waiting with bated breath for the release of Synergy/DE 9.5, and the general availability of Synergy .NET. The development team has been working on this project for a few years (I’m sure it seems like longer for them). But it wasn’t until the beta release earlier this year, that it became something with which you could actually start to write code that really did something useful. Those of you who were at the SPC a few weeks ago had an opportunity to use Synergy/DE 9.5 to develop a WPF application that used Synergy for all the (non-XAML) code in Visual Studio 2010.

As part of the beta testing effort, I’ve been using and updating code that has been submitted to the CodeExchange, and I thought I’d share what I did. Hopefully you can leverage the modifications that were done to the CodeExchange items to help with a possible migration to the .NET environment.

In order to make my life easier, I created a folder C:\Development\CodeExchange and deposited all of the CodeExchange submissions that were created by Synergy PSG, into subfolders.

Phase 1 Test the code in traditional Synergy 9.5.

As I knew I’d be doing a lot of test builds, I wanted to use the project build system built into Workbench (in Synergy/DE 9.3). So I created an empty workspace, and added all the Workbench projects that were in the subfolders. For those projects that didn’t have a Workbench projects, I created one, and for the few projects that didn’t have a mainline program, I created one of those too. Most of the time spent in this phase was in setting the Workbench build environment. As you would expect, the code didn’t require much (if any) modification.

Phase 2 Test the code in Synergy .NET 9.5.

When taking the CodeExchange submissions and building them in Visual Studio, it turned out to relatively easy. In order not to “pollute” the standard CodeExchange folders with Visual Studio “stuff”, I decided to create a separate folder for Visual Studio project. This was C:\Development\CodeExchangeVS, and under this folder is a subfolder for each submission – just like the Workbench folders. Inside these subfolders are a Visual Studio solution and a Synergy project. The Synergy project contains references to the code in the Workbench folders, so that I can use the same code in both places. If you just add a source code file to a Visual Studio project, what you’re really doing is copying the file to the project folder, but all Add Reference does is point the project to the appropriate source file. Now that I have a Visual Studio project, it’s just a matter of hitting the F6 button to build my application. If only it were that simple…..

When building the CodeExchange code in Visual Studio, the code falls into a number of different categories;

1) Requires no/minimal changes

2) Uses features (functions/subroutines) that are not supported

3) Needs recoding

4) Uses features (APIs) that are not supported

Again, most of the code fell into the first category, as it had already compiled using the traditional Synergy compiler. One thing that fell into the “minimal changes” category was the introduction of a logical to point to an include folder (usually the same folder as the source). As Visual Studio was using sources from a different folder, we could no longer rely upon the include file being in the “current folder”. For the purposes of CodeExchange sources, wherever a logical is required to access an include file, the source will use INC:

Also, there was very little code that required recoding – this was almost exclusively required by the use of %DLL_CALL(), which needed to be changed to %DLL_NETCALL(). The coding change was relatively straightforward. (See example below.)

.ifdef DBLNET

begin

argArray = new object[2]

argArray[1] = (object)^addr(spec)

argArray[2] = (object)^addr(WIN32_FIND_DATA)

srch_hdl = %dll_netcall(dll, DLL_TYPE_WINAPI, ‘FindFirstFileA’, argArray)

end

.else ;DBLNET

srch_hdl = %dll_call(dll, DLL_TYPE_WINAPI, “FindFirstFileA”, ^addr(spec), ^addr(WIN32_FIND_DATA))

.endc ;DBLNET

The bulk of the changes needed were mostly to deal with unsupported or not yet implemented features. I first started this project in Feb/Mar 2010, and as time progressed, the number of issues grew significantly smaller as the Synergy development team implemented features omitted from the early betas. At the time of writing, the unsupported features that got caught by the compiler are the use of HTTP_SERVER, %SS_FATAL() and W_CAPTION(). Another problem feature is the use of UI Toolkit. While there is a version of UI Toolkit that you can use when you build using Visual Studio, it’s not a complete implementation. The UI Toolkit provided with Synergy .NET is primarily aimed at allowing UI Toolkit code to be used with xfNetLink .NET and/or .NET interop projects – which are projects that do not use UI Toolkit for the User Interface. If you actually run the application and call a UI-related Toolkit routine, a runtime error will be thrown. For all the projects that used UI Toolkit, I added a try-catch around the entire application, so that I can catch any errors thrown by UI Toolkit. From a CodeExchange perspective, use of UI Toolkit is the main item that falls into the fourth category. The RCB API is another example of an unsupported feature in Synergy .NET.

One difference between traditional Synergy and Synergy .NET, is that there is no “stop message” dialog. “Hurrah!” I hear a lot of you say. Me too. However, with the CodeExchange submissions, most of the test programs are console applications, and now that there’s no stop message, when they complete, the application goes away too. This doesn’t give you much time to read the screen. So I wrote myself a little StopMessage routine, and added it to every application that needed it. As it turns out, this change was by far the largest change that I had to do.

Along the way, we’ve also enhanced some of the submissions; for example, the StringUtil submission is now more functionally rich, and we also added some new submissions (e.g., isamBenchmarks, GetDirFiles, memProc, POP3mail and SelectExample). There is also a new submission CodeExchangeVS which contains all the submissions below, plus the Workbench workspace with all the Workbench projects and all the Visual Studio solutions.

Here are the CodeExchange submissions that are included in the CodeExchangeVS download;

addSourceControl, ASCIIEncoding, axlsort, Base64, Base64_convert, BatchFileConversion, COPY_HANDLE, creditCard, DateTime, DTKproto, dtk_i_enable_set, dtk_list_multi_select, FileLocks, FindNPchars, FixData, GetDirFiles, GetWindowSize, HTTPexample, HTTPqueryString, iConvert, IsamBenchmarks, isHoliday, ismKey, ismSts, lct_lmf, LicensingToolkitExample, ll_accept, memProc, PartialMatch, POP3mail, Registry, RemoteServer, rfa_hex, rpschk, rpssql, rpsxdl, rpsxml, SelectExample, SMTPmail, SocketExamples, StringUtil, synckodbc, SynPsg.Rps, UpsTrack, url_encode, uspsWebService, WinDir, xfnl_synergy, xfplini, xfpllog, xfspism2xml.

Also, one final change. At the request of Synergy/DE Developer Support, each submission includes all the code required to rebuild the application. Previously, some CodeExchange submissions required you to download other CodeExchange submissions.

If you’re using any of the CodeExchange items above, I would recommend that you download the updated version. Synergex PSG is constantly looking for new opportunities to enhance the CodeExchange code submissions, so if you have any suggestions for new items, please let us know.

A Synergy/DE 9.5 RC (release candidate) is available now, and the general release should be available soon.


Leave a Reply

Your email address will not be published. Required fields are marked *

*

Don't miss a post!

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Recent Posts Categories Tag Cloud Archives