Openedge Abl Portable Applications
Openedge Abl Portable Applications
Openedge Abl Portable Applications
Copyright
© 2020 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.
®
These materials and all Progress software products are copyrighted and all rights are reserved by Progress
Software Corporation. The information in these materials is subject to change without notice, and Progress
Software Corporation assumes no responsibility for any errors that may appear therein. The references in
these materials to specific platforms supported are subject to change.
Corticon, DataDirect (and design), DataDirect Cloud, DataDirect Connect, DataDirect Connect64, DataDirect
XML Converters, DataDirect XQuery, DataRPM, Defrag This, Deliver More Than Expected, Icenium, Ipswitch,
iMacros, Kendo UI, Kinvey, MessageWay, MOVEit, NativeChat, NativeScript, OpenEdge, Powered by Progress,
Progress, Progress Software Developers Network, SequeLink, Sitefinity (and Design), Sitefinity, SpeedScript,
Stylus Studio, TeamPulse, Telerik, Telerik (and Design), Test Studio, WebSpeed, WhatsConfigured,
WhatsConnected, WhatsUp, and WS_FTP are registered trademarks of Progress Software Corporation or one
of its affiliates or subsidiaries in the U.S. and/or other countries. Analytics360, AppServer, BusinessEdge,
DataDirect Autonomous REST Connector, DataDirect Spy, SupportLink, DevCraft, Fiddler, iMail, JustAssembly,
JustDecompile, JustMock, NativeScript Sidekick, OpenAccess, ProDataSet, Progress Results, Progress
Software, ProVision, PSE Pro, SmartBrowser, SmartComponent, SmartDataBrowser, SmartDataObjects,
SmartDataView, SmartDialog, SmartFolder, SmartFrame, SmartObjects, SmartPanel, SmartQuery, SmartViewer,
SmartWindow, and WebClient are trademarks or service marks of Progress Software Corporation and/or its
subsidiaries or affiliates in the U.S. and other countries. Java is a registered trademark of Oracle and/or its
affiliates. Any other marks contained herein may be trademarks of their respective owners.
March 2020
Updated: 2020/09/10
Table of Contents
Code style.....................................................................................................15
Purpose
OpenEdge lets you build one application that runs in multiple environments. This set of topics discuss some
of the coding issues involved with writing OpenEdge applications that are portable across system environments,
interfaces, and databases.
• Naming conventions for files, tables, and variables on page 9
• Operating system statements on page 11
• Code style on page 15
Audience
This guide is intended for ABL developers who are interested in writing portable applications.
Organization
Naming conventions for files, tables, and variables on page 9
Operating system statements on page 11
Code style on page 15
Documentation conventions
See Documentation Conventions for an explanation of the terminology, format, and typographical conventions
used throughout the OpenEdge content library.
Purpose
OpenEdge lets you build one application that runs in multiple environments. This set of topics discuss some
of the coding issues involved with writing OpenEdge applications that are portable across system environments,
interfaces, and databases.
• Naming conventions for files, tables, and variables on page 9
• Operating system statements on page 11
• Code style on page 15
Audience
This guide is intended for ABL developers who are interested in writing portable applications.
Organization
Naming conventions for files, tables, and variables on page 9
Operating system statements on page 11
Code style on page 15
Documentation conventions
See Documentation Conventions for an explanation of the terminology, format, and typographical conventions
used throughout the OpenEdge content library.
Different operating systems have different restrictions and naming conventions. To ensure portability across
platforms, use the conventions described in this topic when naming your fields, files, tables, and variables.
Characters to avoid
Several characters have special meanings or are invalid in one or more supported operating systems. Avoid
using these characters:
Do not use a hyphen as the first character of a filename. Do not use spaces in filenames; spaces delimit
filenames.
Case sensitivity
Although operating system filenames are not case sensitive in Windows, they are on UNIX. On systems where
operating system filenames are case sensitive, filenames and command names in uppercase are different
from those in lowercase. By convention, lowercase is used for most UNIX filenames.
To ensure portability among operating systems, use lowercase when specifying a procedure name in a RUN
statement, and make sure your procedure files have lowercase names on UNIX.
The next set of topics explain how you can use operating system statements in portable ABL applications:
• OS-COMMAND
For example, the following procedure produces a listing of the files in your current directory. The OPSYS function
determines the operating system you are running OpenEdge on and uses the appropriate operating system
command to produce the directory listing:
CASE OPSYS:
WHEN "unix" THEN OS-COMMAND ls.
WHEN "win32" THEN OS-COMMAND dir.
OTHERWISE MESSAGE OPSYS "is an unsupported operating system".
END CASE.
To use operating system commands from within OpenEdge, use either the operating system statement for the
operating system you are running on or the OS-COMMAND statement. For example, use the OS-COMMAND
statement on a Windows system and on a UNIX system. If you include the operating system statement in a
procedure on a system other than the one named, the procedure compiles but does not run if the flow of control
passes through that operating system statement. OpenEdge might report an error when it tries to process an
operating system statement on a system other than the one named. See the ABL Reference for more information
on the OPSYS function.
You can also use the built-in preprocessor directive, {&OPSYS}, which expands to a character string that
contains the name of the operating system that the file is being compiled on.
The preprocessor is a component of the OpenEdge Compiler. You control the preprocessor by placing
preprocessor directives throughout your source code.
The {&OPSYS} preprocessor directive allows you to write code that is conditionally compiled, while the OPSYS
function is a run-time function. For more information on preprocessor names, see the "Preprocessor" topics of
Manage ABL Applications.
Table 1: OS statements
OS statement Description
Performs a system call to execute the operating system command that appends
OS-APPEND two files.
Performs a system call to execute an operating system command that you specify.
OS-COMMAND
Performs a system call to execute the operating system command that copies a
OS-COPY file.
Performs a system call to execute the operating system command that creates a
OS-CREATE-DIR new directory.
Performs a system call to execute the operating system command that deletes a
OS-DELETE file or directory.You can delete one or more files, a directory, or an entire directory
branch.
Performs a system call to execute the operating system command that returns a
OS-DRIVES comma-separated list of the available drives in Windows.
Performs a system call to execute the operating system command that returns a
OS-GETENV string containing the value of the specified environment variable in the environment
in which OpenEdge is running.
Performs a system call to execute the operating system command that renames
OS-RENAME a file or directory.
OS-COMMAND
Use the OS-COMMAND statement to execute an operating system statement that you cannot execute using the
OS statements listed in Standard system commands on page 12. The OS-COMMAND statement provides a
generic, operating-system-independent way to escape to the current operating system, which lets you:
• Execute a OpenEdge or operating system command that has the same syntax on two or more different
operating systems.
• Start an operating system shell.
• Execute an operating system statement that a user enters.
The arguments to OS-COMMAND must be appropriate for the current operating system. Therefore, where
possible, read these arguments at run time from the user, database table, or environment variables rather than
hard coding them. The following procedure prompts the user for an operating system command, then uses the
OS-COMMAND statement to execute the command:
The OS-COMMAND statement eliminates the need to use the OPSYS function to determine the operating system.
However, if you cannot use the OS-COMMAND statement, use the OPSYS function to determine the operating
system you are running on, and use conditional logic to execute the appropriate code using one of the
operating-system-specific escape statements.
The NO-WAIT option of OS-COMMAND is valid only in multi-tasking environments. This option causes OpenEdge
to pass control to the statement following the OS-COMMAND, without waiting for the operating system command
to terminate. If you are using the OS-COMMAND statement to run an independent Windows application, use the
NO-WAIT option.
For more information, see the OS-COMMAND Statement reference entry in ABL Reference.
When you use the OS-DIR option, the UNBUFFERED option is ignored. OS-DIR always buffers exactly one
filename at a time. When you try to read beyond the last filename in the list, OpenEdge generates the ENDKEY
condition.
See ABL Reference for more information on the INPUT FROM statement.
FORM
fld1
fld2
&IF "{&WINDOW-SYSTEM}" = "MS-WIN97" &THEN
fld3 AT 20
&ELSE
fld3 AT 15
&ENDIF
WITH FRAME XYZ.
The SESSION system handle also has a WINDOW-SYSTEM attribute. Your application can use this to test the
current window system while it is running:
Both the &WINDOW-SYSTEM preprocessor constant and the SESSION handle WINDOW-SYSTEM attribute perform
the same basic function. The &WINDOW-SYSTEM preprocessor constant allows you to write code that is
conditionally compiled, while the WINDOW-SYSTEM attribute is a run-time function.
The WINDOW-SYSTEM attribute evaluates as follows:
• If Windows nn is running, and the Windows nn user interface is running, this attribute evaluates to MS-WINnn.
Otherwise, if the Windows nn user interface is not running, it evaluates to MS-WINDOWS.
• If the application is not running in a Windows environment, this attribute evaluates to TTY.
OpenEdge supports an override option that enables applications that require a WINDOW-SYSTEM attribute to
return the value of MS-WINDOWS for all Microsoft operating systems. To establish this override capability, define
the Window System key in the Startup Section of the current environment, which might be in the registry or an
initialization file. If the Window System key is located, the WINDOW-SYSTEM attribute returns the value associated
with the Window System key on all platforms.
You can also specify offsets and ROW and COLUMN specifications using preprocessor constants, then define
the constants separately for different environments. OpenEdge allows you to specify fractional character units
so that you can specify precise locations for objects in a graphical environment. In a character environment,
the ROW and COLUMN values are truncated to integer values, as follows: