I encounted an linking error while outputing a TextPacket from a device that I am creating. The error message said that void TextPacket::setText(const char *txt) is an undefined reference. I wonder if it's because the library file wasn't included in the PDK or if the function is not defined yet.
I've temporarily bypassed this problem by defining my own inline function in the TextPacket.h to overide the default setText.
inline void TextPacket::setText(const std::string& txt)
int len = txt.length();
body = new char[len+1];
memcpy(body, txt.c_str(), len);
body[len] = NULL;
However, I could not get the "Text Output" device (which is hooked to the text output of my device) to write a file to the disk. There is no error or warning, just that the "Write output to disk" didn't do anything. Also, after the device is built, it will result an exception whenever I want to switch to either the "Layout view" or the "Explorer view". The device behaves fine if I just swith between the other views.
I wonder if I missed anything here. I would really appreciate your help if you've had similar experience. Thank you!
The text packet body text must be allocated from the WM Core's heap, otherwise there will be potential problems across DLL boundaries. Use WMAlloc() and WMFree() to allocate/delete text.
The Text Output device should output text to the file you specified if the above is correct.
Thank you Remnant.
After using WMAlloc() to allocate the memory for the TextPacket body, I no longer get any exception from switching between different views. However, I still have two questions.
1. Was the function "void TextPacket::setText(const char *txt)" defined in the libraries included in the PDK? The reason I ask this question is because it showed up as an undefined reference for me when I built my device. That's why I have to write my own setText function which is probably incorrect. I would like to use the official version if somehow I just missed.
2. I probably used the text output device in an incorrect way since I still could not get it to write any text to a file.
Here is how I added a second output port in the constructor
AddPort(0, 1, WMP_text, -1);
Here is how I tried to store the data to the output
bool PluginPPA::Activate(BuildContext &context)
StoreData(txtBranchPoints, 1, context);
I also tried to simply link the "Text input" device to the "Text output" device and could not get it to output a text file. What I did was to link it to a text output port, build the whole thing, specify the output filename, and then click the "Write ouput to disk!". I wonder if I did anything wrong with the "Text output" device. Thank you for the help.
Yes.. I just looked into it, and TextOutput output was temporarily disabled. Text I/O is there on a "might be useful" basis rather than being actively used by WM devices right now, so its definitely off of the high traffic code path and I didn't notice. Fixed.
Thank you for clarifying this.
Just wanted to add that a lot of people are looking forward to your plugins Howard. :D
Thank you, Alex. I just posted the first part of the plug-in series here (http://forum.world-machine.com/index.php?topic=765.0), I will start working on the next part and hopefully, I can finish them before the WM Pro version comes out.