SYNERGY-E-NEWS
News and Updates for Synergy/DE Developers

September 30, 2013

Data bind exposed field properties on your Data Object to UI controls

It's easy with Symphony Framework Data Objects

Read More


Microsoft releases Visual Studio 2013 Release Candidate (RC)

Also announces upcoming Virtual Launch Event

Read More


Platform News

Read a selection of recent articles

Read More


 

Snapshots in a snap

Recover previous data states with ISAM Change Tracking

Read More


Synergy/DE Tech Tip

Ranging errors with string variables will cause Unhandled Exception errors at runtime in Synergy .NET code

Read More


Quiz

Synergy/DE pros, see if you can answer this question!

Take Quiz


twitter.com/synergyde

Data bind exposed field properties on your Data Object to UI controls

It's easy with Symphony Framework Data Objects
By Richard Morris, Senior Professional Services Group Consultant

In my previous article (Symphony Framework Basics: Data Objects) I introduced you to the Symphony Data Object. These Data Objects are at the root of a Symphony Framework development. This article demonstrates how to data bind the exposed field properties on your Data Object to user interface controls.

Before we deep dive into data binding let’s take a minute to understand how we are going to craft our new user interface (UI). For a Windows Presentation Foundation (WPF) desktop application we will be building our UI in XAML. …

Read more and watch a short video to learn how to create Symphony Data Objects and build them into your Synergy .NET Visual Studio project.


Snapshots in a snap

Recover previous data states with ISAM Change Tracking
By John Brunett, Senior Software Engineer, Synergy/DE

New in Synergy/DE 10.1, Change Tracking is one of the biggest major additions to Synergy DBMS since its inception. Built directly into the DBMS subsystem, Change Tracking is an entirely transparent mechanism. Once configured, a file automatically tracks all types of changes — inserts, updates, and deletes — within the same working file. Then, using the Select class, you can develop routines to query those changes as you require.

Internally, Change Tracking is simply another index key (hidden, so it doesn’t interfere with your other keys). Unlike other methods of change logging (like keeping two copies of the same record, one in the file and the other in a log file), Change Tracking can, in most cases, just move a link from one index to another — there’s no need to write the record somewhere else, because the original copy is still there.

A new concept associated with Change Tracking is a snapshot. Typically with a mechanism that tracks changes, there needs to be a way to isolate changes made during a specific time period. Recording the date of every change is one option, but doing so for thousands of updates could cause costly overhead, when all you really may want are changes made between two specific times. A snapshot is a timed synchronization point that can represent a specific time (e.g., a start time or an end time). Changes made after a snapshot is applied are grouped in chronological order with respect to that snapshot until another snapshot is applied, which ends that group and starts a new group. Changes that follow the last applied snapshot are considered to be part of the next snapshot. Using the Select class, you can retrieve those changes by specifying two snapshots (start and end) by number. Snapshots can be applied at key time intervals (like end-of-day or end-of-week) for effective retrieval.

The file itself is like any other ISAM file; all READ, READS, STORE, WRITE and Select I/O operations perform as they always have. But to get at the change history, we’ve added a few new methods to the Select class. The Where.Changes and Where.NetChange methods take two snapshot numbers as arguments and return a single record for each enumerator iteration, representing a change or net change that was made to a file between the two snapshot times. So, across several snapshots, Where.Changes shows all recorded changes made throughout those snapshots. It may show an insert of a record followed by several updates of the same record. Over that same span of snapshots, Where.NetChange shows the net result of those recorded changes. In other words, the above selected record would be a single insert with the contents of the last update, or no record at all if it had been inserted and deleted during that period.

To make it easier to programmatically specify snapshot numbers, we’ve included relative numbering. A positive snapshot number represents the actual recorded snapshot number, but a negative snapshot number represents a relative snapshot. It’s possible to use relative snapshots without knowing the current snapshot.

Using the new CTInfo class, you can get information like change type (insert, update, delete) by using the CTInfo.CTState property. If necessary, you can also access back and forth across snapshots to see different versions of the same record by using the CTInfo.Older and CTInfo.Newer properties.

Identifying a change record depends on the CTState bit pattern that gets returned.

public enum CTState

Untracked               0x00

