1. Albert John
  2. PowerBuilder
  3. Friday, 23 April 2021 07:38 AM UTC

I'm a PB 12.5 classic user and I  was trying  to call a C++ dll,the parameter has array like 

 in C++

 

 

typedef struct clientinfo_insuinfo_ret_struct{
int insuinforecordscount;
double * balc;
char ** insutype;
char ** psn_type;
char ** psn_insu_stas;
char ** psn_insu_date;
char ** paus_insu_date;
char ** cvlserv_flag;
char ** insuplc_admdvs;
char ** emp_name;

}clientinfo_insuinfo_ret_struct;

typedef struct clientinfo_idetinfo_ret_struct{
int idetinforecordscount;
char ** psn_idet_type;
char ** psn_type_lv;
char ** memo;
char ** begntime;
char ** endtime;
}clientinfo_idetinfo_ret_struct;

 

int getclientinfo(general_struct & gs,
clientinfo_struct & cs,
clientinfo_baseinfo_ret_struct & cbrs,
clientinfo_insuinfo_ret_struct & cinsurs,
clientinfo_idetinfo_ret_struct & cidenrs,
general_ret_struct & grs)

 

in PB 

then I tried to build structure with array like 

$PBExportHeader$clientinfo_insuinfo_ret_struct.srs
global type clientinfo_insuinfo_ret_struct from structure
long insuinforecordscount
double balc[]
string insutype[]
string psn_type[]
string psn_insu_stas[]
string psn_insu_date[]
string paus_insu_date[]
string cvlserv_flag[]
string insuplc_admdvs[]
string emp_name[]
end type

 

$PBExportHeader$clientinfo_idetinfo_ret_struct.srs
global type clientinfo_idetinfo_ret_struct from structure
long idetinforecordscount
string psn_idet_type[]
string psn_type_lv[]
string memo[]
string begntime[]
string endtime[]
end type

 

and I tried to pass the sturcture like code below,it's not working 

 

 

 

I could see the arrays within structure h

long ll_row



cirs1.insuinforecordscount=0



for ll_row=1 to 50
cirs1.balc [ll_row]= 0.0;
cirs1.insutype [ll_row]= space(10);
cirs1.psn_type [ll_row]= space(10);
cirs1.psn_insu_stas[ll_row] = space(10);
cirs1.psn_insu_date[ll_row] = space(30);
cirs1.paus_insu_date[ll_row] = space(30);
cirs1.cvlserv_flag[ll_row] = space(10);
cirs1.insuplc_admdvs[ll_row] = space(10);
cirs1.emp_name[ll_row] = space(200);

next

string ls_psn_idet_type[50],ls_psn_type_lv[50]
string ls_memo[50],ls_begntime[50],ls_endtime[50]


for ll_row=1 to 50

ls_psn_idet_type[ll_row] =space(6);
ls_psn_type_lv[ll_row] = space(6);
ls_memo[ll_row] = space(500);
ls_begntime[ll_row] = space(30);
ls_endtime[ll_row] =space(30);

next

 

clientinfo_idetinfo_ret_struct cidrs1
cidrs1.idetinforecordscount = 0


for ll_row=1 to 50
cidrs1.psn_idet_type[ll_row] =space(6);
cidrs1.psn_type_lv[ll_row] = space(6);
cidrs1.memo[ll_row] = space(500);
cidrs1.begntime[ll_row] = space(30);
cidrs1.endtime[ll_row] =space(30);
next

 


ll_result = getclientinfo(gs1, cs1, cbrs1, cirs1, cidrs1, grs1)

as been initialized

please take a look at  structure1.png and structure2.png as well in the attchements

 

but when I tried to debug it on VC++ ,(I was using VC++ 2013 ), I saw the cirs1 and  cidrs1 as well was totally like uninitialized, please take a look at the "debug which PB calling.png" in the attachement 

I have compared the normal one which direct calling that function with C++,the memory was totally different ,please take a loook at "calling from C++.png"

