Question
· May 26, 2021

How to add a try / catch block inside a routine that contains indentation with "." characters ?

I have some code in a mac routine that use indentation and the "." character : 
 

 IF condition1 DO
     .WRITE YCR,...
     .WRITE YCR,...
     .WRITE YCR,...

I would like to add a try / catch block between the write statements.
I can't refactor the whole code and use indentation with curly braces instead (there is too much code, not written by me)

I have tried the following but it does not work (it compiles, but code stop running right before the try keyword)

 IF condition1 DO
    try {
        .WRITE YCR,...
        .WRITE YCR,...
        .WRITE YCR,...
    }
    catch {
    }

Is this something supported ? If yes, what is the syntax to use?

It seems to be OK if I include the if inside the try catch :

try {
     IF condition1 DO
        .WRITE YCR,...
        .WRITE YCR,...
        .WRITE YCR,...
 }
 catch {
 } 
Product version: Caché 2018.1
Discussion (2)0
Log in or sign up to continue