# RXS_ComposeVariable()

This searches the currently loaded template for the specified Variable, and replaces it with the Value parameter. If variable is used multiple times, all occurrences will be replaced.

**Note**: This procedure will throw an error if it has been called without the composition engine being initialized via [RXS_StartComposeEngine()](https://isupport.katointegrations.com/rxs/3.3/rxs_startcomposeengine.md).

## Subprocedure Prototype

### IBM i 6.1+

```rpgle
     D RXS_ComposeVariable...
     D                 PR                  Extproc('RXS_ComposeVariable')

      // The name of the variable to be replaced in the currently loaded
      //   template.
     D   Variable                    30A   Varying

      // The value which will replace the specified Variable.
     D   Value                             Const Like(RXS_Var16Mv_t)
```


## Example Code

### IBM i 6.1+

#### Example 1: Write a Template Variable
```rpgle
      *--------------------------------------------------------------
      * This example demonstrates calling RXS_ComposeVariable() to assign the 
      *  value of the gFahrenheit field to the template variable 'fahrenheit'. 
      *  This variable would be defined in the XML template EXAMPLE like so:
      *   <fahrenheit>.:fahrenheit:.</fahrenheit>
      *--------------------------------------------------------------
     H DFTACTGRP(*NO) BNDDIR('RXSBND') ACTGRP(*CALLER)

      /copy QRPGLECPY,RXSCB
      /copy QRPGLETPL,EXAMPLE

     D gFahrenheit     S              3P 1

      /free
       gFahrenheit = 78.6;

       RXS_ComposeVariable( fahrenheit : %Char(gFahrenheit) );

       *INLR = *ON;
      /end-free
```
