1. Joel McManness
  2. PowerBuilder
  3. Wednesday, 16 October 2019 21:07 PM UTC

Hi -

Is it possible to get the Last Modified Date property from objects in powerscript from compiled code (PBDs).  Currently we are able to use LibraryDirectoryEx (below) to get it from PBL's but we would like to create something similiar for compiled code.  Something where we are able to pass in the object name and it retrieves the last modification date.  The purpose of this is to provide in-app version control of reports (datawindows) without having source code available.

Powerbuilder version 2017

 

Thanks

 

/* Get the objects per library */
lib_cnt = upperbound(s_library)
FOR i = 1 to lib_cnt
s_objectlist = LibraryDirectoryEx( s_library[i], DirAll!)
ds_objectlist.Reset()
obj_cnt = ds_objectlist.ImportString(s_objectlist)
s_libraryname = s_library[i]
if LastPos(s_library[i], '\\') > 0 then s_libraryname = mid(s_library[i], LastPos(s_library[i], '\\') + 2)

f_pp_msgs(' Extracting ' + string(obj_cnt) + ' objects from ' + s_libraryname )
FOR j = 1 TO obj_cnt
row = dw_objects.InsertRow(0)
dw_objects.SetItem(row, 'app_name', a_appname)
dw_objects.SetItem(row, 'library_name', s_libraryname)
dw_objects.SetItem(row, 'object_name', ds_objectlist.GetItemString(j, 'object_name'))
dw_objects.SetItem(row, 'last_modified', ds_objectlist.GetItemDateTime(j, 'last_modified'))
dw_objects.SetItem(row, 'comments', ds_objectlist.GetItemString(j, 'comments'))
dw_objects.SetItem(row, 'object_type', ds_objectlist.GetItemString(j, 'object_type'))
NEXT
NEXT

Roland Smith Accepted Answer Pending Moderation
  1. Thursday, 17 October 2019 02:35 AM UTC
  2. PowerBuilder
  3. # 1

There is a function LibraryImport function that imports DataWindow source into a PBL.

You can store the DataWindow source in the database and import it into a PBL that is added to the application's library list using the AddToLibraryList or SetLibraryList functions.

You can call LibraryDirectory to get a list of DataWindow objects in the PBL which will give you the modification date. You could select from the table getting the source for objects with a date greater than the most recent modification date in the PBL. Then when you import the source, the modification date will be updated.

You can't import other types of objects in an application unless you use ORCA functions.

The app I work on allows users to customize DataWindow objects. They click a button and the standard DataWindow is copied to a PBL and InfoMaker is launched. When they exit InfoMaker, the window activate event resets the dataobject property of the DataWindow control so that the latest version is displayed. The custom PBL is added to the top of the library list at program startup using SetLibraryList.

 

Comment
  1. Chris Pollach @Appeon
  2. Thursday, 17 October 2019 15:46 PM UTC
Hi Roland;

FYI: The restriction of only importing DWO source was a PowerSoft imposed restriction so that it would force customers to buy the ORCA support. Sybase just kept on doing that when they acquired PB from PS. In the latter days of Sybase though and into the ownership days of SAP - the ORCA API no longer had a purchase requirement. That open use continues today. So in theory, there would seem to be (unless I am missing something), no requirement to restrict the LibraryImport() command to only DWO's. Personally, I think that opening up this LibraryImport command could stimulate 3rd party tool creation for PB and even improve what "home grown" utilities PB developers could build for their organizations. Of course, that's only IMHO and my $0.02 worth.

Regards ... Chris
  1. Helpful
There are no comments made yet.
Michael Kramer Accepted Answer Pending Moderation
  1. Wednesday, 16 October 2019 22:19 PM UTC
  2. PowerBuilder
  3. # 2

BTW: I wrote app (and Roland has new free code app on his TopWiz site) that can extract the full source code of any DataWindow object in any .PBD or .PBL -- as long as they are compiled with same PB version number.

Elaborating on options:

It would be possible to check last-modified against a database and download DW objects from a database into local file to allow a type of "Get Latest Version" automated refresh at regular intervals. EX: Separate background thread while normal UI app runs its regular main thread.

/Michael

Comment
There are no comments made yet.
Michael Kramer Accepted Answer Pending Moderation
  1. Wednesday, 16 October 2019 22:16 PM UTC
  2. PowerBuilder
  3. # 3

Hi Joel,

I just verified few days ago, that LibraryDirectoryEx can extract the object directory from both .PBL, .PBD, and .EXE files. However, it cannot extract object directory of .DLL files so if you compile to machine code and decide to create dynamic library for every .PBL, then you protect you objects from being immediately scanned by LibraryDirectoryEx.

I just verified a minute ago, LibraryDirectoryEx from a .PBD include the "last modified" stamp.

HTH /Michael

Comment
  1. Joel McManness
  2. Thursday, 17 October 2019 17:56 PM UTC
Thanks for the reply Michael, I tested using the LibraryDirectoryEx on PBD's and it seems to work. However, it does look like it is pulling back its last compilation date rather than the last modified date of the object. I'll take a look at the App you mentioned above as well
  1. Helpful
  1. Michael Kramer
  2. Thursday, 17 October 2019 18:31 PM UTC
A few days ago there were two independent questions that got a lot of response related to your topic.

1) Started on code obfuscation, but also dug into what you can and cannot do with DataWindow objects. Link https://community.appeon.com/index.php/qna/q-a/code-obfuscation-for-powerbuilder-apps

2) Started on data source within DataWindow but veered into more general DataWindow discussion; and therefore fed into (1). Link https://community.appeon.com/index.php/qna/q-a/data-source-on-datawindow-using-pbd

Enjoy.
  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.