Building files for Mosel
Data files generated for Mosel models must observe the same structure as the usual ascii Mosel format. For instance, consider the following data file in its ascii form:
a:123 b:[(1) 10]
The corresponding data stored in the binary format can be obtained with the following code:
bindrv_putctrl(bctx,BINDRV_CTRL_LABEL); bindrv_putstring(bctx,"a"); bindrv_putint(bctx,123); bindrv_putctrl(bctx,BINDRV_CTRL_LABEL); bindrv_putstring(bctx,"b"); bindrv_putctrl(bctx,BINDRV_CTRL_OPENLST); bindrv_putctrl(bctx,BINDRV_CTRL_OPENNDX); bindrv_putint(bctx,1); bindrv_putctrl(bctx,BINDRV_CTRL_CLOSENDX); bindrv_putint(bctx,10); bindrv_putctrl(bctx,BINDRV_CTRL_CLOSELST);
Note the use of control tokens to structure the data stream: a dedicated control code corresponds to each of the special characters in the ascii format. For example, the symbol '[' in the ascii format is represented by the code BINDRV_CTRL_OPENLST in the binary format.