I wanted to have an easy way to pop-up a message to inform users of something going on. I used the QUILNGTX API to create a utility that pops up a message box with a title from any application or command line. To use it:
msgbox message('...') title('..')
msgbox 'job is submitted'
msgbox ('job submitted at ' *cat &date)
msgbox (('this program is offline') ('**ERROR**'))
The message can be up to 255 characters. The title is optional and can be up to 27 characters. The title appears centered on the box.
The 255 character length was arbitrary can could be increased - if you care to tweak the command and code.
MESSAGE rpgile
---------------
h dftactgrp(*no) actgrp('QILE')
h option(*srcstmt:*nodebugio)
DMsgBox pr extpgm('QUILNGTX')
D LngTxt 255a
D TextLen 10i 0 const
D TxtTitle 7a
D TxtMsgF 20a
D ErrCode 16a
d Text s 255a inz(*blank)
d String s 255a inz(*blank)
d Title s 7a inz(*blank)
d MessageF s 20a inz(*blank)
d Error s 16a
d TitleString s 27 varying inz(*blank)
d tx s 2 0
d BlankString s 27 inz(*blank)
D JobType S 1
DRtvJobA pr extpgm('QUSRJOBI')
D rtv_Data 100a
D rtv_Length 10i 0 const
D rtv_Format 8a
D rtv_Job 26a
D rtv_IntJob 16a
D p_Rcvr S 100
D p_Format S 8 INZ('JOBI0100')
D p_ThisJob S 26 INZ('*')
D p_IntJob S 16
c clear title
c clear title
c clear messagef
c *entry plist
c parm inString 255
c parm inTitle 27
c if %parms = 1
c eval String = inString
c endif
c if %parms = 2
c eval String = inString
c eval TitleString = %trim(inTitle)
c endif
c if TitleString <> *blank
c if %len(titlestring)< 27
c eval tx=((27-%len(titlestring))/2)
c eval titlestring=%subst(blankstring:1:tx)
c +titlestring
c +titlestring
c eval titlestring=titlestring
c +%subst(blankstring:1:%len(titlestring))
c if %subst(titlestring:1:1)=*blank
c eval %subst(titlestring:1:1)='.'
c endif
c if %subst(titlestring:27:1)=*blank
c eval %subst(titlestring:27:1)='.'
c endif
c eval title=%subst(titlestring:1:7)
c eval messageF=%subst(titlestring:8:20)
c endif
c endif
C callp RtvJoba ( p_Rcvr :
C %len(p_Rcvr):
C p_Format :
C p_ThisJob :
C p_IntJob )
C EVAL JobType = %SUBST(P_Rcvr : 61 :1)
* B/atch I/nteractive P/restart?
c if JobType = 'I'
c eval Text=%trim(String)
c eval Error=''
c callp MsgBox(Text:
c %len(Text):
c Title:
c MessageF:
c Error)
c endif
c return
MSGBOX Command
---------------
CMD PROMPT('Display message in box')
PARM KWD(MESSAGE) TYPE(*CHAR) LEN(255) MIN(1) +
EXPR(*YES) CASE(*MIXED) PROMPT('Message +
to display')
PARM KWD(TITLE) TYPE(*CHAR) LEN(27) MIN(0) +
CASE(*MIXED) PROMPT('(opt.) Title for +
message') ================================== MORE INFORMATION ON THIS TOPIC ==================================
The Best Web Links: tips, tutorials and more.
Ask your programming questions--or help out your peers by answering them--in our live discussion forums.
Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.
This was first published in October 2002