Who owns what #2

View: New views
12 Messages — Rating Filter:   Alert me  

Who owns what #2

by Christian Sakowski :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Question 1:

If i call:

PA_Unistring PA_GetApplicationFullPath()

Do i have to call "PA_DisposeUnistring"?
--

Grüße/Regards,
[heubach-media] | Christian Sakowski
Christian.sakowski@...
iChat/AIM: SakowskiF
ICQ: 4thDimension (267537916)
Tel: 040/52 10 59-23



**********************************************************************
4D Plugins hosted by 4D, Inc.                      http://www.4D.com/

    Register for 4D Summit 2009 Today
    Early Bird Pricing Ends August 28th - http://www.4D.com/summit

To Unsubscribe:                      mailto:4D-Plugins-off@...
***********************************************************************


Re: Who owns what #2

by Christian Sakowski :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Question 2:

void PA_SetUnistring( PA_Unistring* ustr, PA_Unichar* str )

Who owns the "PA_Unichar* str"? I think me!? I have to dispose the  
unsigned short array?

--

Grüße/Regards,
[heubach-media] | Christian Sakowski
Christian.sakowski@...
iChat/AIM: SakowskiF
ICQ: 4thDimension (267537916)
Tel: 040/52 10 59-23



Am 30.07.2009 um 14:56 schrieb Christian Sakowski:

**********************************************************************
4D Plugins hosted by 4D, Inc.                      http://www.4D.com/

    Register for 4D Summit 2009 Today
    Early Bird Pricing Ends August 28th - http://www.4D.com/summit

To Unsubscribe:                      mailto:4D-Plugins-off@...
***********************************************************************


RE: Who owns what #2

by Laurent Esnault :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>>If i call:
>>PA_Unistring PA_GetApplicationFullPath()
>>Do i have to call "PA_DisposeUnistring"?

yes

L.E.
**********************************************************************
4D Plugins hosted by 4D, Inc.                      http://www.4D.com/

    Register for 4D Summit 2009 Today
    Early Bird Pricing Ends August 28th - http://www.4D.com/summit

To Unsubscribe:                      mailto:4D-Plugins-off@...
***********************************************************************


RE: Who owns what #2

by Laurent Esnault :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>>void PA_SetUnistring( PA_Unistring* ustr, PA_Unichar* str )
>>Who owns the "PA_Unichar* str"? I think me!?
>>I have to dispose the unsigned short array?

'str' is copied and its ownership is not changed.
If you were the owner before the call, you are still the owner after the
call and should dispose your string after use.

L.E.
**********************************************************************
4D Plugins hosted by 4D, Inc.                      http://www.4D.com/

    Register for 4D Summit 2009 Today
    Early Bird Pricing Ends August 28th - http://www.4D.com/summit

To Unsubscribe:                      mailto:4D-Plugins-off@...
***********************************************************************


Re: Who owns what #2

by Christian Sakowski :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thank you. Now it's clear.

I have an other question. I would like to pass a Text back in the  
parameter 2:

command(&L;&T):L

I have to following lines:

PA_Variable variable;
PA_Unistring unistring;
       
unistring=this->GetUnistring(); //the value is valid/i saw it in the  
debugger
       
variable=PA_GetVariableParameter(params,index);
PA_SetStringVariable(&variable,&unistring);
PA_SetVariableParameter(params,index,variable,false);

--

After the call and my routine goes back to 4D, 4D crashes. Why? I saw,  
that there is no "PA_SetTextParameter", right?


--

Grüße/Regards,
[heubach-media] | Christian Sakowski
Christian.sakowski@...
iChat/AIM: SakowskiF
ICQ: 4thDimension (267537916)
Tel: 040/52 10 59-23



Am 31.07.2009 um 18:34 schrieb Laurent Esnault:

>>> void PA_SetUnistring( PA_Unistring* ustr, PA_Unichar* str )
>>> Who owns the "PA_Unichar* str"? I think me!?
>>> I have to dispose the unsigned short array?
>
> 'str' is copied and its ownership is not changed.
> If you were the owner before the call, you are still the owner after  
> the
> call and should dispose your string after use.
>
> L.E.
> **********************************************************************
> 4D Plugins hosted by 4D, Inc.                      http://www.4D.com/
>
>    Register for 4D Summit 2009 Today
>    Early Bird Pricing Ends August 28th - http://www.4D.com/summit
>
> To Unsubscribe:                      mailto:4D-Plugins-off@...
> ***********************************************************************
>
>

