Migration to TD 5.1 : SalOutlineItemSetProperty function

Discussions specific to Team Developer 5.1.

Migration to TD 5.1 : SalOutlineItemSetProperty function

Postby olvin » Wed Jan 28, 2009 6:27 pm

Hello,

we migrate our application from TD 3.0 to TD 5.1 with SP4.
All problems are resolved except that we used a little application in the Quick Object Editor (CDK) to attribute traductions to components (background text associated to data fields, push buttons, ...) and the function "SalOutlineItemSetProperty" used in the little application to store the traductions in our application doesn't work anymore...

e.g. to save the text "Document" (which is in the component called dfLabelf) for the property "Labelf", this command is used :
Code: Select all
Call SalOutlineItemSetProperty( SalStrToNumber(strArgArray[2]), SalStrToNumber(strArgArray[3]), "Labelf", dfLabelf, SalStrLength(dfLabelf)+1)

But it is saving the word "Docum" !?!

So, the function "SalOutlineItemGetProperty" works with no problem... but there's a "little" problem with "SalOutlineItemSetProperty"...

Anybody else has detected this problem ? Has a solution ?
Is it a bug ? Corrected in the next SP5 ?

Thanks,

Olivier
olvin
 
Posts: 72
Joined: Tue Dec 02, 2008 8:43 pm
Location: Belgium

Re: Migration to TD 5.1 : SalOutlineItemSetProperty function

Postby Jeff Luther » Thu Jan 29, 2009 9:57 am

My guess is you need to read up on Unicode issues in 5.1. SalStrLength( s51 ) != SalGetBufferLength( s51) -- I believe that is your issue.

Change your parameter call "SalStrLength(dfLabelf)+1" to
either
SalGetBufferLength( dfLabelf ) +2 ! +2 for the 2-byte 0x00 chars
or
(SalStrLength( dfsLabelf )*2) +2
Jeff Luther
 

Re: Migration to TD 5.1 : SalOutlineItemSetProperty function

Postby olvin » Thu Jan 29, 2009 5:03 pm

Ok, it works !

Thanks.

And BTW, another solution is to replace "SalOutlineItemSetProperty" by "CDK_Window.SetStrProperty" (after initialization of CDK_Window)
olvin
 
Posts: 72
Joined: Tue Dec 02, 2008 8:43 pm
Location: Belgium

Re: Migration to TD 5.1 : SalOutlineItemSetProperty function

Postby Jeff Luther » Fri Jan 30, 2009 3:44 am

"another solution is to replace... "

YEP. I'd recommend staying away from internal, non-documented and non-supported, functions like the SalOutline functions. There is NO guarantee that they wil behave the same or even be in future releases of TD.

Thus, your questions: "Is it a bug ? Corrected in the next SP5 ?", while I didn't say so yesterday, would have been: NO. Since that's an internal function only it is not necessarily maintained. Stick with the CDK classes and methods as declared in cdk.apl and you'll be safe.
Jeff Luther
 

Re: Migration to TD 5.1 : SalOutlineItemSetProperty function

Postby rcogan » Thu Mar 15, 2012 7:39 am

I had this same issue and I wanted to clarify the correct solution for anyone reading this solution.

You would change:
SalOutlineItemSetProperty( SalStrToNumber(strArgArray[2]), SalStrToNumber(strArgArray[3]), "Labelf", dfLabelf, SalStrLength(dfLabelf)+1)

to

SalOutlineItemSetProperty( SalStrToNumber(strArgArray[2]), SalStrToNumber(strArgArray[3]), "Labelf", dfLabelf, SalGetBufferLength(dfLabelf))

You don't want the +2, since the null terminator is for Sal strings only. The SalOutline functions are like external function calls and you want to only include the buffer length without the null terminator. Adding + 2 ends up adding an additional null terminator onto the saved string value. This results in problems when subsequently getting the value returned by SalWindowGetProperty at runtime. When attempting to concatenate another string onto the end of the returned string, you end up with an embedded null, with unexpected results.

This is as of 5.2 and above, not sure if it had different behavior in 5.1.
rcogan
 
Posts: 11
Joined: Sun Oct 26, 2008 6:16 am


Return to Team Developer 5.1

Who is online

Users browsing this forum: No registered users and 1 guest

cron