any idea what wrong I have done? or I should tried something else way to complished this,I was trying to pass a bunch of values which from a web services,it has tooks me 2 months,hopefully I'm not gonna rewrite the code,that was painful though

updated:

 even I tried upgrade PB to 2019 and upgraded my project as well, but it doesn't work, it probably I have done something wrong but I have no idea

 

updated

I tried to use PB 2019 dw importjson functionality,it works for me, but the problem was the  the sequence of node  that means must be exactly like json string

update

I was facing the problem of lost prprecision of double variable which the string which export with PB, when I tried to import that string into json in C++, I didn't it would b a problem

 

update 

the problem I have been resolved I changed C++ like 

 

typedef struct clientinfo_insuinfo_ret_struct{

double  balc;
char * insutype;
char * psn_type;
char * psn_insu_stas;
char * psn_insu_date;
char * paus_insu_date;
char * cvlserv_flag;
char * insuplc_admdvs;
char * emp_name;

}clientinfo_insuinfo_ret_struct;

typedef struct clientinfo_idetinfo_ret_struct{

char * psn_idet_type;
char * psn_type_lv;
char * memo;
char * begntime;
char * endtime;
}clientinfo_idetinfo_ret_struct;

 

int getclientinfo(general_struct & gs,
clientinfo_struct & cs,

clientinfo_baseinfo_ret_struct & cbrs,

int & insuinforecordscount,
clientinfo_insuinfo_ret_struct * cinsurs,

int & idetinforecordscount,
clientinfo_idetinfo_ret_struct * cidenrs,
general_ret_struct & grs)

$PBExportHeader$clientinfo_insuinfo_ret_struct.srs
global type clientinfo_insuinfo_ret_struct from structure

double balc
string insutype
string psn_type
string psn_insu_stas
string psn_insu_date
string paus_insu_date
string cvlserv_flag
string insuplc_admdvs
string emp_name
end type

 

$PBExportHeader$clientinfo_idetinfo_ret_struct.srs
global type clientinfo_idetinfo_ret_struct from structure

string psn_idet_type
string psn_type_lv
string memo
string begntime
string endtime
end type

long ll_row

 

long insuinforecordscount

insuinforecordscount=0

 clientinfo_insuinfo_ret_struct cirs1[]

for ll_row=1 to 50
cirs1[ll_row].balc = 0.0;
cirs1[ll_row].insutype = space(10);
cirs1[ll_row].psn_type = space(10);
cirs1[ll_row].psn_insu_stas = space(10);
cirs1[ll_row].psn_insu_date = space(30);
cirs1[ll_row].paus_insu_date = space(30);
cirs1[ll_row].cvlserv_flag = space(10);
cirs1[ll_row].insuplc_admdvs = space(10);
cirs1[ll_row].emp_name = space(200);

next

 

clientinfo_idetinfo_ret_struct cidrs1[]
cidrs1.idetinforecordscount = 0


for ll_row=1 to 50
cidrs1[ll_row].psn_idet_type =space(6);
cidrs1[ll_row].psn_type_lv = space(6);
cidrs1[ll_row].memo = space(500);
cidrs1[ll_row].begntime = space(30);
cidrs1[ll_row].endtime =space(30);
next

 


ll_result = getclientinfo(gs1, cs1, cbrs1, cirs1, cidrs1, grs1)

it works for me, I'd like to thanks for all you guys,thanks for the helps, I apperciated it

Attachments (4)

Responses (5)
  1. Likes
  2. Latest
  3. Oldest
Loading...

Find Questions by Tag