**********************************************************************
4D Plugins hosted by 4D, Inc.                      http://www.4D.com/

    Register for 4D Summit 2009 Today
    Early Bird Pricing Ends August 28th - http://www.4D.com/summit

To Unsubscribe:                      mailto:4D-Plugins-off@...
***********************************************************************


Re: Who owns what #2

by Christian Sakowski :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thank you. Now it's clear.

I have an other question. I would like to pass a Text back in the  
parameter 2:

command(&L;&T):L

I have to following lines:

PA_Variable variable;
PA_Unistring unistring;
       
unistring=this->GetUnistring(); //the value is valid/i saw it in the  
debugger
       
variable=PA_GetVariableParameter(params,index);
PA_SetStringVariable(&variable,&unistring);
PA_SetVariableParameter(params,index,variable,false);

--

After the call and my routine goes back to 4D, 4D crashes. Why? I saw,  
that there is no "PA_SetTextParameter", right?
--

Grüße/Regards,
[heubach-media] | Christian Sakowski
Christian.sakowski@...
iChat/AIM: SakowskiF
ICQ: 4thDimension (267537916)
Tel: 040/52 10 59-23



Am 31.07.2009 um 18:34 schrieb Laurent Esnault:

>>> void PA_SetUnistring( PA_Unistring* ustr, PA_Unichar* str )
>>> Who owns the "PA_Unichar* str"? I think me!?
>>> I have to dispose the unsigned short array?
>
> 'str' is copied and its ownership is not changed.
> If you were the owner before the call, you are still the owner after  
> the
> call and should dispose your string after use.
>
> L.E.
> **********************************************************************
> 4D Plugins hosted by 4D, Inc.                      http://www.4D.com/
>
>    Register for 4D Summit 2009 Today
>    Early Bird Pricing Ends August 28th - http://www.4D.com/summit
>
> To Unsubscribe:                      mailto:4D-Plugins-off@...
> ***********************************************************************
>
>

**********************************************************************
4D Plugins hosted by 4D, Inc.                      http://www.4D.com/

    Register for 4D Summit 2009 Today
    Early Bird Pricing Ends August 28th - http://www.4D.com/summit

To Unsubscribe:                      mailto:4D-Plugins-off@...
***********************************************************************


RE: Who owns what #2

by simonbesner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Christian,

I use the CString class to handle the text parameters.  I know it might not
exactly what you are looking for but it might help you.

Here's the 2 functions I use to handle the text parameters:

void CStringToPAUnistring (CString* sourceCString, PA_Unistring*
destinationPAUnistring){
       
        PA_Unichar* tempUnichar = PA_GetUnistring(destinationPAUnistring);
        wchar_t* tempWChar = new wchar_t[sourceCString->GetLength()+1];

        wcscpy(tempWChar, sourceCString->GetBuffer(0));
        tempUnichar = (PA_Unichar*)tempWChar;

        PA_SetUnistring(destinationPAUnistring, tempUnichar);
       
        delete [] tempWChar; // Important, otherwise we get a memory leak.

}

void PAUnistringToCString (PA_Unistring* sourcePAUnistring, CString*
destinationCString){
       

        if (PA_GetUnistringLength (sourcePAUnistring)==0){
                destinationCString->Empty();
        }else{
                PA_Unichar* tempUnichar =
PA_GetUnistring(sourcePAUnistring);
                wchar_t* tempWChar = new
wchar_t[PA_GetUnicharsLength(tempUnichar)+1];

                wcscpy(tempWChar, (wchar_t*)tempUnichar);
                *destinationCString = tempWChar;

                delete [] tempWChar; // Important, otherwise we get a memory
leak.
        }
}


simon

-----Original Message-----
From: 4D-Plugins@... [mailto:4D-Plugins@...] On Behalf Of
Christian Sakowski
Sent: 4 août, 2009 17:30
To: 4D Plugin Talk
Subject: Re: Who owns what #2

Thank you. Now it's clear.

I have an other question. I would like to pass a Text back in the  
parameter 2:

command(&L;&T):L

I have to following lines:

PA_Variable variable;
PA_Unistring unistring;
       
unistring=this->GetUnistring(); //the value is valid/i saw it in the  
debugger
       
