Format error with sample Oxygène code copied from docs

Hi Everyone,

I’m new to the world RemObjects and was exploring some of the sample Oxygène code. I copied and pasted some sample code from the String interpolation section. And it would appear that this particular block of code gives both Water and Fire a conniption fit. :nerd_face: It is repeatable on both platforms.

Cheers,

Gary

namespace ConsoleApplication12;

type
  Program = class
  public

    class method Main(args: array of String): Int32;
    begin
      // add your own code here
      writeLn('The magic happens here.');
  
      var lValue := 5;

       var MyString := $'The {{curly} gets replaced by a {lValue}'; // "The {curly} gets replaced by 
  5"

    end;

  end;

end.

An exception occurred in ConsoleApplication12, thread 758F

Type: RemObjects.Elements.System.Exception

Message:

format error

Call Stack:

000000010294FF40 _ElementsRaiseException ConsoleApplication12
000000010295BB0E _ms_s6_Formatnsna_o ConsoleApplication12
000000010294E066 ConsoleApplication12.Program.Main ConsoleApplication12 (Program.pas, line 14)
000000010294DF99 ___elements_entry_point ConsoleApplication12
00007FFF205E8621 _start libdyld.dylib

Gary,

I apologies for this; this does indeed seem to be a bug with escaping the first double-curly braces; I can reproduce this hear and will log an issue; hopefully we can get this fixed for Friday’s build.

   var MyString := $'The curly gets replaced by a {lValue}'; 

works fine; a potential (ugly) workaround if you *need& there curly printed would be

   var MyString := $'The {"{"}curly{"}"} gets replaced by a {lValue}';

Thanks, logged as bugs://85537

Thank you Marc for the temporary workaround! :slight_smile: I noticed in the sample code that only the first curly bracket is escaped and not the second. {{ curly } vs {{ curly }}. Does Oxygène only need to escape the first curly brace or would that be a typo?

var lValue := 5;

var MyString := $'The {{curly} gets replaced by a {lValue}'; // "The {curly} gets replaced by 5"

If all is working correctly, a single } should be fine in the regular string body. only there { needs to be escaped, to indicate that it’s not, indeed, an inline bit of code but just a character (much like mud double the ' or ".

bugs://85537 got closed with status fixed.

bugs://85537 got reopened.

bugs://85537 got closed with status fixed.