When building a report, or outputting information to the screen about your IBM MQ Queue Manager, you may wish to manipulate strings, as is shown in a new example script, mqauthlist.mqsx, available in our Example Scripts bundle. This script builds an array of temporary dynamic queues to exclude from the report later. Some string manipulation is done on the names to make the search easier using the strreplace() function of MQSCX to replace underscores with dots. Here’s how:-
** Query the queue manager for the current temporary dynamic queues delvar(@tempqlist) @x = 0 foreach(DISPLAY QLOCAL(*) WHERE(DEFTYPE EQ TEMPDYN)) if( !_cmdok ) print "Error querying TempDyn queues for queue manager", _qmgr continue endif @x = @x + 1 ** In order for the search to work properly, ** we need to uppercase the queue names ** and substitute underscores with periods. @tempqlist[@x] = strreplace(upper(QUEUE), "_", ".") endfor
Of course there are many uses you might find for using the strreplace() function, especially if you want to work with MQ object names that follow a Naming Convention, then you might find yourself wanting to replace the characters TEST with the characters PROD when working with different environments for Test and Production.
The best way to understand scripts is of course to have a go with them yourself. There are various examples in the download, so why not try them out yourself. If you are not currently an MQSCX licence holder, you may email email@example.com to request a trial licence.