Passing Set Members with @POINTER
In the previous examples, when using the @POINTER function, we only passed attribute values back and forth. You may also pass set members using @POINTER, with the primary difference being that the set members are passed as ASCII text, as opposed to double precision numeric values. In addition, each set member is separated by a line feed (ASCII 10), with the end of the list of set members denoted with a null (ASCII 0) character.
In order to illustrate passing set members via @POINTER, we will modify the knapsack problem discussed above in section Binary Integer Example - The Knapsack Problem. You will recall that the data in a knapsack problem consists of the list of potential items to include in the knapsack, their weight, their utility/value, and the knapsack's capacity. We will pass all this data to LINGO via the @POINTER function, including the set of potential items. After solving the model, we will create a new set, derived from the original set of items, which contains only those items that are included in the optimal solution. Finally, we will use the @POINTER function to pass the optimal set of items back to our calling program so that we can display them for the user.
We will develop this example using the C programming language, however, the concepts should carry over in a straightforward manner to all other development environments. The code for this example may be found in the Programming Samples\VC++\Knapsack folder off the main LINGO directory.