Registriert seit: 10. Sep 2004
Ort: Mönchengladbach
833 Beiträge
Delphi 7 Enterprise
|
Re: Speicherung von Sets... ?!?
28. Feb 2005, 16:21
Ich glaun ich habs raus...
cmd1 = TButton
txt1 = TMemo
Delphi-Quellcode:
Procedure TfrmMain.cmd1Click(Sender: TObject);
Function GetValue( Const WD: TQWeekdays ): Cardinal;
Begin
Case SizeOf( wd ) Of
1: Result := Cardinal( (@wd)^ ) And $000000ff;
2: Result := Cardinal( (@wd)^ ) And $0000ffff;
3: Result := Cardinal( (@wd)^ ) And $00ffffff;
4: Result := Cardinal( (@wd)^ ) And $ffffffff;
Else Result := 0;
End;
End;
Function InfoStr( Const WD: TQWeekdays ): String;
Begin
Result := #9'Size:'#9 + IntToStr( SizeOf( WD ) ) + #13#10 +
#9'Value:'#9 + IntToStr( GetValue( WD ) );
End;
Begin
txt1.Clear;
txt1.Lines.Append( '[ ]'#13#10
+ InfoStr( [ ] ) );
txt1.Lines.Append( '[ wdMonday ]'#13#10
+ InfoStr( [ wdMonday ] ) );
txt1.Lines.Append( '[ wdTuesday ]'#13#10
+ InfoStr( [ wdTuesday ] ) );
txt1.Lines.Append( '[ wdWednesday ]'#13#10
+ InfoStr( [ wdWednesday ] ) );
txt1.Lines.Append( '[ wdThursday ]'#13#10
+ InfoStr( [ wdThursday ] ) );
txt1.Lines.Append( '[ wdFriday ]'#13#10
+ InfoStr( [ wdFriday ] ) );
txt1.Lines.Append( '[ wdSaturday ]'#13#10
+ InfoStr( [ wdSaturday ] ) );
txt1.Lines.Append( '[ wdSunday ]'#13#10
+ InfoStr( [ wdSunday ] ) );
txt1.Lines.Append( #13#10#13#10 );
txt1.Lines.Append( '[ wdMonday, wdTuesday ]'#13#10
+ InfoStr( [ wdMonday, wdTuesday ] ) );
txt1.Lines.Append( '[ wdMonday, wdTuesday, wdWednesday ]'#13#10
+ InfoStr( [ wdMonday, wdTuesday , wdWednesday ] ) );
txt1.Lines.Append( '[ wdMonday, wdTuesday, wdWednesday, wdThursday ]'#13#10
+ InfoStr( [ wdMonday, wdTuesday, wdWednesday, wdThursday ] ) );
txt1.Lines.Append( '[ wdMonday, wdTuesday, wdWednesday, wdThursday, wdFriday ]'#13#10
+ InfoStr( [ wdMonday, wdTuesday, wdWednesday, wdThursday, wdFriday ] ) );
txt1.Lines.Append( '[ wdMonday, wdTuesday, wdWednesday, wdThursday, wdFriday, wdSaturday ]'#13#10
+ InfoStr( [ wdMonday, wdTuesday, wdWednesday, wdThursday, wdFriday, wdSaturday ] ) );
txt1.Lines.Append( '[ wdMonday, wdTuesday, wdWednesday, wdThursday, wdFriday, wdSaturday, wdSunday ]'#13#10
+ InfoStr( [ wdMonday, wdTuesday, wdWednesday, wdThursday, wdFriday, wdSaturday, wdSunday ] ) );
End;
Ergebniss:
Code:
[ ]
Size: 1
Value: 0
[ wdMonday ]
Size: 1
Value: 1
[ wdTuesday ]
Size: 1
Value: 2
[ wdWednesday ]
Size: 1
Value: 4
[ wdThursday ]
Size: 1
Value: 8
[ wdFriday ]
Size: 1
Value: 16
[ wdSaturday ]
Size: 1
Value: 32
[ wdSunday ]
Size: 1
Value: 64
[ wdMonday, wdTuesday ]
Size: 1
Value: 3
[ wdMonday, wdTuesday, wdWednesday ]
Size: 1
Value: 7
[ wdMonday, wdTuesday, wdWednesday, wdThursday ]
Size: 1
Value: 15
[ wdMonday, wdTuesday, wdWednesday, wdThursday, wdFriday ]
Size: 1
Value: 31
[ wdMonday, wdTuesday, wdWednesday, wdThursday, wdFriday, wdSaturday ]
Size: 1
Value: 63
[ wdMonday, wdTuesday, wdWednesday, wdThursday, wdFriday, wdSaturday, wdSunday ]
Size: 1
Value: 127
Scheinbar macht es Delphi so..
lieg ich da richtig?
Dann könnt ich das eigendlich so spiechern oder?
Bye
Edit:
Bei der Funktion GetValue
Greif ich atm auf speicher zu der mir nix angeht, jedenfalls wenn Size <> 4 ist...
Könnte ich da Probleme bekommen?
Christian
|