Consultor Eletrônico



Kbase P102585: How to open a file using its associated application from the ABL on Windows using OS-COMMAND
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   6/11/2008
Status: Verified

GOAL:

How to open a file using its associated application from the ABL on Windows?

GOAL:

How to start the application associated with a specific file type?

GOAL:

How to open a web page in the default web browser from 4GL ?

GOAL:

How to start Windows Explorer from 4GL ?

FACT(s) (Environment):

Progress 9.x
OpenEdge 10.x
Windows

FIX:

This can be achieved by using the OS-COMMAND statement. The Windows shell is aware of the file associations. The Windows shell will open the associated application for any file used as a command when the file is not itself executable. This is what happens in the Explorer when using the action "open".
To use this feature from the Windows shell, simply use the statement OS-COMMAND from the ABL.

OS-COMMAND VALUE("start " + <token>).

This will rely on Windows standard behavior to identify the appropriate action:
- If the token is a filename, Windows will search for an associated program and use that to open the file. (It will pop up an "Open With..." dialog if no program is associated with the file type.)
- If the token is a directory reference, Windows Explorer will open starting on that directory.
- If the token is a URL, Windows will open it in the default web browser registered for the system.


For example:
/* this statement will open test.txt with any application currently associated with the .txt extension */
OS-COMMAND NO-WAIT "test.txt".