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
in Global external function I decleared
function long getclientinfo(general_struct gs,&
clientinfo_struct cs,&
ref clientinfo_baseinfo_ret_struct cbrs,&
ref clientinfo_insuinfo_ret_struct cinsurs,&
ref clientinfo_idetinfo_ret_struct cidenrs,&
ref general_ret_struct grs) &
LIBRARY "dgnewsbsapi.dll" Alias for 'getclientinfo;Ansi'
but it's not working