1. Julián Tagarro
  2. PowerBuilder
  3. Thursday, 30 April 2020 20:24 PM UTC

Hi All,

Please follow me through this steps:

* Inside a pbl I have a datawindow. In runtime, using LibraryExport, I export it to a string variable.

* Set a name for the object and add the header. 

ls_dw_name = 'd_test'
ls_syntax  = '$PBExportHeader$' + ls_dw_name + CharA(13) + ls_syntax

 * Save ls_syntax to a file 

ls_file   = 'c:\temp\d_test.srd'
li_handle = FileOpen ( ls_file , TextMode! , Write! , LockReadWrite! , Replace! , EncodingUTF16LE! )
FileWriteEx ( li_handle , ls_syntax )
FileClose ( li_handle ) 

The problem is that when I try to import it to a tmp_pbl (using PB IDE) I get the "DataWindow syntax has incorrect release number". But when I add a blank space and save it using PB File Editor (not working with notepad or other text editor) then, I can import the datawindows without problems.

What am I missing in the proccess of generating the srd ? Why it "get fixed" when I save the file using PB File Editor ?

Best Regards,

_______________

Julián Tagarro

NeoSistemas SRL

Accepted Answer
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Friday, 1 May 2020 01:15 AM UTC
  2. PowerBuilder
  3. # Permalink

Hola Julian,

CharA(13) ? On which version of pb are you? Should be followed by + char(10), or simply use "~r~n".

My version of your code (with different dw name), in bold my changes:

string ls_file, ls_syntax, ls_dw_name
int li_handle
long ll_flen

ls_dw_name = "d_t" // yes I'm too lazy to use a decent name, sorry
ls_syntax = LibraryExport("d:\pb_code\pb2019\genapp.pbl", ls_dw_name, ExportDataWindow!)
ls_syntax = '$PBExportHeader$' + ls_dw_name + ".srd" + Char(13) + Char(10) + ls_syntax 
ls_file = 'c:\temp\d_test.srd'
li_handle = FileOpen ( ls_file , TextMode! , Write! , LockReadWrite! , Replace! , EncodingUTF16LE! )
ll_flen = FileWriteEx ( li_handle , ls_syntax )

Works perfectly well for me, on a pb2017 version datawindow in PB 2019 IDE, but there is one thing you might want to look at:

Right after your library export, the ls_syntax should start with version information like "release 17;" check on how old your datawindow is (look at the version number you get), because there's probably a limit on how far backwards compatible Powerbuilder versions are when it comes to Importing files.

When you migrate to a newer version of powerbuilder, the version numbers are NOT changed. (I did a request for that time ago). When you then edit a dw in the IDE and save it, then the version number IS updated to the newer version. That would explain why it works when you got it working doing things manually after having done some change.

regards,

MiguelL

 

Comment
  1. Julián Tagarro
  2. Friday, 1 May 2020 13:49 PM UTC
Hi Miguel !!

Your solution is correct. "Char(13) + Char(10)" works fine. I was missing Char(10) !!!!!

I'm migrating from PowerBuilder 9 and "ls_syntax = '$PBExportHeader$' + ls_dw_name + Char(13) + ls_syntax" (without Char(10)) was working fine.

Thanks for all your help.

Regards,

________________

Julián Tagarro

NeoSistemas SRL
  1. Helpful
  1. Miguel Leeuwe
  2. Friday, 1 May 2020 14:03 PM UTC
Glad it works. If you've come from v9, there's no more need for PosA(), CharA(), etc. you can just use all the string versions without the "A", unless your doing something special maybe.
  1. Helpful
There are no comments made yet.


There are replies in this question but you are not allowed to view the replies from this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.