|
发表于 2014-3-20 05:59:33
|
显示全部楼层
cdredmond wrote:I have the following code in the Prolog for parameter input verification:
Code: IF ( DIMIX ( Dim, vVersion ) = 0 ) ;
sMessage = 'Version ( ' | vVersion | ' ) does not exist.' ;
ItemReject ( sMessage ) ;
ProcessError ;
ENDIF ;
As expected, the message appears in the message log.
However, the process does not terminate, only the procedure terminates.
It then continues on to the Data procedure (no code in the Metadata procedure).
I have also tried ProcessBreak and ProcessQuit with the same result.
Anybody know of a method to reliably terminate a process from the Prolog?
Greetings to you in Portland, my favourite city of the north-west which I may never see again but retain fond memories of.
I'm afraid it is working as expected; the problem is with the ItemReject line.
Strictly speaking ItemReject has no context in the Prolog but a lot of people do use it to generate an error log. (Hi Martin!) It's a quick and easy way of achieving that result and as long as IBM never pulls this undocumented feature, there's nothing wrong with doing that.
HOWEVER... when you do that the Prolog, which only has one "item" and that of a virtual kind, stops stone motherless dead and never executes any following statements including your ProcessQuit (etc) statement. Instead it just heads straight for the next tab with code on it, if any. (Same basic behaviour as you get if you encounter the statement on the Metadata or Data tab; none of the code following the ItemReject is executed and it moves straight to the next record (if any).)
You have a couple of alternatives:
(a) (My preferred one) Instead of using an ItemReject, get the error log file by using the GetProcessErrorFilename function, manually write the output to it, THEN ProcessQuit out of the sucker inside the If block; or
(b) Set a flag variable to True if there's an error, and check that in the first line of your Data tab. ProcessQuit if the flag is set to your True value. However I'd regard this as a waste of processor cycles; option (a) is far better.
Incidentally despite the v tag at the start I'm assuming that this really is a parameter that you're checking and not a variable. Obviously none of the variables will have a value in the prolog either, so it would always error out. (I generally tag parameters with a "p" to distinguish them from variables, and I've noticed that that's not an uncommon practice. But it's not a mandatory one obviously.) |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|