translate C# WriteLine to Visual COBOL

The following C# console program, when translated to the following Visual COBOL equivalent, produces different results - apparently the tab (the \t escape sequence) is not recognized in the COBOL version of the program (???).

C# :

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace csConTest1

{

    class Program

         {

        static void Main(string[] args)

                 {

             Console.WriteLine("\t{0}\t{1}\t{2}",

                               "1", "2", "three");

                 }

         }

}

 

Visual COBOL:

        program-id. Program1 as "cblConTest1.Program1".

        data division.

        working-storage section.

        procedure division.

            Invoke type Console::WriteLine("\t{0}\t{1}\t{2}",

                                           "1", "2", "three");

            goback.

         end program Program1.

 

  • ... also notice that Visual COBOL ignored / had no issue with the semicolon at the end of the statement...

  • Verified Answer

    Strangely (and rather annoyingly) semicolon and comma have always been treated as white space by COBOL.  I believe this was already the case in ANS 74 COBOL, and remains the case now.  It would be nice if for instance the comma could be used to separate parameters in an invoke parameter list, but COBOL does not work like that...

  • Verified Answer

    As for the main point (support for /t etc.) it's true this is not supported by COBOL, and it would probably be difficult to introduce support at this stage because of compatibility issues.

    You can do something like:

              Invoke type Console::WriteLine(x"09" & "{0}" & x"09" & "{1}" & x"09" &" {2}", "1", "2", "three");

    ..or maybe:

    78 tab-char value x"09".

    ... and then:

              Invoke type Console::WriteLine(tab-char & "{0}" & tab-char & "{1}" & tab-char &" {2}", "1", "2", "three");

    Not very elegant but should do the job...