code

Show posts with tag  
displaying page 1 of 2

PHP rocks!

uploaded image

PHP is just a great, simple, and forgiving language.  It's intuitive, especially for anybody that has coded in Java and has any experience with HTML.  Unlike Java though, it is not as demanding or OO-dependent.

PHP is part scripting language and part sophisticated, object-oriented language.  It's flexible enough to allow for speedy development in a top-down, loose style.  But at the same time, it provides the ability to create classes and functions, allowing one to take a modular approach.

I've been coding in PHP for a couple of years now as a hobby and skill-building exercise, and now I've started getting paid for it.

At the Peppermill I am doing both sides of the applications I am writing, the client side (Zend PHP) and the server side (RPG on i5).  PHP calling RPG and, believe it or not, RPG calling PHP!

It's the best of both worlds.

links:
0 comments | add comment | email link

RPG: Using a subprocedure as an indicator.

A friend of mine at work gave me the idea of posting coding tips and techniques, or "cheats" as she put it.  ;) I liked the idea, so my first will be an RPG ILE tip for the System i: using a subprocedure as a indicator.

One of the great things about subprocedures in RPG ILE--and there are many--is being able to use its return value in an expression.  This technique allows for some handsome code.  In this post, I will demonstrate how to define and use a subprocedure which returns an indicator type variable.

First, the prototype.  "Things_R_Good" is an example of a validation routine.  Notice the "N" in the data type column, and the absence of any length.

      //-----------------------------------------------------
      //  Verify that things are good
      //-----------------------------------------------------
     D Things_R_Good   PR              N

Now, the subprocedure.  The way this works is that normal validation will occur, and when there are any issues, the local variable "got_error" is set on.  As we know that things are NOT good if we got an error, we return the opposite of "got_error" at the end of the subproc.

      //-----------------------------------------------------
      //  Things_R_Good - Verify that things are good
      //-----------------------------------------------------
     PThings_R_Good    B
     D                 PI              N

      // Local variables
     D got_error       S               N

      /Free

       // Do the validation
       ...

       Return not got_error;

      /End-free

     PThings_R_Good    E

What happens is when got_error = *ON, we return *OFF, and vice versa.  Then we use the subprocedure in the mainline, or other subprocedure, as follows.

       // If everything is good, continue processing.
       If Things_R_Good();
         ...
       EndIf;

Notice that because the subprocedure was named as it was the code becomes extremely readable: "if things are good".

0 comments | add comment | email link

CB/400 - A native i5 chat app

cb/400 is the ultimate chat program for the iSeries (AS/400). It is modeled after Citizens Band radio.

features

  • 40 public channels
  • Private Line (one-on-one) messages
  • Colors and attributes
  • Ignore user capabilities
  • Automatic notification/installation of new versions!
  • Supports two screen modes: 24x80 and 27x132
  • Objects exist in personal libraries (for stealth)

screenshot

cb/400 screenshot

requirements

  • OS/400 V4R3 or higher
  • Each user must have a unique user profile.
  • Each user must have a personal library (same as user profile).
  • The cb/400 objects (5) must be restored to the personal library of each cb/400 user.

installation instructions

  • Download the save file to a temporary directory (c:\temp will be used in the example).
  • Create a save file named CB400 on the AS/400 in the library of your choice (QGPL will be used in the example).
        CRTSAVF FILE(QGPL/CB400)
    
  • Open a DOS window and change the directory to the temporary directory.
        cd c:\temp
    
  • In the same DOS window, use the 'ftp' command to send cb400.svf to CB400 on the AS/400.  Be sure to use the 'bin' command to change to binary mode. Here is a sample FTP session:
        C:\temp> ftp dev400
    
        Connected to dev400.
        220-QTCP at AS400.
        220 Connection will close if idle more than 5 minutes.
        User (192.168.1.123:(none)): userid
    
        331 Enter password.
        Password: XXXXX
    
        230 USERID logged on.
        ftp> bin
    
        200 Representation type is binary IMAGE.
        ftp> put cb400.svf qgpl/cb400
    
        200 PORT subcommand request successful.
        150 Sending file to member SAVF in file CB400 in library QGPL.
        250 File transfer completed successfully.
        (958848 bytes sent in 19.82 seconds 48.39 Kbytes/sec)
        ftp> quit
    
        221 QUIT subcommand received.
    
  • On the AS/400, restore the objects into the library of each user to run CB/400.
        RSTLIB SAVLIB(CB400) DEV(*SAVF) SAVF(QGPL/CB400) RSTLIB(userlib)
    
  • Each user may then run CB/400 out of his/her own library by entering the command CB.
  • If you currently have a version higher than 1.002, you only need to restore objects CB400R, CB400D and CB400DW to one of the user libraries. cb/400 running from other libraries will recognize the new version and follow the installation settings in each user's personal options.
links:
0 comments | add comment | email link

MineSweepMania

MineSweepMania is the old MineSweeper game on steriods.  It should run on any personal computer or mac where java is installed.

features

  • 3 preset boards: Beginner, Intermediate, and Expert.
  • Custom board: make your own!
  • 3 modes: Normal, Record Breaker, and Insanely Unfair.
  • Sound effects, which can be turned off.

screenshot

cb/400 screenshot

requirements

  • Java Runtime Environment

installation instructions

  • Download the jar file then open it.
links:
0 comments | add comment | email link

I dig PHP

I originally created this blog using the open source blog app, WheatBlog.  It's a nice clean app with a minimum of code to get the job done.  But, I still had to make some mods to have it fit into the structure of my site.

Enter: PHP.

I didn't know the language before but it was super easy to learn.  It's syntax is similar to Java, which I already knew, so I was able to understand it with no problem.  That, plus I knew SQL so using MySQL in conjunction was a breeze.

I was able to replace the single category per post logic in the blog app with multiple tags, and then create the tag cloud. Now I've got that coding bug (no.. not that kind of bug, the "jones'ing" kind of bug) and I really want to redo the entire site in PHP.

Definitely more to come...

links:
0 comments | add comment | email link
displaying page 1 of 2