Sign in Join

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

Mailing lists / fpc-pascal / 2005-04

type of resourcestrings

5 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

Marc Santhoff

Hi,

when defining resourcestrings the definition looks like this:

	mystring = 'anything';

A typed definition is not allowed:

	mystring: AnsiString = 'anything';

gives an error.

How are resourcestrings typed?

I expect them to be short strings or ansi strings if $H+ is set. Is this correct?

TIA,
Marc

Michael Van Canneyt
to Marc Santhoff
Marc Santhoff wrote 11 lines
Hi, when defining resourcestrings the definition looks like this: mystring = 'anything'; A typed definition is not allowed: mystring: AnsiString = 'anything'; gives an error.

It should. A typed definition would imply that you can set it at runtime, which is not the case. (At least, not without the special API for it)

Show quoted text 5 lines
How are resourcestrings typed? I expect them to be short strings or ansi strings if $H+ is set. Is this correct?

No. They are always ansistrings.

Michael.

Marc Santhoff
to Michael Van Canneyt
Show quoted text 17 lines
On Wed, 6 Apr 2005, Marc Santhoff wrote: > Hi, > > when defining resourcestrings the definition looks like this: > > mystring = 'anything'; > > A typed definition is not allowed: > > mystring: AnsiString = 'anything'; > > gives an error. It should. A typed definition would imply that you can set it at runtime, which is not the case. (At least, not without the special API for it)

Setting at runtime is my intention, I'm localizing GUI strings ... what I don't understand is: Is this a compiler error or a logical clue, it should work but cannot because the API you mentioned is missing?

Free Pascal Compiler version 1.9.4 [2004/05/31] for i386 Copyright (c) 1993-2004 by Florian Klaempfl
Target OS: FreeBSD/ELF for i386

Show quoted text 7 lines
> > How are resourcestrings typed? > > I expect them to be short strings or ansi strings if $H+ is set. Is this > correct? No. They are always ansistrings.

Okay, I'm fine with that. :)

Thank you,
Marc

Michael Van Canneyt
to Marc Santhoff
Marc Santhoff wrote 22 lines
Am Mi, den 06.04.2005 schrieb Michael Van Canneyt um 16:36: > On Wed, 6 Apr 2005, Marc Santhoff wrote: > >> Hi, >> >> when defining resourcestrings the definition looks like this: >> >> mystring = 'anything'; >> >> A typed definition is not allowed: >> >> mystring: AnsiString = 'anything'; >> >> gives an error. > > It should. A typed definition would imply that you can set it at > runtime, which is not the case. (At least, not without the special API > for it) Setting at runtime is my intention, I'm localizing GUI strings ... what I don't understand is: Is this a compiler error or a logical clue, it should work but cannot because the API you mentioned is missing?

No, you must use the specialized API. For an example, see the 'gettext' unit provided in FPC. The needed low-level functions are in the 'objpas' unit, and are documented.

Michael.

Marc Santhoff
to Michael Van Canneyt: It should. A typed definition would imply that you can set it at runtime, which is not…
Show quoted text 13 lines
On Wed, 6 Apr 2005, Marc Santhoff wrote: > Hi, > > when defining resourcestrings the definition looks like this: > > mystring = 'anything'; > > A typed definition is not allowed: > > mystring: AnsiString = 'anything'; > > gives an error.

Forget about my last question, I forgot to mention that I tried both definitions in the 'resourcestring' section. The second one does work in the 'const' section where it belongs.

Sorry,
Marc