Double quotes in TM1

This short article deals with double quotes in TM1: " or Char(34) (while a single quote is ' or Char(39)). In TM1, single quotes are used for textual constants, for example: vYear = 'Y2016'. In Excel we would use double quotes for that. Double quotes in TM1 can occur in text files. It happens that we encounter the double quotes twice, in which case we want to remove one of the pair of double quotes.

I had this case recently and wrote some small code to remove the excess double quotes. As it can be used by others as well, here it is.

Turbo Integrator code

Here is the case. The last column is called "Group".

m = 1;
While( m > 0 );

   m = Scan( '""', Group );
   If( m > 0 );
      Group = Insrt( '"', Delet( Group, m, 2 ), m );
# or:#     Group = Subst( Group, 1, m ) | Subst( Group, m + 2, Long( Group ));
# or:
#     Group = Delet( Group, m + 1, 1 );
   EndIf;

End;

Above we see three variants of the code, whereby the functions Scan, Insert, Subst and Delet are used. I prefer the third suggestion.

Alternatively you can use variables to hold the constant value of a double quote:

DQ = Char(34);
m = 1;
While( m > 0 );

   m = Scan( DQ | DQ, Group );
   If( m > 0 );
      Group = Insrt( DQ, Delet( Group, m, 2 ), m );
# or:
#     Group = Subst( Group, 1, m ) | Subst( Group, m + 2, Long( Group ));
# or:
#     Group = Delet( Group, m + 1, 1 );
   EndIf;

End;

You can choose for yourself what is easiest.




Homepage

Section contents

About Wim

Wim Gielis is a Business Intelligence consultant and Excel expert

Other links