Another Way to Place Choice List Items in a Memory File

The example program showed how to prepare the menu with an editor and read it into a memory file with mf_rd(). Alternatively, you can code the choice list menu items and place them in a memory file with mf_rowrpl(). This will save you from having to provide a separate text file with your code.

Here is a fragment for preparing a simple menu in code using mf_rowrpl().

MFILEPTR mfp;

mfp = mf_def(8, 30);

mf_rowrpl("*FRUIT", 0, mfp);

mf_rowrpl("Avocados", 1, mfp);

mf_rowrpl("Bananas", 2, mfp);

mf_rowrpl("Cherries", 3, mfp);

mf_rowrpl("Grapes", 4, mfp);

mf_rowrpl("Lemons", 5, mfp);

mf_rowrpl("Oranges", 6, mfp);

mf_rowrpl("Peaches", 7, mfp);

The memory file is first defined and initialized by the call to mf_def(). The memory file will have eight rows of thirty characters each. The keyword is first placed in the memory file with a call to mf_rowrpl(). Subsequent calls to mf_rowrpl() place the specified strings in the rows of the memory file.

As an alternative to using multiple calls to mf_rowrpl(), you can repeatedly call cli_ins() for a memory file that only has one list and no keywords.

For more information on building memory files in code instead of using mf_rd(), see Chapter 45, "Creating and Viewing Memory Files."


Home Contents Previous Next