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

June 14, 2013

There are some exciting new developments in the works

Find out what's next for Synergy/DE

Read More


Introducing the power and flexibility of ISAM REV 6

By John Brunett, Senior Software Engineer

Read More


Quiz

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

Take Quiz


twitter.com/synergyde
 

New Synergy/DE 10.1.1a patch delivers more than fixes

Synergex's first patch to Synergy/DE 10.1 is now available to download.

Read More


Synergy/DE Tech Tip

Which libraries do you need when running Synergy/DE on Linux?

Read More


Platform News

Read a selection of recent articles

Read More


Synergex holiday reminder

Synergex will be closed on Thursday, July 4, in observance of Independence Day

Read More

 


To infinity and beyond

See how a Synergy/DE customer changed their core Unix-based application to a multi-tier application with unlimited possibilities

Come to the Synergy DevPartner Conference and learn how a company took their Unix-based Synergy application from this:

to this:


Customer detail, an advance draft listing, and a report are all loaded at the same time. Users can simply click on the tabs and switch between them.


Synergex Professional Services Group recently helped leading agribusiness software provider AgTrax de-couple their business logic from their user interface. So now they are able to deploy with either a green-screen front end or a graphical user interface and use the same business logic in either case.

At the Synergy DevPartner Conference, you will see the steps involved in developing this application, and you’ll see how the application was successfully reengineered to use Synergy/DE xfServerPlus.

Get more information about the conference at http://conference.synergex.com.

Synergy DevPartner Conference

**Conference attendees: Make sure to reserve your hotel rooms as soon as possible to ensure a room in the conference block at the discounted rate!**


I support incremental loading

Windows 8 introduces an easier way to support infinite scrolling

By Jeff Greene, .NET Developer

In most UI frameworks, if you want to support infinite scrolling, you have to do something like hook scroll bar events and then load more items when the scroll bar gets to a certain position. But with XAML for Windows 8 apps there is an easier way: ISupportIncrementalLoading.

 

One of the major design philosophies that Microsoft has been pushing for Windows 8 apps is that everything should be highly responsive, but nothing makes software unresponsive like trying to add 10K items to a list that the user might not even scroll. To make this problem easier to solve, Microsoft added the ISupportIncrementalLoading interface. To use it, all you have to do is implement ISupportIncrementalLoading on a class that inherits from ObservableCollection. Then any virtualizable XAML container that has this bound as its DataContext will have the ability to do incremental loading. While most Microsoft-provided controls support virtualization, the following is an example of a UI control that is virtualized because it is bound to a ListView. Note that this and the other examples in this article are from a Visual Studio solution that you can download at http://synergex.com/downloads/Synereddit.zip.

 

 

<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">

    <ListView ItemsSource="{Binding Links}">

        <ListView.ItemTemplate>

            <DataTemplate>

                <Grid>

                    <TextBlock Text="{Binding Title}"/>

                </Grid>

            </DataTemplate>

        </ListView.ItemTemplate>

    </ListView>

</Grid>

 

Now that you know what this looks like on the UI side, we can talk about how to implement it on the code side. Our example pulls links using a web service from the popular link aggregation site reddit.com. I’ll gloss over the specifics of talking to reddit.com, but you can download the solution mentioned above to see this.

 

ISupportIncrementalLoading contains two methods: HasMoreItems and LoadMoreItemsAsync. HasMoreItems, as its name suggests, is what the container calls to determine if there is more data to load. LoadMoreItemsAsync is called with a desired number of elements to load. You can load as many as you want, but the number passed to LoadMoreItemsAsync is the framework’s suggestion for optimal efficiency.

 

LoadMoreItemsAsync returns an IAsyncOperation, so it’s not quite compatible with Task. (See “Asynchronous programming: What you’ve been AWAITing for” from the April 12 edition of Synergy-e-News for information on Task.) But there is a helper that bridges the gap for us, namely ToAsyncOperation() on Task. This is usually implemented in this way: a private method that returns Task is called from the public implementation, with ToAsyncOperation() being called on the resultant Task object. You can see this in the following implementation of ISupportIncrementalLoading, which is from a class (RedditLinksCollection) that inherits from ObservableCollection:

 

private initialLoad_, boolean

private after_, @String

             

public property HasMoreItems, boolean

       method get

       proc

              ;;If not loaded or there is more data, then

              ;;it’s a good idea to call LoadMoreItemsAsync

              mreturn !initialLoad_ || !String.IsNullOrWhiteSpace(after_)

       endmethod

