Delphi-PRAXiS
Seite 1 von 3  1 23      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   TMeinSet(Byte(1)) in Variable > ungültige Typumwandlung (https://www.delphipraxis.net/200888-tmeinset-byte-1-variable-ungueltige-typumwandlung.html)

DieDolly 4. Jun 2019 13:14


TMeinSet(Byte(1)) in Variable > ungültige Typumwandlung
 
Seit Jahren mache ich das so aber jetzt funktioniert es nicht mehr. Eine ungültige Typumwandlung. Aber wo?
Was ist daran denn falsch? Das sind so wenige Zeilen das gibts doch nicht.

Weiß jemand weiter?

Delphi-Quellcode:
type
 TGroups = (g1, g2, g3);
 TGroupSet = set of TGroups;

var
 GroupSet: TGroupSet;
begin
 GroupSet := TGroupSet(Byte(2));
Komplettes Konsolenbeispiel
Delphi-Quellcode:
program Project1;

{$APPTYPE CONSOLE}
{$R *.res}

uses
 System.SysUtils;

type
 TGroups = (g1, g2, g3);
 TGroupSet = set of TGroups;


var
 GroupSet: TGroupSet;

begin
 GroupSet := TGroupSet(Byte(2));
end.

Union 4. Jun 2019 13:22

AW: TMeinSet(Byte(1)) in Variable speichern funktioniert nicht, ungültige Typumwandlu
 
Spontan so:

Delphi-Quellcode:
var
  GroupSet : TGroupSet;
  TempSet : Byte absolute GroupSet;
begin
  TempSet := 2;
end;

DieDolly 4. Jun 2019 13:24

AW: TMeinSet(Byte(1)) in Variable speichern funktioniert nicht, ungültige Typumwandlu
 
Das lässt sich beim Keyword absolute nicht kompilieren.^Die ungültiuge Typumwandlung bleibt dann aber auch.

Die Sache ist, dass der Code da oben mit anderen Variablennamen in einem anderen Projekt seit Jahren funktioniert!
Wieso das da oben nicht?

Union 4. Jun 2019 13:25

AW: TMeinSet(Byte(1)) in Variable speichern funktioniert nicht, ungültige Typumwandlu
 
Seltsam. Ich hatte es compiliert und debugged bevor ich es geposted habe.

DieDolly 4. Jun 2019 13:28

AW: TMeinSet(Byte(1)) in Variable speichern funktioniert nicht, ungültige Typumwandlu
 
Hier eine Konsolenanwendung die nur das beinhaltet. Da kommt die ungültige Typumwandlung auch

Delphi-Quellcode:
program Project1;

{$APPTYPE CONSOLE}
{$R *.res}

uses
 System.SysUtils;

type
 TGroups = (g1, g2, g3);
 TGroupSet = set of TGroups;


var
 GroupSet: TGroupSet;

begin
 GroupSet := TGroupSet(Byte(2));
end.
Ich verstehe langsam die Welt nicht mehr. In anderen Projekten funktioniert das seit Jahren. Entweder ist Delphi kaputt bei mir oder ich habe einen äußerst schrecklichen Copy paste Fehler drin.

Union 4. Jun 2019 13:31

AW: TMeinSet(Byte(1)) in Variable speichern funktioniert nicht, ungültige Typumwandlu
 
Zeig doch mal den compilierfähigen Code aus einem anderen Projekt.

DieDolly 4. Jun 2019 13:32

AW: TMeinSet(Byte(1)) in Variable speichern funktioniert nicht, ungültige Typumwandlu
 
Das kann ich nicht, da es sich hier um Firmencode handelt. Der ist 1 zu 1 gleich. Nur die Variablennamen sind anders (Wochentage).

Union 4. Jun 2019 13:36

AW: TMeinSet(Byte(1)) in Variable speichern funktioniert nicht, ungültige Typumwandlu
 
Dann bau doch ein Beispiel das man compilieren kann, und welches nur aus Deklaration und Zuweisung besteht. Damit verletzt Du dann auch keine Firmengeheimnisse.

DieDolly 4. Jun 2019 13:36

AW: TMeinSet(Byte(1)) in Variable speichern funktioniert nicht, ungültige Typumwandlu
 
Zitat:

Dann bau doch ein Beispiel das man compilieren kann, und welches nur aus Deklaration und Zuweisung besteht.
Wenn ich es schaffen würde irgendwas zum Kompilieren zu bringen, würde ich nicht hier um Hilfe bitten ;)

Hier ist der Code aus dem funktionierenden Projekt. Eins zu eins rauskopiert. Andere Variablennamen aber das ist egal denn die Originalnamen lassen sich auch nicht kompilieren.

Delphi-Quellcode:
program Project1;

{$APPTYPE CONSOLE}
{$R *.res}

uses
 System.SysUtils;

type
 TDOF = (d1, d2, d3, d4, d5, d6, d7);
 TDOFSet = set of TDOF;

type
 TGroups = (g1, g2, g3);
 TGroupSet = set of TGroups;

var
 Days: TDOFSet;
 GroupSet: TGroupSet;

begin
 Days := TDOFSet(Byte(2));

 GroupSet := TGroupSet(Byte(2));

end.
Das iwr auf das absolute Minimum reduziert und es funktioniert nicht. Irgendwo ist da doch ein Loch im Köse zuviel!

Fritzew 4. Jun 2019 14:16

AW: TMeinSet(Byte(1)) in Variable speichern funktioniert nicht, ungültige Typumwandlu
 
Compilersettings
MinEnumSize steht da wahrscheinlich falsch Word oder Double Word und nicht auf Byte
im deutschen Delphi "Mindestgrösse für Enum"


Alle Zeitangaben in WEZ +1. Es ist jetzt 18:01 Uhr.
Seite 1 von 3  1 23      

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