gm2
[Top][All Lists]
Advanced

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

Inconsistent HIGH values with 'ARRAY OF CHAR'


From: Rudolf Schubert
Subject: Inconsistent HIGH values with 'ARRAY OF CHAR'
Date: Mon, 8 May 2023 23:26:11 +0200 (CEST)

Hi Gaius,

I'm still hunting miscellaneous bugs which occurred with my 'big squash file'.

One thing I noted today is:

the HIGH values seen inside a PROCEDURE do not reflect the expectations.

Again, I've written a small example program which shows the problem:


MODULE port_test8_gm2;

FROM IOChan IMPORT
  ChanId;
FROM StdChans IMPORT
  StdOutChan;
FROM Strings IMPORT
  Length;
FROM TextIO IMPORT
  WriteLn, WriteString;
FROM WholeIO IMPORT
  WriteCard;


VAR
  str_a:                        ARRAY[0..0] OF CHAR;
  str_b:                        ARRAY[0..1] OF CHAR;
  str_c:                        ARRAY[0..2] OF CHAR;


PROCEDURE ShowStringInfos(the_str: ARRAY OF CHAR);
  VAR
    cid_out:                    ChanId;

  BEGIN                         (* PROCEDURE ShowStringInfos *)
    cid_out:=StdOutChan();

    WriteString(cid_out, 'Length(the_str): ');
    WriteCard(cid_out, Length(the_str), 1);
    WriteLn(cid_out);

    WriteString(cid_out, 'HIGH(the_str): ');
    WriteCard(cid_out, HIGH(the_str), 1);
    WriteLn(cid_out);

    WriteString(cid_out, 'the_str: ');
    WriteString(cid_out, the_str);
    WriteLn(cid_out);

    WriteLn(cid_out);
  END ShowStringInfos;


BEGIN                           (* MODULE port_test8_gm2 *)
  ShowStringInfos('1');
  ShowStringInfos('12');
  ShowStringInfos('123');

  str_a:='a';
  ShowStringInfos(str_a);
  str_b:='ab';
  ShowStringInfos(str_b);
  str_c:='abc';
  ShowStringInfos(str_c);

  str_c:='d';
  ShowStringInfos(str_c);
END port_test8_gm2.


ShowStringInfos just prints out the Length, the HIGH value and the
string proper which is passed to the PROCEDURE. When using literals
'1', '12' and '123' the HIGH values are 0, 2 and 3. So I guess either
for '1' the HIGH value should be 1 and not 0 or for '12' and '123'
the HIGH values should be 1 and 2 and not 2 and 3. I can only compare
with GPM and there they report a HIGH value of 1 for '1' (and 2 and 3
for '12' and '123'). So the question is what will be the correct behaviour?


BR

Rudolf


--
Rudolf Schubert                 \
Kirchstr. 18a                    \  mailto:rudolf@muc.de
82054 Sauerlach                   > http://www.dose.muc.de
Deutschland                      /
Tel. 08104/908311               /




reply via email to

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