endproperty

 

private async method LoadMoreItemsAsyncImpl, @Task<LoadMoreItemsResult>

       count, uint

       endparams

proc

       data result = new LoadMoreItemsResult()

       data gottenJson, @string, GetTheJson()

       result.Count = AddLinksFromJson(gottenJson)

                    

       mreturn result

endmethod

 

public method LoadMoreItemsAsync, @IAsyncOperation<LoadMoreItemsResult>

       count, uint

       endparams

proc

       mreturn LoadMoreItemsAsyncImpl(count).AsAsyncOperation()

endmethod

 

Now we’re going to glue everything together in the simplest possible way. You should really use the Model-View-ViewModel (MVVM) design pattern for this sort of thing, but our example is just a single page. So when the page gets constructed, we simply set the DataContext to be a new instance of our RedditLinksCollection:

 

namespace Synereddit

       public sealed partial class MainPage extends Page

 

              public method MainPage

                     endparams

              proc

                     this.InitializeComponent()

                     Links = new RedditLinksCollection()

              endmethod

             

              public property Links, @RedditLinksCollection

                     method get

                     endmethod

                     method set

                     endmethod

              endproperty

       endclass

endnamespace

 

As with all things, there are some caveats. Virtualizable UI is very nice and performs well in most cases, but if the items in your list contain expensive-to-create UI controls, remember that the UI controls are created and destroyed as they come into view. You have a lot of headroom on a modern desktop system, but this can be problematic on ARM devices and low-powered x86 devices. Keep your target device in mind.

 

So here’s a quick recap of what we’ve talked about here. ISupportIncrementalLoading is the Windows 8 way to do infinitely scrolling lists. It loads more data as the user scrolls down the page, and it works with any virtualizing container (derived from VirtualizingStackPanel). But don’t put expensive-to-create UI controls in one.

 

Synergy/DE 10.1 offers support for Windows 8. For more information, visit our web site. Download the Visual Studio solution mentioned in this article at http://synergex.com/downloads/Synereddit.zip.

 

Synergy/DE tech tip

Unable to set Width property of a .NET form to less than 132 pixels

Question

I am trying to set the Width property of a .NET form to 100 pixels, but I can't set it to less than 132 pixels. (The Width member for the MinimumSize property is set to 0.) What's preventing me from setting the Width property to 100?


Answer

To set the Width property to something less than this minimum (132), set the FormBorderStyle property for the form to None (integer value 0) before setting Width.

By default, the Width property for a .NET form's frame has a minimum setting that allows enough space for the frame's components (an icon, a caption, and buttons for minimizing, maximizing, and closing the form). This minimum varies depending on the screen resolution and the Windows theme in use. In this case the frame requires 132 pixels, so you won't be able to set the Width property to anything less than 132. However, if you set FormBorderStyle to 0, this limitation is removed.

Note that this also applies to .NET forms embedded in UI Toolkit windows with the Toolkit routine %DOTNET_TKWIN. Even though Toolkit turns off the frame for a form in this case, it doesn't change the FormBorderStyle property. So the Width property can't be set to anything less than the minimum calculated for it unless you set FormBorderStyle to 0 before changing Width.

Quiz

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

What will be the result of the following Synergy Language code given these assumptions?

  • We have a valid memory handle (rh) with a valid length set (rl) and the handle contains valid XML returned from a call to a web service that returns US city/state information for a ZIP Code
  • The request to the web service included a valid ZIP Code
  • ZipCode and City are valid nodes
  • The XML returned does NOT include a node for Error and contains only valid nodes
  • DBLDIR:synxml.def is included in the program
;; In the data division.....

record
    doc             ,XML_DOC_TYPE
    parser          ,XML_PARSER_TYPE

    root            ,XML_ELEM_TYPE
    rootcount       ,i4                     ;Loop counter
    rootchildren    ,XML_ELEMLIST_TYPE      ;XML element list
    rootchild       ,XML_ELEM_TYPE          ;XML element

    count           ,i4                     ;Loop counter
    children        ,XML_ELEMLIST_TYPE      ;XML element list
    child           ,XML_ELEM_TYPE          ;XML Child element

    errCount        ,i4                     ;Loop counter
    errChildren     ,XML_ELEMLIST_TYPE      ;XML element list
    errChild        ,XML_ELEM_TYPE          ;XML Child element

    tt              ,i4
    city            ,a50
    rh              ,D_HANDLE
    rl              ,i4

