Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi Konstanten und Konkatenationen (https://www.delphipraxis.net/200042-konstanten-und-konkatenationen.html)

Sherlock 13. Mär 2019 14:34

Delphi-Version: 10.2 Tokyo

Konstanten und Konkatenationen
 
Warum klappt das hier
Delphi-Quellcode:
const
  cStar: string      = #$2606;
  cPOWER_OFF: string = #$2606 + 'POWER-OFF';
  cPOWER_LOSS: string = #$2606 + 'POWER-LOSS';
  cPOWER_BACK: string = #$2606 + 'POWER-BACK';
und das hier nicht?
Delphi-Quellcode:
const
  cStar: string      = #$2606;
  cPOWER_OFF: string = cStar + 'POWER-OFF'; // E2026 Konstantenausdruck erwartet
  cPOWER_LOSS: string = cStar + 'POWER-LOSS'; // Dito
  cPOWER_BACK: string = cStar + 'POWER-BACK'; // Dito
Und warum kann ich aus dem Meldungsfenster nicht mehr die Hilfe aufrufen?
Zitat:

---------------------------
Fehler
---------------------------
Keine Hilfe für dcc32 gefunden.
---------------------------
OK Details >>
---------------------------
Sherlock

Schokohase 13. Mär 2019 15:07

AW: Konstanten und Konkatenationen
 
Weil es so geht
Delphi-Quellcode:
const
  cStar = #$2606;
  cPOWER_OFF = cStar + 'POWER-OFF';
  cPOWER_LOSS = cStar + 'POWER-LOSS';
  cPOWER_BACK = cStar + 'POWER-BACK';

ghubi01 13. Mär 2019 15:28

AW: Konstanten und Konkatenationen
 
Hallo,

@Sherlock
In typisierten Konstanten (const identifier: type = value) darf Value nur aus echten Konstanten bestehen.
In deinem zweiten Beispiel wird Value eine typisierte Konstante + einer echten Konstante zugewiesen und das geht nicht.
Siehe hier: http://docwiki.embarcadero.com/RADSt...rte_Konstanten
ab Abschnitt typisierte Konstanten.

Das hier geht:
Delphi-Quellcode:
const
   //cStar: string = #$2606;
   cStar = #$2606;
   cPOWER_OFF: string = cStar + 'POWER-OFF';
   cPOWER_LOSS: string = cStar + 'POWER-LOSS';
   cPOWER_BACK: string = cStar + 'POWER-BACK';

Sherlock 14. Mär 2019 07:12

AW: Konstanten und Konkatenationen
 
Gnarf... Danke!

Sherlock


Alle Zeitangaben in WEZ +1. Es ist jetzt 11:40 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz