A number of you have sent me email suggesting that if you could just see a short, simple working CGI program, it would help so much in getting started.
Emphasis on the word "simple" is what the problem has been. Most "simple" examples seem to have gotten a bit complicated.
Nonetheless, here is a simple CGI program that will display the show times for a specific movie, given a Movie ID (key value). I've also included the HTML for the SHOWTM.HTML file that this CGI program reads and sends to the browser. The folder location name /MOVIES may be different on your machine, or you can create MOVIES and put the HTML in there. This technique does use HTML stored on the IFS.
This CGI program requires the CGILIB, which is part of the RPG xTools. It can also be easily converted to use the popular CGIDEV2 library by changing the /COPY and the CGI procedure names.
FMDB IF E K DISK
F
/COPY XTOOLS/QCPYSRC,CGI
D html S 256A Inz('/movies/showtm.html')
C Callp cgiInit()
C
C Movie KLIST
C KFLD MID
C eval MID = cgiGetVar('MID')
C callp cgiLoadHtmlIFS(html)
C Movie Chain MDB
C if %Found()
C callp cgiSetVar('TITLE':MTITLE)
C callp cgiWrtSection('*TOP')
C Dou %EOF()
C callp cgiSetVar('PLAYTIME': %Char(MTIME))
C callp cgiWrtSection('SHOWTIME')
C Movie READE MDB
C enddo
C callp cgiWrtSection('THERESTOFTHEHTML')
C callp cgiWrtSection('*END')
C eval *INLR = *ON
C
The HTML source is as follows:
The remaining show times for the movie:
/%MOVIETITLE%/ are as follows:
/$SHOWTIME
/$TheRestOfTheHTML
Bob Cozzi is a programmer/consultant, writer/author, and software developer. His popular RPG xTools add-on subprocedure library for RPG IV is fast becoming a standard with RPG developers. His book The Modern RPG Language has been the most widely used RPG programming book for more than a decade. He, along with others, speaks at and produces the highly popular RPG World conference for RPG programmers.



Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.
IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn:
LATEST COMMENTS
MC Press Online