Autor Beitrag
g1o2k4
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 493



BeitragVerfasst: So 31.08.08 11:41 
hi

ich bin auf eine funktion aus einer dll gestoßen der man werte übergeben kann die in form von konstanten gespeichert sind.
in einem beispiel der dll hab ich gesehn, dass man sie wie folgt aufrufen kann:
ausblenden Delphi-Quelltext
1:
x(konstante1 and konstante2);					


wie läuft das functionsintern ab, dass beide konstanten benutzt werden ?
muss man dazu abfragen ob mehrere werte übergeben wurden oder geht das automatisch ?
wie sieht das innere so einer funktion aus ?
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: So 31.08.08 11:52 
Hi,

Kann es sein, dass es sich bei den Konstanten um Einstellungen o.ä. handelt? Imho kann das 'and' nämlich nur ein bitweises und sein(!) und damit würde deine function einfach überprüfen, ob die einzelnen bits gesetzt sind.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
const
  MotorA = 1;  //001
  MotorB = 2;  //010
  MotorC = 4;  //100
  MotorAB = MotorA and MotorB;  // = 001 and 010 = 011


mfG,

_________________
Centaur spears can block many spells, but no one tries to block if they see that the spell is a certain shade of green. For this purpose it is useful to know some green stunning hexes. (HPMoR)
g1o2k4 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 493



BeitragVerfasst: So 31.08.08 11:58 
hmm aso das könnte sein, aber teilweise gibts auch konstanten mit werten um die 8mio...
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: So 31.08.08 12:23 
2^23 ;-)

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
g1o2k4 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 493



BeitragVerfasst: So 31.08.08 12:29 
user profile iconBenBE hat folgendes geschrieben:
2^23 ;-)


k wenns sinnvoll ist :P
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: So 31.08.08 12:37 
Beim GeSHi hab ich letztens 25 Konstanten gebraucht (ging dort um verschiedene Zahlenformate, die vordefiniert waren). Man kommt also schnell in solche Dimensionen ...

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.


Zuletzt bearbeitet von BenBE am So 31.08.08 14:08, insgesamt 1-mal bearbeitet
Kha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3803
Erhaltene Danke: 176

Arch Linux
Python, C, C++ (vim)
BeitragVerfasst: So 31.08.08 13:32 
user profile iconHidden hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
001 and 010 = 011					
Nope, 1 and 10 = 0 ;) .
Normalerweise (wenn man nicht sowieso Delphis Set-Typ nutzt) wird or zum Verknüpfen und and zum Auslesen (Set and Bit = Bit) benutzt, das war wahrscheinlich nur ein Schreibfehler im ersten Post.

_________________
>λ=
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: So 31.08.08 14:16 
user profile iconKha hat folgendes geschrieben:
user profile iconHidden hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
001 and 010 = 011					
Nope, 1 and 10 = 0 ;) .
Normalerweise (wenn man nicht sowieso Delphis Set-Typ nutzt) wird or zum Verknüpfen und and zum Auslesen (Set and Bit = Bit) benutzt, das war wahrscheinlich nur ein Schreibfehler im ersten Post.

Ups :) Hab nichtmal nachgedacht. btwAND -> Informationsverlust -> einzelne Konstanten können nicht wieder getrennt werden, da war ich schon fertig :lol:

Edit: Wobei ich es so kennengelernt habe, dass hier der '+' - Operator verwendet wird. Der ist zwar weniger leistungsfähig, aber für Neulinge syntaktisch an dieser Stelle logischer.

mfG,

_________________
Centaur spears can block many spells, but no one tries to block if they see that the spell is a certain shade of green. For this purpose it is useful to know some green stunning hexes. (HPMoR)