Re: PowerCobol
- From: Jeff Campbell <n8wxs@xxxxxxxx>
- Date: Sat, 28 Jan 2006 16:56:30 -0700
Alain Reymond wrote:
ProdCil a écrit :I can make thi: INVOKE pow-self "Execute" USING "notepad.exe text.txt"
I want to do the same, but calling "text.chm" for help files and "text.pdf", for example.
If i do: INVOKE pow-self "Execute" USING "AcroRd32.exe text.pdf"
don't work.How can call a .HLP or .PDF files in Power Cobol
You can call the windows function that opens a file based on the extension association.
In MF Cobol, it is call WINAPI ShellExecute using by value 0 size 4, *> window handle by reference z"open", *> operation to perform by reference z"myfile.pdf", *> document to open by value 0 size 4, *> parameters (none here) by reference sw-cwd, *> directory by value SW-SHOWNORMAL *> show the file when open returning se-hInstance end-call
and there must be the equivalent in PowerCobol (it's the windows API).
If Acrobat is installed on the computer, all pdf files should be associated with that application. When you call the ShellExecute api, it looks at the file extension at starts the application associated with it.
a myfile.txt will start notepad, etc...
You don't have to worry about where the application is installed...
Regards.
Alain
Here is a PowerCobol version:
ENVIRONMENT DIVISION. * special-names. * symbolic constant * SW-SHOWNORMAL is 1. DATA DIVISION. WORKING-STORAGE SECTION. * These group items are C-style null terminated strings. 1 open-command. 2 filler pic x(4) value "open". 2 filler pic x(1) value low-value.
1 file-to-open. 2 filler pic x(12) value "THF6A_OM.pdf". 2 filler pic x(1) value low-value.
1 default-directory. 2 filler pic x(17) value "D:\downloads\pdfs". 2 filler pic x(1) value low-value.
77 se-hInstance pic s9(9) comp-5. 77 ReturnValue pic s9(9) comp-5.
PROCEDURE DIVISION. *** To use this routine, the SHELL32.LIB file needs to be added *** to the PowerCobol project.
call "ShellExecuteA" with stdcall linkage
using
by value 0 *> window handle
by reference
open-command *> operation to perform
file-to-open *> document to open
by value 0 *> parameters (none here)
by reference
default-directory, *> directory (could also be null)
by value 1 *> SW-SHOWNORMAL show the file when open
returning
se-hInstance *> not 'really' a handle,
*> more an error return
end-call if se-hInstance is not greater than 32 then
INVOKE pow-self "DisplayMessage"
USING "Could not open document" "Bad Open" POW-DMICONERROR
RETURNING ReturnValue
end-ifexit program
. *> term
Hope that helps!,
Jeff Campbell N8WXS
----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups ----= East and West-Coast Server Farms - Total Privacy via Encryption =---- .
- Follow-Ups:
- Re: PowerCobol
- From: ProdCil
- Re: PowerCobol
- References:
- PowerCobol
- From: ProdCil
- Re: PowerCobol
- From: Frederico Fonseca
- Re: PowerCobol
- From: ProdCil
- Re: PowerCobol
- From: Alain Reymond
- PowerCobol
- Prev by Date: Re: cobol code assessment
- Next by Date: Re: cobol code assessment
- Previous by thread: Re: PowerCobol
- Next by thread: Re: PowerCobol
- Index(es):