today
Oct 16, 2018 6:27 UTC
visitors:   40
search with google   
  
Site surfing
Home
Tools
Documentation
Code snippets
Links
Subscribers
Testimonials
Login

Last updates
Suggestions
Easy400Group forum
 
Code snippets

Sometimes, while supporting my customers, I happen to write some code that could be useful to other people.
Why not share it?

 

1.  JavaScript & HTML
2.  ILE-RPG

 

1. Javascript & HTML
  1. Clock
    A small demo on the basic Javascript setInterval() method. A setInterval() of one second is used to display the computer clock value. Run it, display its source.
  2. Stopwatch
    A more complex demo still on Javascript setInterval() method. This demo also demonstrates the use of round-up instructions, mathematics functions Math.ceil() and Math.floor(). Run it, display its source.
  3. Page disabling
    When you develop a web page containing several buttons and/or links and the response time of a submitted form may take several seconds to respond, you can easily see the user pressing other buttons or links just to find out if anything is going on. In such a case, you would rather disable all buttons and links, while waiting for the response from the submitted transaction.
    This demo shows how you can implement this, by using some general Javascript that
    • disables all the buttons and all the links in the page
    • greys out the screen
    • pops up a "please wait" sign.
    To make it work, you must just assign a unique id to each form element (<form>, <input>, <select>, <textarea>, <button>, etc.) and to each anchor (<a ...>).
    Please note that in the demo no transaction is actually submitted, so that the wait message stays there for ever.
    Run the demo, display its source.
  4. Displaying totals on the top of a page
    This is a very common case. Your program reads some database file and writes the rows of an HTML table. Totals are available only after the last input record has been read. How to make the totals available on the top of the page (before the beginning of the table)?
    A possible solution is:
    • write the totals in some hidden input fields after the end of the table
    • define some readonly input fields before the beginning of the table
    • have an onLoad function copying the values of the bottom hidden fields into the top readonly fields.
    Run the example, display its source.
  5. Text scrolling utility lineScroll.js
    Though apparently superseded by new JQuery tools, this technique of scrolling a text line - moving letters right to left - stills appears to be one of the best in attracting readers attention. Something you may have seen in Times Square, NY City, US.
    Have a look at this example of my scrolling utility lineScroll.js.
    Basically, it picks up - from a WEB page - a character string from a given input html element ID (example: a <input type="hidden" id="xxx" value="..."> element) and makes it horizontally flowing in a given output html element (example: a <span id="yyy">...</span> element).
    1. From my text scrolling demo download file lineScroll.zip, unzip it and upload file lineScroll.js to an IFS directory that can be access from your HTTP instance.
    2. In a WEB page of yours include the following statement:
      <script src="/path/lineScroll.js"></script>
      where /path is the IFS path to the directory where you have put the stream file lineScroll.js.
    3. In that WEB page of yours, add a form with an input hidden field containing the input text to be shown in scroll mode. This text can be static or dynamically filled in at execution time. Provide this input field with an ID.
    4. Next, add another ID-identified HTML element, where the scrolled text should appear.
    5. To start the text scrolling, call this function:
      strLineScroll("p1","p2","p3","p4","p5","p6","p7")
      where
      • p1 is the id of the html element containing the input text (example: "inStr")
      • p2 is the id of the html element that will contain the scrolled output text (example: "outStr")
      • p3 is the length (number of characters) of the output scrolled string (example: "85")
      • p4 is the number of millisecond to wait before starting the scrolling (example: "2000" , that is 2 seconds)
      • p5 is the number of milliseconds between two consecutive character scrolls (example: "150"). Lower this value to increase the scrolling speed. Increase this value to slow down the scrolling speed.
      • p6 is the number of milliseconds between two consecutive string scroll iterations (example: "5000" , that is 5 seconds)
      • p7 is the number of string scroll iterations that must be performed (e.g. "999999" for a never ending case, "2" for just 2 iterations)
      You may call function strLineScroll(...)
      • at page load time (e.g. <body onLoad=strLineScroll(...)>),
      • or through some other event control (example: a button click).
      If you wish, in your WEB page you may also add buttons calling some other functions:
      • pauseLineScroll(). The first time this function is called, it freezes the scrolling. The next time it is called, it releases the scrolling.
      • endLineScroll(). It ends the scrolling. To restart the scrolling, function strLineScroll(...) must be called again.
      • clrLineScroll(). It ends the scrolling and clear the output string. To restart the scrolling, function strLineScroll(...) must be called again.
    Note. To get a full understanding of the whole works, please run my text scrolling demo and display its source.

 

2. ILE-RPG

  1. XML EMERGENCY PUMP TO STREAM FILE

    More and more often I'm asked to support an urgent need of providing an IFS stream file containing a XML script.
    Usually this is someone who stumbled on an article suggesting - for that need - to use CGIDEV2 procedure WrtHtmlToStmf().

    Does it really take a Kung Fu artist to crack a walnut?

    We are talking about an RPG programmer who does not know how to create, open and write to an IFS stream file.
    Instead of teaching him how to do it, they are pushing him to use a CGI technique conceived for WEB development, just because that technique allows by chance to save a script to an IFS stream file.
    Would it not be wiser to suggest to spend a few hours on the splendid Scott Klement's tutorial Working with the IFS in RPG IV?

    Yes, there might be cases where the need is so urgent that there is no time for a quick walk through Scott's material.
    However, if you were able to write a simple RPG program that generates the XTML script on a flat database file
    and if you had a command to copy that file to a stream file, the problem could be easily solved.

    No such command available? Get it here. It is named F_TO_STMF (File To STMF). Just install and compile the following sources:

    1. Command F_TO_STMF
    2. Panel group F_TO_STMF
    3. ILE-RPG program F_TO_STMF

 

 
 
This site is owned by
Giovanni B. Perotti

Worked 39 years for IBM Italy. Started with OS/360, went through 370, enjoyed System/38 and landed on the greatest system of them all: AS/400. I was used to play two roles, manager and professional at the same time.
In year 1997 I got a major stroke when I discovered the easy way to make WEB from some Mel Rothman's work, CGIDEV. That day I started a mission: enable AS/400 programmers to build WEB sites using their existing knowledge.
After retiring in year 2005 I decided to carry on with my own site. Since then I've got more recognition than I ever had before.

contact Giovanni Contact Giovanni.