1. John Fauss
  2. PowerBuilder
  3. Friday, 24 January 2020 22:13 PM UTC

Does anyone have any advice, tips, C++ source for creating simple PBNI examples they are willing to share with the community?

The "pbadd" non-visual object example in the PowerBuilder Native Interface Programmers Guide and Reference publication compiles with multiple errors as it is listed and the Visual Studio wizards supplied in the PB SDK are woefully out of date (the most current wizard is for Visual Studio 2005 and do not work in Visual Studio Community 2017). With corrections to the example code, I'm able to get a clean compile of the pbadd example source and produce a DLL, then rename the extension to .PBX - But I get an error ("The string returned by function "GetDescription" has a syntax error.") when attempting to Import the extension into a PBL.

The PBNI publication states there are examples in the Appeon web site and supplies the URL (which is a valid URL), but a search from that page for anything relevant to PBNI turns up nothing. Ditto for a search in the PowerBuilder section of CodeXchange. I'm stymied.

Many thanks in advance!

John Fauss Accepted Answer Pending Moderation
  1. Tuesday, 28 January 2020 03:07 AM UTC
  2. PowerBuilder
  3. # 1

Update: I've opened a bug ticket (#3952) on the out-of-date PBNI VS Wizard & erroneous documentation.

Comment
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Saturday, 25 January 2020 20:45 PM UTC
  2. PowerBuilder
  3. # 2

I've uploaded an example PBNI non-visual extension. Go to this page and download WinsockPBNI.

https://www.topwizprogramming.com/tools.html

This PBNI example is a re-write of the n_winsock object from my Winsock example in C++ as a PBNI non-visual extension.

 

Comment
  1. John Fauss
  2. Monday, 27 January 2020 17:50 PM UTC
The new WinsockPBNI example you have made available on the TopWiz web site has allowed me to get past the issues I've been struggling with and successfully generate the trivial example of a PBNI non-visual user object described in Chapter 2 of the PBNI Programmers Guide & Reference. I'm very grateful for your help!
  1. Helpful
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Saturday, 25 January 2020 03:58 AM UTC
  2. PowerBuilder
  3. # 3

Here is and example from one of mine. I'm not sure if the help mentions but the autoinstantiate keyword is not supported by PBNI.

PBXEXPORT LPCSTR PBXCALL PBX_GetDescription()
{
   static const CHAR classDesc[] = {
      "class n_twclient from nonvisualobject\n"
      "function string base64encode (string as_string)\n"
      "function string getarguments ()\n"
      "end class\n"
   };

   return classDesc;
}
Comment
  1. John Fauss
  2. Monday, 27 January 2020 16:27 PM UTC
I've tried changing "LPCTSTR" (as listed in the PBNI Programmers Guide & Reference) to "LPCSTR" and TCHAR to CHAR in the declaration of the static constant array. Now when I perform a Build in Visual Studio, I get the following errors:

C2556 'LPCSTR PBX_GetDescription(void)': overloaded function differs only by return type from 'LPCTSTR PBX_GetDescription(void)

C2371 'PBX_GetDescription': redefinition; different basic types



I'm going to examine the WinsockPBNI example you have posted on your site. Thanks for making this available!!!



Have you made any changes to the PBNI SDK header (.h) files? What tool/version are you using to compile the C++?
  1. Helpful
  1. Roland Smith
  2. Monday, 27 January 2020 16:37 PM UTC
The Winsock PBNI example is Visual Studio 2017. I have not changed any files within the PBNI folder.



The snippet above is from an ANSI example. The Winsock example is Unicode. You don't have to use Unicode in the C++ project, the strings that pass between PB code and C++ code are converted automatically.
  1. Helpful
  1. John Fauss
  2. Monday, 27 January 2020 17:44 PM UTC
Ah. Thank you, Roland. The default project for a Windows C++ DLL created by Visual Studio is configured for Unicode, and I did not recognize that the sample code for creating a simple non-visual object in Chapter 2 of the PBNI Programmers Guide & Reference was ANSI-specific.

My Visual C++ / Visual Studio skills are rudimentary at this point.

It appears the PBNI documentation has not been updated in a LONG time, save for changing all SAP references Appeon.
  1. Helpful
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.