# A Little Help with the World's 3rd Simplest Code Generator

## RowNumber

``` This is row \$RowNumber ``` The RowNumber command can also be used in 'If' statements.

## 'If' Statements

Compare with a constant string value:

Equality

``` \$if \$7 = "varchar" then String \$end if ```

Inequality

``` \$if \$7 != "readonly" then set {_\$1 = value;} \$end if ```

Compare with a constant numeric value:

Equality

``` \$if \$7 = 2 then String \$end if ```

Inequality

``` \$if \$7 != 2 then set {_\$1 = value;} \$end if ```

Less Than

``` \$if \$7 < 5 then set {_\$1 = value;} \$end if ```

Greater than

``` \$if \$7 > 10 then set {_\$1 = value;} \$end if ```

Less Than Or Equal To

``` \$if \$7 <= 5 then set {_\$1 = value;} \$end if ```

Greater Than Or Equal To

``` \$if \$7 >= 10 then set {_\$1 = value;} \$end if ```

``` \$if \$RowNumber=4 Hiccup!\$endif \$1 ``` ``` \$if \$RowNumber!=1 ,\$endif \$1 ``` ``` \$if \$LastRow And that's the end....\$endif ``` ``` \$if Not \$LastRow And another thing...\$endif ``` ``` \$if !\$LastRow And another thing...\$endif ```

## Notes on If statements

Text values are enclosed in double quotes. Single quotes don't cut it.

You can't use Ands and Or's yet (maybe next version), but you can nest 'if' statements inside each other, to get the same effect.

And sorry, but there's no 'else' statement yet. Again, you can create two if statements and get the same effect.

(The word 'then' is optional. Leave it off if you prefer. 'Endif' or 'End if': either is fine. Commands are not case-sensitive.)

You can also use the RowNumber command with an If statement. For example, this pattern...

... creates a nice comma separated list of just the first column of your data, that DOESN'T include the extra comma you would be used to seeing if you've used earlier version of the generator.

### Loops

The coolest new feature is 'Loops Mode', which is turned off by default. (Click the checkbox to turn it on)

In loops mode you can have multiple 'ForEach Row' statements.

For example:

Say you want a pattern that declares a bunch of variables, then exposes them as properties... you need two loops!

``` #region private declarations \$ForEach Row   private \$2 _\$1; \$Next #end region #region public properties \$ForEach Row   public \$2 \$1   {     get { return _\$1; }     set { _\$1 = value; }   } \$Next #end region ```

Using this feature you can write a whole data access layer, or get some pretty powerful stuff happening. The united nations want me to ban this feature. But I'm not backing down on it.

Using an if inside a ForEach loop is a pretty nifty trick, bound to impress the ladies:

``` #Region private declarations \$ForEach Row   private \$2 _\$1; \$Next #end region #Region public properties \$ForEach Row   public \$2 \$1   {     get { return _\$1; } \$if \$3 != "readonly"     set { _\$1 = value; } \$endif  } \$Next #end region ```

Comments begin with \$Comment. You can also use \$Rem, or \$// or \$--.

``` \$// \$1 is the variable name, e.g. 'Height', 'Age' \$// \$2 is the type, e.g. String #Region private declarations \$ForEach Row   private \$2 _\$1; \$Next #end region #Region public properties \$ForEach Row   public \$2 \$1   {     get { return _\$1; }     set { _\$1 = value; }   } \$Next #end region ```

### XML and XSL

But the fun thing is, it allows you to see the XML and XSL that is generated.

In fact, some people might use the generator for creating XSL in a hurry.

Writing XSL by hand is not fun at all. For example the "\$1" command in 'Pattern language' is replaced by this monster in XSL:

``` <xsl:value-of select="field[@number=1]"/> ```

## Flexible

There's also a lot of 'options' provided, to make the tool more flexible.

If you paste data in from Excel, or from a grid, it will probably have tabs delimiting each column. To handle for this, type '\t' into the 'column delimiter' text box. (There's tool-tip help that reminds you of this.)

Say each row of your data is delimited by pipe characters: just type that into the 'row delimiter' text box.

You don't like using the "\$" symbol to denote commands? Use any character you like, specify it as the "Code Symbol Prefix". You can even specify a character to mark the end of each command.

## Input Options

• Delimiters
• Trim
• Ignore First Row
• ## Pattern Options

• Delimiters
• Trim
• Ignore First Row