variable=PA_GetVariableParameter(params,index);
PA_SetStringVariable(&variable,&unistring);
PA_SetVariableParameter(params,index,variable,false);

--

After the call and my routine goes back to 4D, 4D crashes. Why? I saw,  
that there is no "PA_SetTextParameter", right?
--

Grüße/Regards,
[heubach-media] | Christian Sakowski
Christian.sakowski@...
iChat/AIM: SakowskiF
ICQ: 4thDimension (267537916)
Tel: 040/52 10 59-23



Am 31.07.2009 um 18:34 schrieb Laurent Esnault:

>>> void PA_SetUnistring( PA_Unistring* ustr, PA_Unichar* str )
>>> Who owns the "PA_Unichar* str"? I think me!?
>>> I have to dispose the unsigned short array?
>
> 'str' is copied and its ownership is not changed.
> If you were the owner before the call, you are still the owner after  
> the
> call and should dispose your string after use.
>
> L.E.
> **********************************************************************
> 4D Plugins hosted by 4D, Inc.                      http://www.4D.com/
>
>    Register for 4D Summit 2009 Today
>    Early Bird Pricing Ends August 28th - http://www.4D.com/summit
>
> To Unsubscribe:                      mailto:4D-Plugins-off@...
> ***********************************************************************
>
>

**********************************************************************
4D Plugins hosted by 4D, Inc.                      http://www.4D.com/

    Register for 4D Summit 2009 Today
    Early Bird Pricing Ends August 28th - http://www.4D.com/summit

To Unsubscribe:                      mailto:4D-Plugins-off@...
***********************************************************************


**********************************************************************
4D Plugins hosted by 4D, Inc.                      http://www.4D.com/

    Register for 4D Summit 2009 Today
    Early Bird Pricing Ends August 28th - http://www.4D.com/summit

To Unsubscribe:                      mailto:4D-Plugins-off@...
***********************************************************************


Re: Who owns what #2

by Christian Sakowski :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

So the PA_SetVariableParameter does NOT work with text (->crash),  
there is a "workaround". Maybe 4D can add this as  
PA_SetStringParameter():

PA_Unichar* unichar;
unichar=this->GetUniCharPtr();
       
PA_SetUnistring((((PA_Unistring**) params->fParameters)[ index - 1 ]),  
unichar );

This works very well.
--

Grüße/Regards,
[heubach-media] | Christian Sakowski
Christian.sakowski@...
iChat/AIM: SakowskiF
ICQ: 4thDimension (267537916)
Tel: 040/52 10 59-23



Am 04.08.2009 um 23:30 schrieb Christian Sakowski:

> Thank you. Now it's clear.
>
> I have an other question. I would like to pass a Text back in the  
> parameter 2:
>
> command(&L;&T):L
>
> I have to following lines:
>
> PA_Variable variable;
> PA_Unistring unistring;
>
> unistring=this->GetUnistring(); //the value is valid/i saw it in the  
> debugger
>
> variable=PA_GetVariableParameter(params,index);
> PA_SetStringVariable(&variable,&unistring);
> PA_SetVariableParameter(params,index,variable,false);
>
> --
>
> After the call and my routine goes back to 4D, 4D crashes. Why? I  
> saw, that there is no "PA_SetTextParameter", right?
> --
>
> Grüße/Regards,
> [heubach-media] | Christian Sakowski
> Christian.sakowski@...
> iChat/AIM: SakowskiF
> ICQ: 4thDimension (267537916)
> Tel: 040/52 10 59-23
>
>
>
> Am 31.07.2009 um 18:34 schrieb Laurent Esnault:
>
>>>> void PA_SetUnistring( PA_Unistring* ustr, PA_Unichar* str )
>>>> Who owns the "PA_Unichar* str"? I think me!?
>>>> I have to dispose the unsigned short array?
>>
>> 'str' is copied and its ownership is not changed.
>> If you were the owner before the call, you are still the owner  
>> after the
>> call and should dispose your string after use.
>>
>> L.E.
>> **********************************************************************
>> 4D Plugins hosted by 4D, Inc.                      http://www.4D.com/
>>
>>   Register for 4D Summit 2009 Today
>>   Early Bird Pricing Ends August 28th - http://www.4D.com/summit
>>
>> To Unsubscribe:                      mailto:4D-Plugins-off@info.
>> 4D.com
>> ***********************************************************************
>>
>>
>
> **********************************************************************
> 4D Plugins hosted by 4D, Inc.                      http://www.4D.com/
>
>   Register for 4D Summit 2009 Today
>   Early Bird Pricing Ends August 28th - http://www.4D.com/summit
>
> To Unsubscribe:                      mailto:4D-Plugins-off@...
> ***********************************************************************
>
>

