gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Access of elements of a string constant


From: Michael Riedl
Subject: Access of elements of a string constant
Date: Sat, 4 Jan 2020 18:05:38 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:60.0) Gecko/20100101 Thunderbird/60.6.1

Hallo Gaius,

here another one (I think we had that already in one of the former releases, but I'm not sure).

The compiler states


gm2 -c -fiso -flibs=iso -I /usr/local/gm2/lib/gcc/i686-pc-linux-gnu/8.2.0/m2/iso -I /usr/local/gm2/lib/gcc/i686-pc-linux-gnu/8.2.0/m2/pim -L /usr/local/gm2/libs -O1 -g TestKonstanten.mod /usr/local/gm2/lib/gcc/i686-pc-linux-gnu/8.2.0/m2/iso/SYSTEM.def:10:1: error: can only access arrays using variables or formal parameters TestKonstanten.mod:19:7: error: can only access arrays using variables or formal parameters TestKonstanten.mod:19:7: error: type of array is undefined (no such array declared)

And here a short test code ...


MODULE TstStrConst;

IMPORT STextIO,SWholeIO;

CONST NumStr = "0123456789ABCDF";

VAR   i : CARDINAL;

BEGIN
      STextIO.WriteLn;
      FOR i:=0 TO LENGTH(NumStr)-1 DO
        SWholeIO.WriteCard(i,2);
        STextIO.WriteString(" '");
        STextIO.WriteChar(NumStr[i]);
        STextIO.WriteString("' ");
        SWholeIO.WriteCard(ORD(NumStr[i]),1);
        STextIO.WriteLn;
      END;
      STextIO.WriteLn;
END TstStrConst.

It can be fixed by a VAR string initialized in the module body - but that's less elegant.

And I started to check my quantum chemical code with GM2 - and here I used that a couple of times.


Greetings

Michael




reply via email to

[Prev in Thread] Current Thread [Next in Thread]