I remember i did this long ago and it worked (in PB version 10 probably).
I export syntax of an external datawindow then add some data in it and Imported it back into either dll or pbd depending build type.
the "data(" is searched from the exported external dw syntax. then i add at the end of the line new comma separated data. Creating syntax and importing it in library (dll or pbd) is not the problem.
The Problem:
The new last row i added in script at runtime, instead of increasing rowcount, somehow updates any one of the previous rows.
I could not understand this behavior.
But same code when used without creating project and run in Powerbuilder IDE 12.5 the new row is added in previous rows and rowcount increases. It only happens when export and import both are from pbl and app runs in IDE.
dwsyntax = LibraryExport(GetCurrentDirectory() + "\btserverdll.pbl", "dwe_list", ExportDataWindow!)
IF IsNull(dwsyntax) OR TRIM(dwsyntax) = "" THEN
MSG.Text = "LibraryExport failed."
RETURN
END IF
TheLine = Pos( dwSyntax, "data(")
TheLineEnd = Pos( dwSyntax, ",)", TheLine)
IF TheLineEnd > TheLine THEN
TheLineEnd = Pos( dwSyntax, ",)", TheLine)
dwSyntax = Replace(dwSyntax, TheLineEnd, 2, + "," + Trim(NewRow )+ ")")
ELSE
IF TheLineEnd <= TheLine THEN
TheLineEnd = Pos( dwSyntax, ", )", TheLine)
dwSyntax = Replace(dwSyntax, TheLineEnd, 3, + "," + Trim(newRow )+ ")")
END IF
END IF
rtncode = LibraryImport( GetCurrentDirectory() + "\btserverdll.dll", "dwe_list", ImportDataWindow!, dwsyntax, ErrorBuffer,"dynamic @ runtime")
IF rtncode <> 1 THEN
///MessageBox("LibraryImport ERROR", ErrorBuffer)
ELSE
dw_1.DataObject = "dwe_list"
END IF
Please note that i carefully checked the export and import is from dll in case of machine code and pbd in pcode. In the above code export is from pbl which i was just testing.
Even after trying all possible combinations i could not get new row added in neither dll nor the pbd.
Is it not possible in PB12.5.
What i am trying to do is that. two application server and client talk to each other on winsock. client sends new row to server side and server keeps list of the rows. Server export the external dw add data in it syntax and import it back. this idea is working only through PB IDE. But when exe runs behavior is different.
I am pretty much sure i have done this through exe long ago. May be forgetting but i need to do it now. Please help because 2 days of effort made my write this request.
Case:
1- Syntax generated from a template DW (External DW but no data in it)
2- dw_1.dataobject shows that the templates is ok
3- Now data is needed (row can be added and all columns have data)
4- Again Syntax of dw_1 is taken with dw_1.Object.DataWindow.Syntax (the syntax does not include the row )
5- have to use 2nd syntx ( dw_1.Object.DataWindow.Syntax.Data )
6- need to join both after "table(" and before "text(" (tricky part)
Anyway, when dw_1 is external and have now row (template) then syntax will not have "data(" part in it.So need to figure out what is the right way to add "data(" part . So in step 5 we got data syntax which has to fit in between "table(" and "text(".
Anyway, when dw_1 is external and have no row (the template) then syntax will not have "data(" part in it.So need to figure out what is the right way to add "data(" part . So in step 5 we got data syntax which has to fit in between "table(" and "text(".
When both syntax are joined properly then new syntax can be passed to LibraryImport.