**********************************************************************
4D Plugins hosted by 4D, Inc.                      http://www.4D.com/

    Register for 4D Summit 2009 Today
    Early Bird Pricing Ends August 28th - http://www.4D.com/summit

To Unsubscribe:                      mailto:4D-Plugins-off@...
***********************************************************************


Re: Who owns what #2

by Rob Laveaux :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On 6 aug 2009, at 21:34, Christian Sakowski wrote:

> So the PA_SetVariableParameter does NOT work with text (->crash)

No, because the data in the parameter block is not a PA_Variable. Just  
look at the source code of the plugin API. It helps you to understand  
the inner workings. Then you will see that all the PA_GetxxxParameter  
all do a typecast.

> , there is a "workaround". Maybe 4D can add this as  
> PA_SetStringParameter():

It's not a workaround. It's the way it was designed. You have to call  
PA_GetStringParameter followed by PA_SetUnistring.

It's a shame that 4D does not deliver the update documentation for the  
plugin SDK that was once written. This would answer some of the  
questions posted here.

In case anyone needs it, you can download it here:
http://www.pluggers.nl/downloads/4D%20Plugin%20SDK%20v11.pdf

HTH,

- Rob Laveaux

--------------------------------------------------------
Pluggers Software
Bleriotlaan 62
2497 BM  Den Haag
The Netherlands

Email: rob.laveaux@...
Website: http://www.pluggers.nl

--------------------------------------------------------


**********************************************************************
4D Plugins hosted by 4D, Inc.                      http://www.4D.com/

    Register for 4D Summit 2009 Today
    Early Bird Pricing Ends August 28th - http://www.4D.com/summit

To Unsubscribe:                      mailto:4D-Plugins-off@...
***********************************************************************


Re: Who owns what #2

by Christian Sakowski :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> It's not a workaround. It's the way it was designed. You have to  
> call PA_GetStringParameter followed by PA_SetUnistring.

You're right. I see the documentation in the code:

// Use PA_SetUnistring or PA_GetUnistring to set or read the parameter  
content

Now i have the following:

PA_Unistring* unistring;
PA_Unichar* unichar;

unichar=this->GetUniCharPtr();

unistring=PA_GetStringParameter(params,index);
PA_SetUnistring(unistring,unichar);


Thank you for the hint, Rob!
--

Grüße/Regards,
[heubach-media] | Christian Sakowski
Christian.sakowski@...
iChat/AIM: SakowskiF
ICQ: 4thDimension (267537916)
Tel: 040/52 10 59-23



Am 06.08.2009 um 21:50 schrieb Rob Laveaux:

>
> On 6 aug 2009, at 21:34, Christian Sakowski wrote:
>
>> So the PA_SetVariableParameter does NOT work with text (->crash)
>
> No, because the data in the parameter block is not a PA_Variable.  
> Just look at the source code of the plugin API. It helps you to  
> understand the inner workings. Then you will see that all the  
> PA_GetxxxParameter all do a typecast.
>
>> , there is a "workaround". Maybe 4D can add this as  
>> PA_SetStringParameter():
>
> It's not a workaround. It's the way it was designed. You have to  
> call PA_GetStringParameter followed by PA_SetUnistring.
>
> It's a shame that 4D does not deliver the update documentation for  
> the plugin SDK that was once written. This would answer some of the  
> questions posted here.
>
> In case anyone needs it, you can download it here:
> http://www.pluggers.nl/downloads/4D%20Plugin%20SDK%20v11.pdf
>
> HTH,
>
> - Rob Laveaux
>
> --------------------------------------------------------
> Pluggers Software
> Bleriotlaan 62
> 2497 BM  Den Haag
> The Netherlands
>
> Email: rob.laveaux@...
> Website: http://www.pluggers.nl
>
> --------------------------------------------------------
>
>
> **********************************************************************
> 4D Plugins hosted by 4D, Inc.                      http://www.4D.com/
>
>   Register for 4D Summit 2009 Today
>   Early Bird Pricing Ends August 28th - http://www.4D.com/summit
>
> To Unsubscribe:                      mailto:4D-Plugins-off@...
> ***********************************************************************
>
>

