Skip to content

Instantly share code, notes, and snippets.

@MikeWills
Created April 11, 2011 21:23
Show Gist options
  • Save MikeWills/914384 to your computer and use it in GitHub Desktop.
Save MikeWills/914384 to your computer and use it in GitHub Desktop.
A common and consistent error message/message prompting module. Also uses https://gist.github.com/914365
/* ********************************************************************** */
/* Program . . . . . ADVERROR */
/* */
/* Created on . . . 08/10/2004 */
/* by . . . Mike Wills (http://mikewills.me) */
/* */
/* Description . . . */
/* */
/* CHANGE LOG: */
/* Date | Name | Description */
/* ---------------------------------------------------------------------- */
/* | | */
/* | | */
/* | | */
/* ************************************************************************/
STRPGMEXP PGMLVL(*CURRENT) LVLCHK(*YES) SIGNATURE('1.10')
EXPORT SYMBOL(ErrorMsg)
EXPORT SYMBOL(PromptMsg)
ENDPGMEXP
H NoMain
H BNDDIR('MODULES')
//*************************************************************************
// Program . . . . . ADVERROR
//
// Created on . . . 08/10/2004
// by . . . Mike Wills (http://mikewills.me)
//
// Description . . .
//
// CHANGE LOG:
// Date | Name | Description
// -----------------------------------------------------------------------
// | |
// | |
// | |
//*************************************************************************
FADVERRORFMCF E WORKSTN USROPN
// Prototypes
/copy qsrvsrc,adverror_h
/copy modules/qsrvsrc,string_h
// **********************************************************************
// Global Definitions
P*--------------------------------------------------
P* Procedure name: ErrorMsg
P* Purpose: Pop-up a screen with a longer error message
P* Returns:
P* Parameter: errorText
P*--------------------------------------------------
P ErrorMsg B EXPORT
D ErrorMsg PI
D errorText 150A VARYING
D CONST
D len S 3P 0
/free
if (not %open(ADVERRORFM));
open ADVERRORFM;
endif;
retWordWrap = WordWrap(errorText:50);
wError1 = %subst(retWordWrap(1):1:50);
wError2 = %subst(retWordWrap(2):1:50);
wError3 = %subst(retWordWrap(3):1:50);
exfmt ERRORSCRN;
close ADVERRORFM;
return;
/end-free
P ErrorMsg E
P*--------------------------------------------------
P* Procedure name: PromptMsg
P* Purpose: Pop-up a screen with a longer error message
P* Returns:
P* Parameter: errorText
P*--------------------------------------------------
P PromptMsg B EXPORT
D PromptMsg PI N
D errorText 150A VARYING
D CONST
D len S 3P 0
/free
if (not %open(ADVERRORFM));
open ADVERRORFM;
endif;
retWordWrap = WordWrap(errorText:50);
wError1 = %subst(retWordWrap(1):1:50);
wError2 = %subst(retWordWrap(2):1:50);
wError3 = %subst(retWordWrap(3):1:50);
exfmt PROMPTSCRN;
if (not *in12);
if (wPrompt = 'Y');
return *on;
else;
return *off;
endif;
endif;
close ADVERRORFM;
return *off;
/end-free
P PromptMsg E
// **********************************************************************
// Copybook for misc commands
D*--------------------------------------------------
D* Procedure name: ErrorMsg
D* Purpose: Pop-up a screen with a longer error message
D* Returns:
D* Parameter: errorText
D*--------------------------------------------------
D ErrorMsg PR
D errorText 150A VARYING
D CONST
D*--------------------------------------------------
D* Procedure name: PromptMsg
D* Purpose: Pop-up a screen with a longer error message
D* Returns:
D* Parameter: errorText
D*--------------------------------------------------
D PromptMsg PR N
D errorText 150A VARYING
D CONST
A* ***********************************************************************
A* Compiler Options:
A* COMPILE OPTIONS HERE
A*
A* File . . . . . . ADVERRORFM
A* For Program . . ADVERROR
A*
A* Created on . . . 08/10/2004
A* by . . . Mike Wills (http://mikewills.me)
A*
A* Description . . . Display Screen for ADVERROR.
A*
A* CHANGE LOG:
A* Date | Name | Description
A* -----------------------------------------------------------------------
A* | |
A* | |
A* | |
A* ***********************************************************************
A DSPSIZ(24 80 *DS3)
A PRINT
A CA12(12)
A R ERRORSCRN
A WINDOW(7 15 8 52)
A WDWBORDER((*COLOR RED) (*DSPATR RI)-
A (*CHAR ' '))
A OVERLAY
A 1 23'Warning'
A COLOR(RED)
A WERROR1 50 O 3 2COLOR(RED)
A WERROR2 50 O 4 2COLOR(RED)
A WERROR3 50 O 5 2COLOR(RED)
A 7 2'F12=Close'
A COLOR(BLU)
A R PROMPTSCRN
A WINDOW(6 15 10 52)
A WDWBORDER((*COLOR BLU) (*DSPATR RI)-
A (*CHAR ' '))
A OVERLAY
A 1 20'Are You Sure?'
A COLOR(WHT)
A WERROR1 50 O 3 2COLOR(WHT)
A WERROR2 50 O 4 2COLOR(WHT)
A WERROR3 50 O 5 2COLOR(WHT)
A 9 2'F12=Close'
A COLOR(BLU)
A WPROMPT 1 I 7 19COLOR(WHT)
A CHECK(ER)
A 7 21'(Y)es or (N)o'
A COLOR(WHT)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment