![]() |
Delphi-Version: 10.2 Tokyo
Konstanten und Konkatenationen
Warum klappt das hier
Delphi-Quellcode:
und das hier nicht?
const
cStar: string = #$2606; cPOWER_OFF: string = #$2606 + 'POWER-OFF'; cPOWER_LOSS: string = #$2606 + 'POWER-LOSS'; cPOWER_BACK: string = #$2606 + 'POWER-BACK';
Delphi-Quellcode:
Und warum kann ich aus dem Meldungsfenster nicht mehr die Hilfe aufrufen?
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 Zitat:
|
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'; |
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: ![]() 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'; |
AW: Konstanten und Konkatenationen
Gnarf... Danke!
Sherlock |
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:59 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz