iModernize
Summer Edition

Profound Tips From Alex - Mixing Free and Fixed
By: Alex Roytman

I was working with a customer recently who was frustrated with mixing free format and fixed format code together. Even though he has transitioned to doing most of his coding in free format, there were still those times when fixed format came in handy, and the extra lines of code it takes to switch in an out of fixed were a nuisance. Essentially, to execute one line of fixed format code, you need 3 lines:

/End-Free
   Your Fixed Format Line
/Free


But since he was working in RPGsp, I let him know that this was not a problem. He was surprised to hear that you can actually execute fixed format code without ending a /Free section. In fact, you don't have to specify any /Free or /End-Free lines at all.

Many users don't realize this, but RPG code within RPGsp pages is a little more flexible compared to the RPG in traditional programs. All code is preprocessed before it is sent to the ILE RPG compiler, which gives RPGsp a chance to do a number of useful things for you, such as:

 Fix the order of your code. This means you can declare files and fields in sections of your program other than the very top, and RPGsp will send it in the correct order to the compiler. This can be useful since Web programs are not always coded in a top-down manner like traditional RPG.

 Provide a way to mix HTML (or XML) directly with RPG code, including conditional HMTL, repeating HTML, and HTML within subroutines or subprocedures.

 And last, but not least, insert /Free and /End-Free lines where they are missing.

So coding fixed and free format in the same RPGsp program might just be a little easier than you think, since you don't need to have special lines of code to switch between the two.

To post a comment on this article, please click here.

© 2009 Profound Logic Software, Inc. Search | Trademarks | Privacy Policy