.EXE .NET 6.0 .NET Assembly .NET Core 3.1 .NET Core Framework .NET DataStore .NET Std Framework 32-bit 64-bit ADO.NET AEM AI Algorithm Amazon AWS Android Apache API APK App Store App Store (Apple) Appeon Workspace Appeon Xcelerator Plug-in Architecture Array ASE Asynchronous Methods Authentication AutoBuild AutoCompiler Automated Testing Automation AutoScript Azure Barcode Base64 Batch BigData BLOB Branch & Merge Browser Bug Build Button C# C# Class Importer C# Editor C# Model generator Calendar Camera Certificate Chrome Citrix Class Client Client/Server Cloud Cluster Collection COM Command Line Compiler Compression Computed Field Configuration Controls Cookies Cordova Crash Cross-Platform Crosstab CSharpAssembly CSharpObject CSS CSV Cursor Data Database Database Driver Database Painter Database Profile Database Provider DataObject DataSource DataStore DataStore (C#) DataStore (PS) DataType DataWindow DATE DATETIME DB2 Debug Debugger Debugging Deployment Design DLL DO-WHILE Dockable Docker Documentation DOUBLE Download DragDrop Edge Edit Style Editor Elevate Conference Email Embedded SQL Emulator Encoding Encryption Enhancement Request Entity Entity Framework ERP Error Event Event Handler Event Handling Excel Exception Export Expression External Functions F# Field File File Access Filter Firefox Firewall Font FOR-NEXT Foreground Format Function Garbage Collection GeoLocation Git Graph HANA Hash Header HTML/5 HTTP/S HTTPClient Icon IDE Identity IIS IMAPI Import InfoMaker Inheritance Installation Integer IntelliSense Interface Internet Internet Explorer iOS IPA iPad iPhone IWA J# Java JavaScript JBoss JDBC JOIN JSON JSONGenerator JSONParser Kestrel Label Lambda Large File LDAP Library License LINQ Linux OS Load Balancing Localization Localized PBVM Log In Log Out Logging LONG LONGLONG macOS MAPI Maps MDI Memory Memory Leak Menu Merge MessageBox Messagging Method Migration MIME TYPE Mobile Model ModelStore ModelStore (C#) MSOLEDBSQL Multi Threading MVC MySQL n-Tier Namespace NativePDF NVO OAuth ODATA ODBC Office Offline OLE OLEDB Online Open Source OpenAPI OpenSSL Oracle OrcaScript Other Outlook Output Package Parameter Patch PayPal PB Classic PB Native PB.NET PBC PBD PBDOM PBG PBJVM PBL PBNI PBORCA PBVM PBX PDF Performance Permission PFC Picture Pipeline Play Store (Google) Plugin Popup Port POST PostgreSQL PowerBuilder PowerBuilder (Appeon) PowerBuilder (SAP) PowerBuilder Compiler PowerBuilder Runtime PowerClient PowerScript (PS) PowerScript IDE PowerScript Migrator PowerServer PowerServer Mobile PowerServer Toolkit PowerServer Web PowerServerLabel Print Properties Proxy Publish PULL PUSH Query Regression Release Renew Resize Response REST Retrieve RibbonBar RibbonBar Builder Rich Text Roadmap RPC Runtime Packager SaaS Scaffolding Script SDI SDK Security Server Service Session Single Sign-on Size SMTP SMTPClient SnapDevelop SOAP Sort Source Code Speech Recognition SQL SQL Anywhere SQL Server SqlBuilder SqlExecutor SQLite SqlModelMapper Storage Stored Procedure Subscription SVN Swagger Syntax TabbedBar TabbedView Tablet TabPage Target TE Control Testing Text TFS Theme TIME Timer TLS/SSL Tomcat TortoiseGit TortoiseSVN Transaction Transparency Trial Trigger TRY-CATCH TX Control Type UI ULONG UltraLite Uninstall Unit Test Unit Testing UNIX OS Update Upgrade Upload URL User Center User Object UWP Validation VARCHAR Variable Versioning Visual Studio Visual Studio Code VM Voice Warning WCF Web API Web Extensions Web Service WebBrowser WebForms WebLogic WebSphere WildFly WinAPI Window Windows OS WinForms Wizard Workgroup Workspace WPF XCODE XHTML XML Zoom

Helpful?

If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.