Browse Prior Art Database

More Powerful Conditional Statements to Simplify Configuration Files

IP.com Disclosure Number: IPCOM000028633D
Original Publication Date: 2004-May-25
Included in the Prior Art Database: 2004-May-25
Document File: 3 page(s) / 44K

Publishing Venue

IBM

Abstract

A new programming command combines the test value of a conditional statement with the action to be performed, simplifying certain types of code, such as the build file used as an example.

This text was extracted from a PDF file.
This is the abbreviated version, containing approximately 53% of the total text.

Page 1 of 3

More Powerful Conditional Statements to Simplify Configuration Files

The common conditional programming statement IF tests a condition and routes execution according to the result. Depending on the condition, any number of following actions may be executed or skipped. This gives great flexibility. but is tedious and obscure for use in places where the action is obvious from the context and the number of conditions is great.

For example, consider the task of conditionally including a number of files into a larger file on the basis of previously set selections. When the only action performed is INCLUDE, the overhead of normal conditional commands complicates the code. Normally the program would assign a number or an arbitrary symbol to a variable called "selected" with one conditional clause following for each possible condition, such as:

INCLUDE "first_file.inc" IF(selected==1) INCLUDE "a_file.inc" IF(selected==2) INCLUDE "b_file.inc"
...

IF(selected==n) INCLUDE "n_file.inc" ELSE INCLUDE "def.inc" INCLUDE "third_file.inc"

The same may be done with a case statement: INCLUDE "first_file.inc" SWITCH(selected){ CASE 1: INCLUDE "a_file.inc"; break; CASE 2: INCLUDE "b_file.inc"; break;


...

CASE n: INCLUDE "n_file.inc; break; DEFAULT: INCLUDE "def.inc";

1

Page 2 of 3

the name of the file to be included. If "selected" has no value (NULL), then no PREPEND-INCLUDE is executed, which is equivalent to the code above without the ELSE or DEFAULT statements.

This considerable simplification is possible because nobody really cares about the actual values taken by "selected". That is, "1, 2,...n" were arbitrarily chosen for the programmer's convenience. Any sequence of values is suitable as long as they are distinct. Yet the code shown does nothing more than convert one set of distinct values, "selected", to another set of distinct values, the file names. The file names only differ by their prefixes, "a, b, .." . Let "selected" take these values. The stem of the filenames is identical to distinguish this set of files from others in the system.

For overal...