record
    errtxt          ,a60                    ;error text
    xmlstr          ,a30000
    elem_name       ,a256

;; Somewhere in the procedure division......

process_results,
    begin

    open(tt=%syn_freechn,O,"tt:")

    xcall xml_option("ENCODE", SYNESCAPE_UNESCAPE)

    xmlstr = %xml_string_create
    xcall xml_string_appendhandle(xmlstr, rh, rl)

    doc = %xml_parser_parsestring(parser, xmlstr)

    xcall xml_string_delete(xmlstr)

    if (doc) then
    begin
        call parse_results
        xcall xml_doc_delete(doc)

        writes(tt,city)
    end
    else
    begin
        writes(tt,errtxt)
    end

    return

;-----------------------------------------------------------------------------

parse_results,

    root = %xml_doc_getroot(doc)
    xcall xml_elem_getname(root, elem_name)

    rootchildren = %xml_elem_children(root)
    for rootcount from 1 thru %xml_elemlist_count(rootchildren)
    begin
        rootchild = %xml_elemlist_item(rootchildren, rootcount)
        xcall xml_elem_getname(rootchild, elem_name)
        using elem_name select
        ("ZipCode"),
        begin
            children = %xml_elem_children(rootchild)
            for count from 1 thru %xml_elemlist_count(children)
            begin
                child = %xml_elemlist_item(children, count)
                xcall xml_elem_getName(child, elem_name)
                using elem_name select
                ("City"),
                    xcall xml_elem_gettext(child, city)
                endusing
            end
        end
        endusing
    end

    return

 

a. Blank output

b. The text returned in a City node in the XML

c. It won’t compile

d. A run-time error

e. Error text

 

 Click to read the answer


Platform News

Read a selection of recent articles

Windows

Microsoft sells more than 100M Windows 8 licenses in 6 months

http://news.cnet.com/8301-10805_3-57583162-75/microsoft-sells-more-than-100m-windows-8-licenses-in-6-months/

 

Windows Blue gets official name: Windows 8.1

http://news.cnet.com/8301-10805_3-57584370-75/windows-blue-gets-official-name-windows-8.1/

 

Microsoft admits zero-day bug in IE8, pledges patch

http://www.computerworld.com/s/article/9238922/Microsoft_admits_zero_day_bug_in_IE8_pledges_patch?taxonomyId=89

 

Windows 8 tablets hit 3 million shipped in first quarter

http://news.cnet.com/8301-1001_3-57581316-92/windows-8-tablets-hit-3-million-shipped-in-first-quarter/

 

Intel CEO on Windows 8 woes: Pesky 'adoption curve'

http://news.cnet.com/8301-1001_3-57579968-92/intel-ceo-on-windows-8-woes-pesky-adoption-curve/

 

Windows 8, take 2? Let's see Start button, boot to desktop

http://news.cnet.com/8301-10805_3-57579793-75/windows-8-take-2-lets-see-start-button-boot-to-desktop/

 

Microsoft rolling out two-factor authentication

http://news.cnet.com/8301-10805_3-57580071-75/microsoft-rolling-out-two-factor-authentication/

 

 

Unix/Linux

 

Linux 3.9 released

http://www.osnews.com/story/26992/Linux_3_9_Released

 

Other

 

Apache servers ambushed by sophisticated backdoor attacks

http://www.infoworld.com/d/security/apache-servers-ambushed-sophisticated-backdoor-attacks-217553

 

How hackable is your password? McAfee offers password tips

http://news.cnet.com/8301-1009_3-57583213-83/how-hackable-is-your-password-mcafee-offers-password-tips/

 

Targeted cyberattacks jump 42 percent in 2012, Symantec says

http://news.cnet.com/8301-1009_3-57579847-83/targeted-cyberattacks-jump-42-percent-in-2012-symantec-says/

 

Identity Loss is the Leading Data Breach Attack

http://www.esecurityplanet.com/hackers/identity-loss-is-the-leading-data-breach-attack.html

 

Recently patched Java flaw already targeted in mass attacks

http://www.computerworld.com/s/article/9238652/Recently_patched_Java_flaw_already_targeted_in_mass_attacks

Synergex holiday reminder

Synergex will be closed on Monday, May 27, in observation of Memorial Day.

 

If you anticipate needing our assistance on this day, let us know.