Const array of record

Hi,
how could I translate the following delphi code into oxygene?

type
  TCmdSyntax = record
   Text: String;      
   ArgCount: Integer;
  end;

  TCmdToken = (
   cmdNOP = 0,
   cmdVER,
   cmdUSERID,
   cmdERROR
   );

const
  Syntax: Array[TCmdToken] of TCmdSyntax = (
   (Text: '';            ArgCount: 1),
   (Text: 'VER';         ArgCount: 4),
   (Text: 'USERID';      ArgCount: 2),
   (Text: '';            ArgCount: 1)
   );

My only problem is the last part. The code before is simple:

type
  CmdSyntax = public record
    Text: String;      
    ArgCount: Integer; 
  end;

  CmdToken = (
    cmdNOP = 0,
    cmdVER,
    cmdUSERID,   
    cmdERROR
  );

Thank you!
Benny

Hello Benny,

You can try next code:

type
  TCmdSyntax = public record
   Text: String;      
   ArgCount: Integer;
  end;

  TCmdToken = public (
   cmdNOP = 0,
   cmdVER,
   cmdUSERID,
   cmdERROR
   );

const
  Syntax: Array[TCmdToken] of TCmdSyntax = [
   new TCmdSyntax(Text := '', ArgCount := 1),
   new TCmdSyntax(Text := 'VER', ArgCount := 4),
   new TCmdSyntax(Text := 'USERID', ArgCount := 2),
   new TCmdSyntax(Text := '', ArgCount := 1)
   ];

Best regards.

1 Like

Thank you! Now, the syntax is correct.
But the compiler says that a NSString isn’t possible in a record. So I need to replace this type with array[1..50] of Char

Do you know how to write a string into a array of char?

In this case th best thing would be a plain class instead of record