One of the first things I wanted to read on my iriver story was the montly msdn subscription magazine which is available as a .chm. Which unfortunately the iriver story does not support, so I needed to convert it into either .pdf or .epub format.

As I am both a Mac and Windows user my choices were various from using a pdf printer on Windows to using various .chm readers on the Mac.

I first tried to use a .pdf printer on Windows but this not work due me using a 64bit version of Windows 7 and all the free pdf printers failed to either install or just simply did not work… much to my own frustration, so I turned to the Mac as this has native pdf support but did not have native .chm support! Don’t you just love computers…

On my mac I tried out various, these being:

  • Chmox
  • xchm
  • Chmosx
  • iChm
  • Again, I was meet with disappointment all of them either failed to display the embedded html in the .chm magazine (complaining about a nbsp entity) or just not displaying anything. So decided to raise a bug against the most the one I thought had the most chance of being fixed, which was the iChm application.

    So to my joy and delight the developer fixed it in version 1.4.2 and I was then able to load up the .chm, select Unicode encoding (as without this the pages did not display correctly) and then use the iChm function to export the .chm as a .pdf, copy it to the iriver story and I could then get back to reading all the years issues I had failed to read!

    So my tip for converting .chm to .pdf on the Mac is to use iChm as it works and the developer is very responsive to issues raised or was at least was for me! :-)

     

    Santa was very kind to me this year, as he has treated me to an iRiver Story ebook reader.

    Hopefully this will help me become less reliant to printed books!

    The first thing I found was that the firmware had been quietly updated to version 1.5. The changes are significant enough to state them and say that I have been using them for a couple of days and are delighted by the changes, thank you iriver.

    The major changes to the firmware include:

    . New Firmware supports “Table of contents” of PDF or Epub file.
    Please press”Option”button on PDF file.
    Cutting blank space of PDF file
    -. New Firmware supports the function, Cutting blank space of PDF file.
    -. Please press Zoom button and control its size with arrow btton.
    After the size control is done, please press Enter button

    * Power Option & User font
    -. New Firmware supports “Power Option” & “Changing font”(Office file, Text file, Memo, Diary)
    -. Menu -> Settings -> Power Option or Change Font

    The minor changes are for me equally important, the last one is especially welcome :-)

    a. Move Page
    -. Please press “option” button and select “Move Page”
    You can move the page with “arrow” button.

    b. Fit to Screen of comic file
    -. Please press “option” button and select “Fit to Screen on” to fit the screen size.

    c. Auto Page Transition of comic file.
    -. Please press “option” button and select “Auto Page Transition”
    You can set auto-page speed within 3 ~ 99 seconds.

    d. Dithering function of comic file
    -. Please press “option” butoon and select “Dithering on” to enjoy high-definition screen

    e. New Firmware support “GIF file” (by 2460*1948)

    f. Playback time is imporved from 24hr(max) to 30hr(max)

    The firmware can be downloaded from the iriver lounge or quickly from here!. Remember the .hex file always goes in the top level/root directory of the iriver story, the firmware update will start once you have disconnected from your computer.

    What next? I need to sort out some content for the device… more on this later..

    Dec 222009
     

    12 Tips for using Micro Focus COBOL

    As it is close to Christmas and I wanted to do something with 12 in the title, I’ve thrown together some useful if not un-ordered list of 12 things tips using Micro Focus COBOL.

    Remember I am just a developer and just want to help fellow developers out :-) so…

    Merry Christmas!

    and here is my list…

    1. Use DLLs/Shared objects rather than .int code
    2. DLLs/Shared objects can be preloaded using:
      01 my-ptr procedure-pointer.
      set my-ptr to entry "sodllname"

      Note; sodllname does not have the extension… let the runtime choose it for you!
    3. Use a good development environment such as Visual Studio or on Unix use Eclipse offering if you have a workstation, otherwise I personally use vim/gvim if terminal access is the only choce.
    4. Remember you have a great choice of platforms from Windows to Linux to a load Unix platforms, so choice is king. (did I say that…)
    5. Try using managed code (.Net) if you want to create WPF/WinForms or use WCF
    6. Interopability is great, so if you see a Java Class, .Net Class, COM object, ‘C’ function or a Web Service… use it! You can even mix unmanaged and managed applications..
    7. Avoid using the following if performance is key, as this really does help our code generator:
      alter
      perform thru
      next sentence
      segments
      go to section-name
      go to paragraph outside the current section
    8. Try to end your routine with a “stop run [returning..]” or “exit program [returning..]” or “goback [returning..]” as this gives our code generators a defined end to the routine, which really does help our code analysis/generator
    9. Use comp-5, integers for speed in calculations or native .Net types in managed
    10. Use comp-x for portability (file formats etc..)
    11. Make your application more robust, use tracing in production systems, either our own CTF tracing or your own or third party… it will save your life one day! Use runtime routines to catch error and log them (CBL_ERROR_PROC), ensure your programs shutdown cleanly always use CBL_EXIT_PROC.
    12. Use the generator directive nocheck if you are happy your code is solid and want to a little more performance. ie: it turns off runtime bounds checking

    Further reading:

  • Coding for speed, size and portability
  • Eclipse/COBOL on Unix
  • Newsletter about CTF
  • For CTF_ APIs see CBL_CTF_ see library routines
  • Yes.. its a bit of a mixed list.. but hey it may be of help!

     

    Today my collegues Robert and Alex have finally :-) decided to publish a document that compares Visual Basic, C# and COBOL for .Net under The Creative Commons Attribution-ShareAlike 2.5 License.

    Rather than doing a cut-paste job, here is a quote from alex, along with a link to the “real” article itself.

    Enjoy.

    Alex Turner said:

    A Comparison Of .Net COBOL, Visual Basic and C#

    Introduction

    If you are a COBOL programmer wanting to learn C# or a VB programmer wanting to learn COBOL as a .net language (or any other combination of VB.net, C# and COBOL) then this is a good place to start.

    Background

    If you are a COBOL programmer wanting to learn C# or a VB programmer wanting to learn COBOL as a .net language (or any other combination of VB.net, C# and COBOL) then this is a good place to start.

    It has often been noted that the richness of the COBOL language in its Micro Focus .net implementation is not well known. Robert Sales and I have worked on this document to help bring the language to peoples’ attention and to help people who need to work with COBOL on the .net platform.

    Click here to continue reading the rest of the article…

    Dec 082009
     

    If you are interested in trying out some of my examples with a modern COBOL compiler.. let me give you a quote from a friend.

    From: Twitter “Scot Nielsen said: Micro Focus COBOL for .NET and Visual Studio available here FREE for non-commercial.

    The development environment/compiler can be downloaded from the Micro Focus Shop.

    More information can be picked up from the Microsoft Visual Studio Gallery

    Dec 072009
     

    Continuing my series on design patterns for the COBOL, the next one on my list is the “Factory method” pattern.

    The pattern is useful, as it helps you hide the real implementation/creation mechanism of your classes. I you are fond of uml… here is the actual uml (from wikipedia).

    Factory Method Pattern from Wikipedia!

    So… lets see the COBOL code…


    interface-id. "Base".
    method-id. "DoIt".
    end method "DoIt".
    end interface "Base".

    class-id. "Derived1Impl".
    object. implements type "Base".
    method-id. "DoIt" public.
    display "Derived1Impl from DoIt".
    end method "DoIt".
    end object.
    end class "Derived1Impl".

    class-id. "Derived2Impl".
    object. implements type "Base".
    method-id. "DoIt" public.
    display "Derived2Impl from DoIt".
    end method "DoIt".
    end object.
    end class "Derived2Impl".

    class-id. "Factory".
    object.
    method-id. "GetObject".
    linkage section.
    01 obj-base type "Base".
    procedure division using by value oType as binary-long
    returning obj-base.

    evaluate oType
    when 1
    set obj-base to new type "Derived1Impl"()
    when 2
    set obj-base to new type "Derived2Impl"()
    when other
    set obj-base to null
    end method "GetObject".
    end object.
    end class "Factory".

    class-id. "FactoryDemo".

    method-id. "Main" static.
    local-storage section.
    01 obj-factory type "Factory".
    01 base-obj type "Base".

    linkage section.
    01 args string occurs any.
    procedure division using by value args.
    set obj-factory to new type "Factory"()

    set base-obj to obj-factory::"GetObject"(1)
    invoke base-obj::"DoIt"()

    set base-obj to obj-factory::"GetObject"(2)
    invoke base-obj::"DoIt"()

    end method "Main".
    end class "FactoryDemo".

    That was pretty straight forward… not too much pain…

    And finally the code produces…


    d:> FactoryDemo.exe
    Derived1Impl from DoIt
    Derived2Impl from DoIt
    Hello world

    Time to sign off for today.. but if you would like me to continue the series on code patterns or have a particular pattern you need… drop us a line!

    Dec 062009
     

    Some people think the UK National Lottery is a bit of a con and the prize money is a bit low.. but surely it can’t be this low!

    2009-12-06_1148

    I think this week I will give it a miss :-)

     

    Monitor’ing Java processes can be achieved using the jvmstat monitor classes provided in the JVM. The documentation is a bit sketchy but with a little experimenting it can be done.

    Below is a little example that shows you how to get a list of active Java processes.. which of course can then be used for other things :-)

    Here’s the code…


    import java.net.URISyntaxException;
    import java.util.Set;

    import sun.jvmstat.monitor.*;

    public class sjps
    {
    public static void main(String[] args)
    throws MonitorException, URISyntaxException
    {
    MonitoredHost monitoredHost = MonitoredHost.getMonitoredHost("localhost");
    Set activeVms = monitoredHost.activeVms();
    for (int psId : activeVms)
    {
    MonitoredVm monitoredVm = monitoredHost.getMonitoredVm
    (new VmIdentifier(String.valueOf(psId)));
    String mainClass = MonitoredVmUtil.mainClass(monitoredVm, false);
    String vmVersion = MonitoredVmUtil.vmVersion(monitoredVm);
    String commandLine = MonitoredVmUtil.commandLine(monitoredVm);
    System.out.println(mainClass + " [" + psId + "]" +
    " using : "+vmVersion);
    System.out.println(" -> "+commandLine);
    }
    }

    }

    And to see the code running..


    $ java sjps
    sjps [865] using : 14.1-b02-90
    -> sjps
    JConsole [863] using : 14.1-b02-90
    -> sun.tools.jconsole.JConsole

    Dec 052009
     

    While working on a project recently I need to find out the current process of the active running Java process (for tracing/auditing), however I never found a 100% perfect solution but did come across an acceptable solution to use the management classes to query its name, which happens to have encoding in it, so here is the quick solution:


    import java.lang.management.ManagementFactory;

    public class getpid
    {
    public static void main(String args[]) throws Exception
    {
    System.out.println("Process id : "+getProcessId());
    }

    public static long getProcessId()
    {
    String name = ManagementFactory.getRuntimeMXBean().getName();
    String[] nameBits = name.split("@");

    return nameBits == null ? -1 : Long.valueOf(nameBits[0]);
    }
    }


    $ java getpid
    Process id : 377

    Nov 292009
     

    As part of my working life I happy to say I use COBOL and for better or worse it is here to stay. With this in mind it annoys me I here/see saying things such as

    COBOL is a old language that naturally prohibits you from using modern design patterns.

    rubbish I say… COBOL can be used in good ways and bad ways.

    I will try and show you that COBOL can be used in a good way… lets take the “Singleton pattern“, as the first example.

    First.. lets start off my creating a singleton class in csharp… so here it is:


    using System.Collections;

    public sealed class MySingleton {
    private static readonly Hashtable sharedHashtable = new Hashtable();

    // Explicit static constructor to tell C# compiler
    // not to mark type as beforefieldinit
    static MySingleton() {
    }

    private MySingleton() {
    }

    public static Hashtable Singleton {
    get {
    return sharedHashtable;
    }
    }
    }

    Not too shabby.. but lets see what we can do in COBOL…


    $set ilusing"System.Collections"
    class-id. "MySingleton".

    01 shared-hashtable type "Hashtable"
    static property as "Singleton" with no set.

    method-id. "New" static.
    set shared-hashtable to new type "Hashtable"
    end method "New".

    What… COBOL is smaller… that can’t be true… sorry but it is…

    To complete the example… lets use it…


    *> Add two items to the single hashtable
    invoke type "MySingleton"::"Singleton"::
    "Add"("01234567","Ian")

    invoke type "MySingleton"::"Singleton"::
    "Add"("987654321","Stephen")

    *> Now get one of the items of the singleton
    display "Account 01234567 - Contains: "
    type "MySingleton"::"Singleton"::"Item"("01234567")

    And I am sure some people… will say sure… this is really true… it is… here is it running..


    c:temp> cobol MySingleton.cbl ilgen(sub);
    c:temp> cobol UseSingleton.cbl ilgen ilref"MySingleton.dll";
    c:temp> UseSingleton.exe
    Account 01234567 - Contains: Ian
    c:temp> csc MySingleton.cs /target:library
    c:temp> UseSingleton.exe
    Account 01234567 - Contains: Ian

    Now it seems to me that COBOL is being under rated… perhaps someone should shout about it! :-)

    [ad#Google Adsense-3]

    © 2012 The ramblings of a yorkshire tyke Suffusion theme by Sayontan Sinha