Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2002-07

Problem with ANSI-Strings

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Philipp Lucas

I have a problem with ANSI-Strings. Please take a look at the following program, which is a minimal sample of code that produces different results depending on whether I use ANSI or short strings.

**START
{$H-}
PROGRAM t;
FUNCTION STR_neu(w:WORD):STRING;
  VAR d:STRING;
  BEGIN
    STR(w,d);
    exit(d);
  END;
BEGIN
  WRITELN('->'+STR_neu(25)+'<-');
END.
**END

When compiling this program with 1.0.6 for DOS without command line arguments, it works as expected. If I use {$H+$}, the result of STR_neu is not '25'. I can't see /why/ this works differently. Help!

Philipp Lucas

Reply by email

Michael Van Canneyt
to Philipp Lucas
Philipp Lucas wrote 14 lines
I have a problem with ANSI-Strings. Please take a look at the following program, which is a minimal sample of code that produces different results depending on whether I use ANSI or short strings. **START {$H-} PROGRAM t; FUNCTION STR_neu(w:WORD):STRING; VAR d:STRING; BEGIN STR(w,d); exit(d);

This line is the problem. It's a compiler bug !

replace this with

  str_neu:=d;

and it will work fine.

To the compiler guys: It's really a bug, it should be fixed somehow. There is an access violation when using the exit() with ansistrings.

Michael.

Reply by email