Insert                  0x01

Update                  0x02

Delete                  0x04

ModifiedByDelete        0x10

ModifiedByUpdate        0x20

Changed                 0x30

PriorVersion            0x40

endenum

Correctly identifying a change record requires using the bitwise logical operators, which can be a little tricky. Here is some sample code:

ctstate = selenum.GetCTInfo.GetCTState

if (ctstate.band.CTState.Insert) then

    display(ttchn, "[Insert")

else if (ctstate.band.CTState.Delete) then

    display(ttchn, "[Delete")

else if (ctstate.band.CTState.Update) then

    display(ttchn, "[Update")

else

    display(ttchn, "[No Change data")

if (ctstate.band.CTState.ModifiedByDelete) then

    display(ttchn, ":ModifiedByDelete")

else if (ctstate.band.CTState.ModifiedByUpdate)

    display(ttchn, ":ModifiedByUpdate")

if (ctstate.band.CTState.PriorVersion)

    display(ttchn, ":PriorVersion")

if (.not.(int)(ctstate.band.CTState.Changed).and..not.(int)(ctstate.band.CTState.Delete)) then

    writes(ttchn, ":Active]")

else

    writes(ttchn, "]")

A retrieved change record flagged with Insert reflects the record contents as they were first stored; Update reflects the new record contents after they were updated; and Delete reflects the record contents as they were when they were deleted. If an Insert or Update record includes the Changed enumeration (ModifiedByUpdate or ModifiedByDelete), an updated version or deletion of that record exists in a newer snapshot; otherwise that record is currently active. An “active record” is simply the record version that will be retrieved when accessing the file through regular I/O (READ/READS). An “inactive record” is a prior record version and cannot be changed.

Something to consider when deciding when to issue a snapshot is how changes are recorded during a snapshot. Multiple changes made to the same record during the same snapshot will get folded into a single net change. For example, an Update following an Insert during the same snapshot will be converted to a single change and marked as a net Insert at the interval the Update was made. Similarly, a Delete following an Insert made during the same snapshot will result in all traces of that record being removed entirely. If a finer level of change tracking is desired, snapshots need to be applied more frequently. You might consider a daily snapshot if you plan on implementing data replication.

You can also select on a certain type of change. For example, if you just want inserts, you can include the following in your Where expression:


      Where.Changes(snapshot_1, snapshot_2).and.Where.ChangeType(CTState.Insert)

Another use of Change Tracking is the ability to view a file as it was at a certain time in history. The Where.Snapshot method takes a single snapshot number as its only argument to identify the end time condition for a file. Then, enumerated records represent the active (and possibly inactive) contents of a file as they existed at the time the snapshot was made. Records can be inserted, updated, or even deleted after the snapshot occurred without altering the original content of that snapshot. An example of how this feature can be used is in end-of-period processing. A bank can issue a snapshot at 5:00 pm and proceed to calculate end-of-day figures or generate a report, while customers continue to access and update their accounts without interfering with that process.

To manage a file with Change Tracking, we’ve added a new utility called ctutl. Ctutl enables you to apply snapshots as well as free them. A powerful function of this utility is the “rollback” function: all changes to a file can be rolled back to a specific snapshot. You’ll also use this utility to free old snapshots and the change history preceding them. The “free” function is necessary to manage the space used by Change Tracking. Neglecting to free old snapshots can cause a file to exceed your disk capacity or exceed the maximum 255 snapshot limit, so don’t forget to free.

Whether you need to replicate DBMS data to another database, roll back changes after failure, or report end-of-day figures, Change Tracking can be your path. For more information, see the Synergy DBL Language Reference Manual and the Synergy Tools manual.             

Back to top

Microsoft releases Visual Studio 2013 Release Candidate (RC)

Also announces upcoming Virtual Launch Event

On September 9, S. Somasegar of Microsoft announced the public availability of the Visual Studio 2013 Release Candidate (RC). He also announced that the Visual Studio 2013 Virtual Launch will be held November 13, 2013. See his blog for RC details and download links; see the events page for launch event details.

We have been working with Microsoft and testing each of their Visual Studio 2013 pre-releases to make sure Synergy DBL’s integration with Visual Studio will work optimally when Visual Studio 2013 is released. If you would like to see how Visual Studio 2013 RC works with your Synergy .NET development, you can download a special Synergy/DE 10.1.1a patch here on our web site.


