1. Jay Hastings
  2. PowerBuilder
  3. Monday, 11 May 2020 23:02 PM UTC

In PB 12.6......my app has a PBL (not PDB) in our library path.  We store our reports datawindow syntax in the database, extract it, may or may not modify it, and use LibraryImport to create the datawindow object in this PBL.  This has been working with harcoding the PBL in the library path (ie C:\temp\rpttmp.pbl)

My IT dept is cracking down on where you can write on the C drive so I'm trying to create the PBL in the user's directory using the USERPROFILE environment variable.

My issue is I can't get that added dynamically to the Library path using SetLibrary or AddToLibrary. 

Any tips on how I can accomplish this?

 

Thank you in advance

Jay

Roland Smith Accepted Answer Pending Moderation
  1. Tuesday, 12 May 2020 02:28 AM UTC
  2. PowerBuilder
  3. # 1

I would try ProgramData and then a folder YourCompanyName under that.

Usual location:

C:\ProgramData

 

Comment
  1. Jay Hastings
  2. Tuesday, 12 May 2020 14:30 PM UTC
It doesn't appear that C:\ProgramData exists in the standard Win 10 environment. I need something for both Win 7 and Win 10.
  1. Helpful
  1. Roland Smith
  2. Tuesday, 12 May 2020 17:56 PM UTC
It is a hidden folder. It replaces the 'All Users' folder in Win7.
  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Tuesday, 12 May 2020 13:38 PM UTC
  2. PowerBuilder
  3. # 2

Greetings, Jay -

1. What exactly does not work with your attempt to use the USERPROFILE environment variable value? Are you trying to specify the library path as %USERPROFILE%\rpttmp.pbl, or are you first resolving the value of the environment variable and then constructing the library's path from that value? You need to first use the GetContextKeywords PowerScript function to obtain the value of the USERPROFILE environment variable. The PB Help topic for GetContextKeywords contains an example of how to call this function.

2. Roland's suggestion to use C:\ProgramData is a good alternative. This is where we install our product when it is installed locally onto an individual's PC.

3. Since your IT is dictating where the library cannot reside, ask them where they think it can/should reside.

Regards, John

Comment
  1. Jay Hastings
  2. Tuesday, 12 May 2020 15:03 PM UTC
I get the environment into a variable so g_PATH has C:\users\myname.



I've tried

li_rc = this.SetLibraryList("prod.pbd,sublabels.pbd,rptobj.pbd,report.pbd,"+gs_userpath+"\myrpttmp.pbl,rpttmp.pbl")



This returns -1 and the library is everything but the one in gs_userpath.

Now I'm noticing that I set the library to the PBDs but when I call GetLibraryList ( ) it returns a list of PBLs.

Help states that -1 means "The application is being run from PowerBuilder, rather than from a standalone executable". I don't nderstand what that means. I'm in debug mode so I am running from PB



C:\ProgramData does not exist in standard Win 10.

They wanted me to use the USER directory as it would exist on both Win 7 and Win 10
  1. Helpful
  1. John Fauss
  2. Tuesday, 12 May 2020 18:05 PM UTC
When you're running your application through the debugger, you're still running under the control of the PB Integrated Development Environment (IDE), so yes, the return code of -1 is correct. My understanding is the SetLibraryList PowerScript function can only be used from a compiled application (either PBD's or DLL's), but not when the app is executed from within the PowerBuilder IDE.
  1. Helpful
  1. Roland Smith
  2. Tuesday, 12 May 2020 18:13 PM UTC
Correct
  1. Helpful
There are no comments made yet.
mike S Accepted Answer Pending Moderation
  1. Tuesday, 12 May 2020 16:37 PM UTC
  2. PowerBuilder
  3. # 3

why use libraryimport at all?

Just create the datawindow from the syntax.

 

"store datawindow syntax in the database, extract it... use LibraryImport to create the datawindow object in this PBL.  "

 

 

 

Comment
  1. Roland Smith
  2. Tuesday, 12 May 2020 17:51 PM UTC
Correct, you can use the DataWindow Create function to instantiate the syntax directly into a control. No need for importing it into a library. Import would only be needed if it references another DataWindow that is also from the database.
  1. Helpful
There are no comments made yet.
Jay Hastings Accepted Answer Pending Moderation
  1. Tuesday, 12 May 2020 17:40 PM UTC
  2. PowerBuilder
  3. # 4

I set my library list with a string of PBDs

this.SetLibraryList("lance.pbd,lancepfc.pbd,framewrk.pbd,pbshared.pbd....etc)

When I call GetLibraryList I get a string of PBL's which is the actual application library list , not what I've set.  Maybe I want the order rearranged vs how I have it.

Is this an issue?  Any workaround?

 

Jay

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 12 May 2020 19:08 PM UTC
  2. PowerBuilder
  3. # 5

Hi Jay;

   The "AddToLibrary" command will do the job. I use that approach quite often. Note though that this command only works from an EXE.

   FWIW: I would locate the PBL in the User's Work Area. Typically ... APPDATA = "C:\Users\<UserName>\AppData\Roaming". Just allocate a folder under that for your App and read/write from there.

     In my PC, it's ... "APPDATA=C:\Users\Chris\AppData\Roaming\OrderEntry" for my STD Framework OrderEntry Demo App.

HTH

Regards ... Chris

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