Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CCW Interop - How to create a C# array from PowerScript?

53 views
Skip to first unread message

Michael Kramer

unread,
Aug 21, 2009, 9:24:16 AM8/21/09
to
I need this to happen (written in "pseudo code") from a win32 application.
oleData.EmployeeData = New EmployeeDataStructure( Rows )
FOR i = 1 TO Rows
oleData.EmployeeData[i].FullName = ...
...
NEXT

oleData is my OLEObject referencing the C# object containing a nested
unbound "structure" array.
PB version: PB 10.5.2 for current production release.
Next release will be in PB 11.5.1 but for now I need a solution in PB
10.5.2.

What is the RIGHT SYNTAX?
Do I need other dodgy tricks to get the job done?


I would prefer simply passing my PB structure containing nested unbound
arrays of other structures but I simply don't have the C# skills to pass
such structures across a CCW layer.

Is it possible at all to pass a structure from PB to C# using CCW?

Any help greatly appreciated!
/MicKr-
Michael Kramer, Geokon A/S, Denmark


frankalvaro

unread,
Aug 27, 2009, 11:46:59 AM8/27/09
to
> Do I need other dodgy tricks to get the job done?

I ran into the same issue with arrays and an interop library
i'd created (i use vb.net, but ymmv). I used a "dodgy
trick", as you put it, to get around the issue: created a
ComVisible method for adding my array values. This method
searches for an existing element in the array using "key"
values from the structure; if found, it'll just update that
element, if not, it adds a new element to the array with the
method's parameters.
i.e.:

[ComVisible(true)]
public boolean AddEmployeeData(employeeStructure
employeeData)
{
try
/* check your existing array to see if there's already an
index for your structure's "key" values, and "update"
that structure in the array if found.
*/
... code ...
/* otherwise, expand the array and add */
... code ...
catch
return false;
end try

return true;
}

NOTE: if you need to RETRIEVE an array element, you'll
probably run into the same issue. As such, you'll need a
"public employeeStructure GetEmployeeByIndex(int index)"
(and/or "public employeeStructure
GetEmployeeByLastname(string lastName))" method.

HTH

Michael Kramer

unread,
Sep 8, 2009, 5:07:11 AM9/8/09
to
Thank you Frank,
The data structures we need to create and manipulate are just too
complicated. We finally decided to marshall the data structure into an XML
string and then unmarshall it at the other side of the CCW boundary into the
right data structure again. The alternative was to duplicate all data
extraction in C# (code already existed in PB) and let each user double her
DB connections.

We have a five level hierarchy of unbounded arrays of structure types
matching collections of structs. Several levels have several collections of
difrent structure types. Since C# can deserialize an XML string into the
right data structure in just four lines of code if we map to the right XML
tags, we simply decided to create a PBDOM tree using the right XML tag names
from the data structures containing the data in PowerBuilder.

In case you or anyone reading this thread wonders "What is so complicated?"
It is a LocationStructureType describing a polluted area, the pollutants,
its geographic area (GML polygons), and all actions taken or planned to be
taken independent of whether it is earth, water, air or anything else
polluted. It includes accrued and budgetted expenses. GML polygons are XML
documents themselves but at 4th level of structure nesting.

/MicKr-
Michael Kramer, Denmark

<Frank Alvaro> wrote in message news:4a96aa73.324...@sybase.com...

Michael Kramer

unread,
Sep 8, 2009, 5:13:06 AM9/8/09
to
All my problems stem from PB not capable of inserting a string into the SOAP
header of a web-service call. It is not a "Custom SOAP Header", so it is
unsupported.

If I could just expand the SOAPConnection object with a method
"SetSOAPHeader( string HeaderText )". Then I could call a simple C# method
to retrieve the security token. That token is simple a huge string to be
inserted in the SOAP header.

The security token requires the Geneva framework of .NET 3.5 SP1, so I need
C# for that purpose when PB runs win32.

Anyone out there having such a SOAPConnection extension?
/MicKr-
Michael Kramer, Denmark

<Frank Alvaro> wrote in message news:4a96aa73.324...@sybase.com...

0 new messages