Unfortunately there is no programmatic way to tell. Due to the limitation of this method, you can not automatically determine the number of trunk fields.
To calculate the number of trunks, first find out the maximum amount of data. Most applications encode a small amount of printable characters. In addition to the data, the target size is also a factor that needs to be taken into consideration. Some people prefer to seeing all bar codes having the same size, or some industries have a size requirement. After you have both information, enter them into data matrix encoder GUI and create a barcode. Calculate the number of characters in the encoder result. Do not forget each line requires two extra characters as new line indicator. Divide the number by 200 and round it up. For safety you may add 1 or 2 more trunks. It does not hurt - extra trunks contain empty string.
For example, suppose a typical data have the following encoding results:
55D559519 FA9B7819D 5D8A715EC 7AA799EAC DC68BC929 5F1E44258 D8B6118DD F1125A059 DEEDECDDD
The generated data matrix symbol has a matrix of 18 by 18. Converted to font characters, it is 9 by 9. Adding 2 extra character for each line, the result would be 11 by 9, total 99 characters. A trunk holds 200 characters. Therefore in this case, one trunk is sufficient for us to use.