**********************************************************************
4D Plugins hosted by 4D, Inc.                      http://www.4D.com/

    Register for 4D Summit 2009 Today
    Early Bird Pricing Ends August 28th - http://www.4D.com/summit

To Unsubscribe:                      mailto:4D-Plugins-off@...
***********************************************************************


Re: Who owns what #2

by aparajita :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> I have an other question. I would like to pass a Text back in the  
> parameter 2:
>
> command(&L;&T):L

Just modify the PA_Unistring in parameter 2 directly. When you return  
to 4D the new value will be there in the parameter you passed.

For example:

C_TEXT($text)
$text:="foo"

MY_Command($text)


// In your plugin

PA_Unistring* text = PA_GetStringParameter(inParams, 1);
PA_Unichar newText[] = { 'b', 'a', 'r', 0 };
PA_SetUnistring(text, newText);


When MY_Command returns, $text = "bar".

Regards,

   Aparajita
   www.aparajitaworld.com

   "If you dare to fail, you are bound to succeed."
   - Sri Chinmoy   |   www.srichinmoy.org

**********************************************************************
4D Plugins hosted by 4D, Inc.                      http://www.4D.com/

    Register for 4D Summit 2009 Today
    Early Bird Pricing Ends August 28th - http://www.4D.com/summit

To Unsubscribe:                      mailto:4D-Plugins-off@...
***********************************************************************


Re: Who owns what #2

by Christian Sakowski :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Please ignore the mails!!!

I wrote this mails two days ago, before the 4D mail server had a  
problem...

--

Grüße/Regards,
[heubach-media] | Christian Sakowski
Christian.sakowski@...
iChat/AIM: SakowskiF
ICQ: 4thDimension (267537916)
Tel: 040/52 10 59-23



Am 04.08.2009 um 12:19 schrieb Christian Sakowski:

> Thank you. Now it's clear.
>
> I have an other question. I would like to pass a Text back in the  
> parameter 2:
>
> command(&L;&T):L
>
> I have to following lines:
>
> PA_Variable variable;
> PA_Unistring unistring;
>
> unistring=this->GetUnistring(); //the value is valid/i saw it in the  
> debugger
>
> variable=PA_GetVariableParameter(params,index);
> PA_SetStringVariable(&variable,&unistring);
> PA_SetVariableParameter(params,index,variable,false);
>
> --
>
> After the call and my routine goes back to 4D, 4D crashes. Why? I  
> saw, that there is no "PA_SetTextParameter", right?
>
>
> --
>
> Grüße/Regards,
> [heubach-media] | Christian Sakowski
> Christian.sakowski@...
> iChat/AIM: SakowskiF
> ICQ: 4thDimension (267537916)
> Tel: 040/52 10 59-23
>
>
>
> Am 31.07.2009 um 18:34 schrieb Laurent Esnault:
>
>>>> void PA_SetUnistring( PA_Unistring* ustr, PA_Unichar* str )
>>>> Who owns the "PA_Unichar* str"? I think me!?
>>>> I have to dispose the unsigned short array?
>>
>> 'str' is copied and its ownership is not changed.
>> If you were the owner before the call, you are still the owner  
>> after the
>> call and should dispose your string after use.
>>
>> L.E.
>> **********************************************************************
>> 4D Plugins hosted by 4D, Inc.                      http://www.4D.com/
>>
>>   Register for 4D Summit 2009 Today
>>   Early Bird Pricing Ends August 28th - http://www.4D.com/summit
>>
>> To Unsubscribe:                      mailto:4D-Plugins-off@info.
>> 4D.com
>> ***********************************************************************
>>
>>
>
> **********************************************************************
> 4D Plugins hosted by 4D, Inc.                      http://www.4D.com/
>
>   Register for 4D Summit 2009 Today
>   Early Bird Pricing Ends August 28th - http://www.4D.com/summit
>
> To Unsubscribe:                      mailto:4D-Plugins-off@...
> ***********************************************************************
>
>

**********************************************************************
4D Plugins hosted by 4D, Inc.                      http://www.4D.com/

    Register for 4D Summit 2009 Today
    Early Bird Pricing Ends August 28th - http://www.4D.com/summit

To Unsubscribe:                      mailto:4D-Plugins-off@...
***********************************************************************