For Programmers: Free Programming Magazines  


Home > Archive > Cobol > January 2006 > PowerCobol









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author PowerCobol
ProdCil

2006-01-27, 7:55 am

How can call a .HLP or .PDF files in Power Cobol

Thank you for any help
Joe


Frederico Fonseca

2006-01-27, 7:55 am

On Fri, 27 Jan 2006 12:10:46 -0000, "ProdCil" <nospam_prodcil@sgs.com>
wrote:

>How can call a .HLP or .PDF files in Power Cobol
>
>Thank you for any help
>Joe
>

what exactly are you trying to accomplish? a LOT more details please


Frederico Fonseca
ema il: frederico_fonseca at syssoft-int.com
ProdCil

2006-01-27, 6:55 pm

Thanks Frederico,

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.

Regards




"Frederico Fonseca" <real-email-in-msg-spam@email.com> wrote in message
news:o27kt11o4i8vhlcvf6rsqqtvjmtaetcimc@
4ax.com...
> On Fri, 27 Jan 2006 12:10:46 -0000, "ProdCil" <nospam_prodcil@sgs.com>
> wrote:
>
> what exactly are you trying to accomplish? a LOT more details please
>
>
> Frederico Fonseca
> ema il: frederico_fonseca at syssoft-int.com



HeyBub

2006-01-27, 6:55 pm

ProdCil wrote:
> Thanks Frederico,
>
> 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.


Here's how we get access to a helpfile:

02 HANDLE PIC S9(9) COMP-5.
02 HELPFILE PIC X(255).
02 FILLER PIC X VALUE LOW-VALUES.
02 HELPHANDLE PIC S9(9) COMP-4.
02 HELPREQUEST.
05 HELPREQUEST-A PIC S9(4) COMP-5.
05 FILLER PIC X(2) VALUE LOW-VALUES.


COMPUTE SUBCOMMAND = FUNCTION NUMVAL(TOPIC-NUMBER-X).
MOVE "Hwnd" of pow-self TO HANDLE
MOVE 1 TO HELPREQUEST-A.
CALL "WinHelpA" WITH STDCALL LINKAGE USING
BY VALUE HANDLE
BY REFERENCE HELPFILE
BY VALUE HELPREQUEST-A
BY VALUE SUBCOMMAND.


Oliver Wong

2006-01-27, 6:55 pm


"ProdCil" <nospam_prodcil@sgs.com> wrote in message
news:newscache$cxerti$x3j$1@newsfront4.netvisao.pt...
> Thanks Frederico,
>
> 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.


I don't know why COBOL would treat notepad.exe differently from
AcroRd32.exe. Did you verify that:

(1) the "AcroRd32.exe" file actually exists
(2) "AcroRd32.exe" is in the search path

?

- Oliver


Alain Reymond

2006-01-28, 3:55 am

ProdCil a écrit :[color=darkred]
> 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.

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
Jeff Campbell

2006-01-28, 6:55 pm

Alain Reymond wrote:
> ProdCil a =E9crit :
>=20
> You can call the windows function that opens a file based on the
> extension association.
>=20
> 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
>=20
>=20
> and there must be the equivalent in PowerCobol (it's the windows API).
>=20
> If Acrobat is installed on the computer, all pdf files should be
> associated with that application. When you call the ShellExecute api, i=

t
> looks at the file extension at starts the application associated with i=

t.
>=20
> a myfile.txt will start notepad, etc...
>=20
> You don't have to worry about where the application is installed...
>=20
> Regards.
>=20
> 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-if

exit 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 =----
ProdCil

2006-01-30, 7:55 am

grateful to all for the help



"Jeff Campbell" <n8wxs@arrl.net> wrote in message
news:1138493465_3767@sp6iad.superfeed.net...
Alain Reymond wrote:
> ProdCil a écrit :
>
> 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-if

exit 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
----=ast and West-Coast Server Farms - Total Privacy via Encryption =--


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com