• Welcome to World Machine Community. Please login or sign up.
 
April 23, 2019, 01:37:30 pm

News:

Read the Development Diary for an inside look at World Machine's progress!


Question: TextPacket output

Started by howardzzh, July 07, 2007, 08:36:25 pm

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

howardzzh

Hi everyone,
    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!

Howard

Stephen

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.
-- Stephen Schmitt
- Creator of World Machine

howardzzh

July 08, 2007, 10:08:12 pm #2 Last Edit: July 08, 2007, 10:16:51 pm by howardzzh
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.
Howard

Stephen

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.


-- Stephen Schmitt
- Creator of World Machine

howardzzh

Howard

Alexander

Just wanted to add that a lot of people are looking forward to your plugins Howard.  :D

howardzzh

Thank you, Alex. I just posted the first part of the plug-in series here, I will start working on the next part and hopefully, I can finish them before the WM Pro version comes out.
Howard

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it's been approved by a moderator.

Name:
Email:
Verification:
Please leave this box empty:
Type the letters shown in the picture
Listen to the letters / Request another image

Type the letters shown in the picture:

Shortcuts: ALT+S save/post or ALT+P preview