Quantcast
Channel: Visual COBOL - Forum - Recent Threads
Viewing all articles
Browse latest Browse all 4356

"Call winapi..." fails in chained-to prog, works in called prog?

$
0
0

Hi,

CALL WINAPI "MessageBoxA", gets windows "114 Attempt to access item beyond bounds of memory:" when I CHAIN to prog below but works if I CALL the prog.

I want to chain to it when a db error occurs so that all resources are freed (file locks etc) even if user doesn't close my pop up box. I'm running within Visual studio i.e. in development environment.

I'm using Visual COBOL / Windows 10.

Thanks, Linden

 

environment division.
special-names.
call-convention 74 is winapi.
data division.
working-storage section.
01 retCode pic x(4) comp-5 value zero.
01 msgCaption pic x(255) value
z"TNL Advertising Management System Error Report".
01 uType pic x(4) comp-5 value 273. *> 305.
01 msgText pic x(1000).
01 username pic x(100).

linkage section.
01 callersMsgText pic x(1000).
procedure division using callersMsgText.

*> IF HERE THIS PROG HAS BEEN CHAINED TO, NOT CALLED, SO
*> THAT RESOURCES HELD BY CALLING PROG ARE RELEASED BEFORE
*> ABORT MSG SHOWN. HENCE IF USER DOESN'T CLOSE THIS MSG BOX
*> NO FILES ARE HELD OPEN ETC.
display 'USERNAME' upon environment-name.
accept username from environment-value.

string 'AN ERROR OCCURRED.' x'0d0a0d0a'
'PLEASE email screen print to:' x'0d0a'
'Linden Rowland ('
'TNL Ad. Management System developer)' x'0d0a'
'lindenrowland@yahoo.com'
' or contact Tindle IT.' x'0d0a0d0a'
'DETAILS:' x'0d0a'
'Windows account name: ' username x'0d0a'
callersMsgText(1:900)
x'0d0a0d0a'
'CLICK OK. TNL Ad. Management System will shut down.'
x'00'
delimited by ' ' into msgText.

initialize retCode.
perform until retCode = 1
call WINAPI "MessageBoxA"
using by value 0 size 4
by reference msgText, msgCaption
by value uType
returning retCode
end-call
end-perform.

STOP RUN.


Viewing all articles
Browse latest Browse all 4356

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>