Quiz

Given the following code, what will the output from the program be?

main
record
	result		,d10.2
	num1		,d10.2
	num2		,d10.2
	
proc
	open(1,o,'tt:')
	num1 = 5.6
	num2 = 3.7
	writes(1, %string(AddTwoNumbers(num1,num2)))
	close 1
	stop
end

function AddTwoNumbers ,d
	anum1	,d.
	anum2	,d.
	
proc
	freturn anum1 + anum2
end

Options:
	a) It won’t compile
	b) Run time error
	c) 9.3000000000000000000000000000
	d) 9

Click here to read

Synergy/DE Tech Tip

Ranging errors with string variables will cause Unhandled Exception errors at runtime in Synergy .NET code

When a string variable is improperly ranged in a Synergy .NET program, the following error occurs:

Unhandled Exception: Synergex.SynergyDE.SynDataException: Invalid subscript specified
  at Synergex.SynergyDE.VariantDesc.RelRange(Int32 start, Int32 len)

Improper ranging is ranging past the end of a string or attempting to range into a NULL string. If the same code is compiled with the traditional Synergy compiler, an “Invalid subscript specified / Access violation” error occurs. This error is trappable when compiled under either compiler. When the error occurs in a Synergy .NET application, it causes the registered Windows Debugger to catch the error.

Note that when an alpha variable is improperly ranged into with a literal ranging value, the error is typically caught at compile time, as alpha variables have a known fixed size. But because a string variable doesn't have a length until a value is placed into the string, it isn't possible to catch this error at compile time for string variables and literal ranging values. When an alpha variable is ranged into with variables as the ranging values, it also isn't possible for the compiler to catch the error, and the results will be unpredictable, depending on what the improper ranging corrupts. In this case, we recommend compiling with bounds checking (-B or –qcheck on Windows/UNIX or /CHECK=BOUNDS on OpenVMS) to have information on the ranging error presented at runtime.

Back to top

Platform News

Read a selection of recent articles

Windows

Windows 8.1 retail pricing & packaging revealed, full versions return
http://www.techspot.com/news/54041-windows-81-retail-pricing-packaging-revealed-full-versions-return.html

Microsoft ups the ante on its iPhone, iPad trade-in promotion
http://www.zdnet.com/microsoft-ups-the-ante-on-its-iphone-ipad-trade-in-promotion-7000020859/

Microsoft reverses course; releases Windows 8.1 RTM to developers
http://www.zdnet.com/microsoft-reverses-course-releases-windows-8-1-rtm-to-developers-7000020402/

Microsoft delivers near-final Visual Studio 2013 Release Candidate
www.zdnet.com/microsoft-delivers-near-final-visual-studio-2013-release-candidate-7000020423/

Microsoft to add Siri-like Cortana to Windows devices, shows off Windows Phone 8.1
http://www.extremetech.com/computing/166435-microsoft-to-add-siri-like-cortana-to-windows-devices-shows-off-windows-phone-8-1

Dell cleared for $25 billion buyout, will remain committed to PCs
http://www.techspot.com/news/53988-dell-cleared-for-25-billion-buyout-will-remain-committed-to-pcs.html

Unix/Linux

Keeping your Red Hat Enterprise Linux current
http://www.zdnet.com/keeping-your-red-hat-enterprise-linux-current-7000020688/

Intel: The year of the Linux desktop is here
http://www.zdnet.com/intel-the-year-of-the-linux-desktop-is-here-7000020849/

IBM and Linux: The next billion dollars
http://www.zdnet.com/ibm-and-linux-the-next-billion-dollars-7000020757/

Linux development by the numbers: Big and getting bigger
http://news.cnet.com/8301-1001_3-57603216-92/linux-development-by-the-numbers-big-and-getting-bigger/

Linux kernel luminaries talk enterprise, embedded and why they're coming together
http://tinyurl.com/p8bluh8

Other

Oh Quark: Intel just changed the technology market
http://www.technewsworld.com/story/Oh-Quark-Intel-Just-Changed-the-Technology-Market-78941.html