1. Vladimir Mylnikov
  2. PowerBuilder
  3. Sunday, 1 December 2024 02:35 AM UTC

PowerBuilder 2022 R3 on Windows 10. I am trying to use OleCustomControl - 32 bit ActiveX control from nsoftware.com: www.nsoftware.com/platforms/activex/setup?sku=ISAJ-A&type=demo

I used the control for many years but the vendor made a change which PowerBuilder cannot handle. It is an event in OCX control. This is how it worked before:

Sub webdavcontrol_DirList(ResourceURI As String, DisplayName As String, ContentLanguage As String, ContentLength As String, ContentType As String, LastModified As String)

All event arguments are String.

The new problematic version:

Sub webdavcontrol_DirList(ResourceURI As String, DisplayName As String, ContentLanguage As String, ContentLength As Long64, ContentType As String, LastModified As String)

ContentLength is now Long64. In PowerBuilder I see ContentLength as type Any and this what caused the problem, I cannot get the value of ContentLength.

The code which used to be working:

long ll_row
string ls_size
long ll_size

 

ls_size = contentlength  //Does not work anymore 

If I do:

ls_size = string (contentlength) // then ls_zise is '', so it returns an empty string

Ok, I tried to do:

LongLong ll_size

ll_size = Long(contentlength) // returns 0

 

Then I tried:

ll_size = contentlength*1 //runtime error

 

I tried to modify an argument type in the event painter - change Any to LongLong, String, Long. If I change the type for ContentLength from Any - then the even simply is not fired anymore. I am out of ideas. Any ideas - is it possible to read Any datatype in this situation? I sent a question to the control's vendor and asked to change the argument type back to string, not sure what will be the result. 

 

 

 

 

Who is viewing this page
John Fauss Accepted Answer Pending Moderation
  1. Sunday, 1 December 2024 05:37 AM UTC
  2. PowerBuilder
  3. # 1

It looks to me that you have supplied us with the Visual Basic prototypes for the before/after function calls, as those are not in PowerBuilder form. Can you please supply the External Function Declaration (EFD) that you used with the previous version as it was coded in PowerBuilder?

Not being a Visual Basic developer (well, not since VB 4, 30 years ago), I can make a guess that a Long64 datatype is a 64-bit integer, and that the new version of this function is supplying the memory address of a string. Is this correct?

Is your PB app deployed as a 32-bit app or as a 64-bit app?

If I were in your shoes, I would try changing the EFD in PowerBuilder so that this problematic argument's datatype is LongLong and see if that will allow the function call to interface with PB correctly. If so, then that is a positive step in the right direction.

Once that is working, the challenge then becomes obtaining the string at the memory address that is supplied.

There is an obscure form of the PowerScript String function that can be used to obtain a string value from a memory address, but I've never tried using it with a LongLong datatype. It is documented (even more obscurely) in the PB Help for the TriggerEvent and PostEvent PowerScript functions to use an address in a Long datatype. It is coded like this:

String ls_value
Long   ll_memory_address  // Assume this variable contains the address of a string value.

ls_value = String(ll_memory_address,"address")

If that does not work, then you'll likely need to call a Windows API function to obtain the string value. I (or others here in the Community) can assist with that, but first try what I have described and see if that works.

Best regards, John

Comment
There are no comments made yet.
Vladimir Mylnikov Accepted Answer Pending Moderation
  1. Monday, 2 December 2024 19:55 PM UTC
  2. PowerBuilder
  3. # 2

The functions are indeed based on Visual Basic, but this is the documentation I have from the vendor. And no, I do not use External Functions - I insert Ole Custom Control. My application is deployed as 32 bit, the control is 32 bit as well. This is an event, not a method, as documented by OCX vendor:

DirList Event (WebDAV Control)
This event fires for each entry returned in a directory listing.

Sub webdavcontrol_DirList(ResourceURI As String, DisplayName As String, ContentLanguage As String, ContentLength As Long64, ContentType As String, LastModified As String)

Remarks
The DirList event is fired when a directory listing is received as a response to ListDirectory.

This is the previous version which works fine. In PB, I created a user object, and then in PB IDE  I do 'Insert' -> 'Control' -> 'Ole' -> 'Insert Control' tab, select version 2022 of the WebDav control.

 

 

You can see that for DirList event ContentLength is String. This is what I see in PB:

 

You can see that ContentLength is  a String and my code works. Now I try to use version 2024 of OCX control

 

 

Now in DirList event ContentLength is Any! And in PB:

 

 

I tried to change the return type of ContenLength to string, long, longlong, blob - then the event is not fired. I tried to keep Any data type and change Access to 'by reference'. Then the following code:

string ls_size

ls_size = contentlength // Causes runtime error:

The following:

longlong ll_size

ll_size = contentlength*1

ll_size = LongLong(contentlength) //this returns 0

ls_size = string(contentlength) //this returns empty string

I am out of ideas. 

 

 

Comment
  1. John Fauss
  2. Tuesday, 3 December 2024 01:55 AM UTC
Thank you for the clarifications.

I suggest you use the ClassName(contentlength) PowerScript function on the content length event argument value to see what datatype PowerBuilder thinks it contains. This function returns a string value, such as "integer", "long", "string", etc. that describes the underlying type of data contained in the Any variable. This information should give you a clue as to how you can assign/convert the value.

In case anyone else is following this thread, here is a URL to the vendor's Help topic for the DirList method of the WebDavControl OLE custom control:

https://cdn.nsoftware.com/help/IPJ/acx/WebDAV.htm#hdr_822_syntax

It would appear that at some point in the communications chain, either Windows OLE or PB is unable to accurately determine the actual datatype of this event argument. I suggest you open a free bug ticket with Appeon now to report this issue.
  1. Helpful 1
There are no comments made yet.
Vladimir Mylnikov Accepted Answer Pending Moderation
  1. Tuesday, 3 December 2024 20:44 PM UTC
  2. PowerBuilder
  3. # 3

ClassName returns void. I am going to submit a bug report. 

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.