It is remarkably difficult to show a Windows message box in GAMS and react on it at execution time:
$onecho > q.vbs
Select Case MsgBox("No data for ID=" & WScript.Arguments.Item(0) & " Continue?",4,"Database Error")
returnValue = 1
returnValue = 0
errorID(*) 'dynamic set with error IDs'
* assume we have an error
errorID('myErrorId') = yes;
rc 'return code' /0/
* I don't want to put out anything, but this $%!%@$$#! put_utility requires it
file dummy /xx/;
put_utility 'exec' / 'cscript //nologo q.vbs ' errorID.tl;
rc = ErrorLevel;
I always cringe when I need to use this dreaded put_utility.
Background: in theory database systems can be designed such that data is always consistent. In practice almost all databases contain data problems. Somehow when doing optimization models we hit these errors more often than other db applications. This code is related to a larger model where we need to react on detecting some form of db error, i.e. stop or try to fix and continue.