1. Haakon Langballe
  2. PowerBuilder
  3. Wednesday, 16 October 2019 10:48 AM UTC

Hi.

I try to implement a user settings file, user.ini, to store different settings for my application.

The user.ini file content is liek this:

[DATABASE]
DBMS=ODBC
ServerName=demo_db

In the application I try to read the settings like this:

string ls_profile =  "user.ini"
string ls_servername = ProfileString(ls_profile, "DATABASE", "ServerName", "")

I always get the same value for ls_servername. It seems like i get the values set at compile time.

How do I correctly read user settings from an external file?

 

Thanks
Haakon

 

 

 

Roland Smith Accepted Answer Pending Moderation
  1. Wednesday, 16 October 2019 17:04 PM UTC
  2. PowerBuilder
  3. # 1

Basically the issue is that any function calls that are part of the variable declaration are executed at compile time, not at run time.

 

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

Hey Haakon,

Back in the '90s I trained most PB developers in Denmark. These days hard to find training or up-to-date books but there are options:

Appeon has online intro class (videos + lab exercises). This is basically updated version of the training we did in the '90s. This course expects you know how to develop in another OO language (like C++, C#, java, or Delphi) but expects you have close to no experience in PowerScript.

Course = PowerBuilder Fundamentals on Appeon-U.

The programming language of PB is PowerScript. You will learn it quickly. AutoScript (less advanced intellisense) has templates for the different control-flow statements.

The complex part of PowerBuilder is the DataWindow technology. This is where PowerBuilder sets itself apart from any other language/product. Basically the 2-way binding introduced in .NET 4.0 was part of the DataWindow since early 1990s. You will find large part of the training class focuses on DataWindow technology for a reason.

F1-Help contains complete product documentation. This includes Getting Started (level comparable to the online intro course. 

Application Techniques is a good intro to how system classes of PB work, how you can leverage them. Users Guide is more focused on how to navigate in the IDE to accomplish your DEV tasks.

PowerScript Reference and Objects and Controls are more reference manual style docs.

Several help "books" cover DataWindow and database connections:

  • DataWindow Programmers Guide
  • DataWindow Reference
  • Connecting to Your Database
  • Connection Reference

And then you have this community to help you when you get stuck. We are many long-time PowerBuilders all help you find the right docs and the right code examples.

There are som free frameworks for app development: PowerBuilder Foundation Classes (PFC) and STD Foundation Classes. They both have sample apps.

PowerBuilder itself comes with a bunch of sample apps as well. They are also worth looking into.

Finally, if you need to maintain existing software, also just reading code - and using [Shift+F1] for context ssensitive help is great way to start learning the detailed mechanics one function, event, property, or class at a time.

Welcome to PowerBuilder!

Godspeed /Michael

SIDEBAR
TopWiz is an excellent source of free code for solving real world problems that require deep product knowledge and high technical skills. You will see many references to this code throughout Q&A threads.

And many of the videos on community and Appeon's own website also cover many topics to learn from without being proficient in PB up front.

Comment
  1. Haakon Langballe
  2. Wednesday, 16 October 2019 15:35 PM UTC
Thanks for this excellent list Michael!

I'll work my way through the list and pick whats relevant. This community seems like a goldmine though.

I inherited an old project for a business application and I'm tasked to maintain and keep it alive. Porting it from Powerscript to C# is tempting but maybe not trivial.



Haakon
  1. Helpful
  1. Michael Kramer
  2. Wednesday, 16 October 2019 15:53 PM UTC
I have seen many projects kill themselves trying to migrate from PowerBuilder with DataWindows to C#/WPF, Java, or ASP.NET as web app.

It is so hard = takes lots of code and dev man hours to develop DataWindow like behavior.

Ronnie Po has presented at several conferences and webinars with fantastic UX using PB with DataWindows. Another article with links to videos: http://www.dw-extreme.com/
  1. Helpful
There are no comments made yet.
Haakon Langballe Accepted Answer Pending Moderation
  1. Wednesday, 16 October 2019 13:16 PM UTC
  2. PowerBuilder
  3. # 3

Thanks!

That did the trick! I've been struggling with the profile api. There are obvoiusly concepts I have not understood.

Powerscript is same but different from c++ / c#. Are ther any good (and up to date) books or other learning resources available out there?

 

Haakon

Comment
  1. Miguel Leeuwe
  2. Wednesday, 16 October 2019 15:03 PM UTC
I think in this aspect, Powerbuilder is different from any other language I know.
  1. Helpful
There are no comments made yet.
Michael Kramer Accepted Answer Pending Moderation
  1. Wednesday, 16 October 2019 11:10 AM UTC
  2. PowerBuilder
  3. # 4

Arthur is right.
Different semantics for PowerScript vs. C# when you provide initial value for the declaration.

  • PowerScript => Calculate at compile time
  • C# => Determine datatype and calculate at runtime

HTH /Michael

Comment
There are no comments made yet.
Arthur Hefti Accepted Answer Pending Moderation
  1. Wednesday, 16 October 2019 10:54 AM UTC
  2. PowerBuilder
  3. # 5

Hi

yes. This will get the value at compile time (see https://community.appeon.com/index.php/qna/q-a/variable-value-assignment-magic-pb-12-6)

You have to do:

string ls_profile =  "user.ini"
string ls_servername

ls_servername = ProfileString(ls_profile, "DATABASE", "ServerName", "")

 

Regards
Arthur

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.