I am checking the return from one of my procedures and want to create an error message. I am using the GAUSS errorlogat function. This works:
//ret is nonzero if the matrix is not invertible
if ret;
errorlogat "Matrix not invertible";
endp;
However, I want to also print the name of the variable which is a string. I am trying this below, but I get the error "Operator missing: G0063":
//ret is nonzero if the matrix is not invertible //myVar is a string with the name of the matrix if ret; errorlogat "Matrix " myVar " is not invertible"; endif;
1 Answer
0
accepted
The problem is that the errorlogat function is supposed to take just one string for its reporting. You need to make your entire error message into one string. This is easy to do in GAUSS with the $+ operator which merges the contents of two strings together like this:
stringA = "GDP"; stringB = "Inflation"; stringC = stringA$+stringB;
Now stringC will equal: "GDP Inflation".
For your example, this will work:
if ret; errorlogat "Matrix "$+myVar$+"is not invertible"; endif;
Your Answer
1 Answer
The problem is that the errorlogat function is supposed to take just one string for its reporting. You need to make your entire error message into one string. This is easy to do in GAUSS with the $+ operator which merges the contents of two strings together like this:
stringA = "GDP"; stringB = "Inflation"; stringC = stringA$+stringB;
Now stringC will equal: "GDP Inflation".
For your example, this will work:
if ret; errorlogat "Matrix "$+myVar$+"is not invertible"; endif;