Executing code for specific platforms – PB Docs 70

Executing code for specific platforms

If your application has platform-specific behavior but you
don’t want to edit scripts when you move it to another
platform, you can write a script that finds out the operating system
the user has and executes code appropriate for that system.

GetEnvironment function

The PowerBuilder Environment object holds information about
the computing platform the application is running on. You populate
the Environment object by calling the GetEnvironment function.

The following code template illustrates the use of the GetEnvironment
function with the CHOOSE CASE statement:

In addition to the operating system, you can find out the
specific CPU, the version of the operating system and of PowerBuilder,
and information about the screen display.

For a list of the properties of the Environment
object, see the Browser or online Help.

When you need conditional code

Some typical situations that require conditional code are:

  • Setting values in
    transaction objects for accessing a database
  • Specifying filenames and paths–for example,
    a program name for the Run function or a filename for FileOpen
  • Instead of using platform-specific code, you could
    avoid specifying a path and put all files in the application’s
    current directory and you could restrict the filenames to the DOS
    8+3 format

For an example of using the GetEnvironment
function to determine screen size, see “Window placement and
screen size”

Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x