AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Einheiten parsen

Ein Thema von Bjoerk · begonnen am 9. Mär 2015 · letzter Beitrag vom 14. Mär 2015
Antwort Antwort
Seite 5 von 5   « Erste     345   
Bjoerk

Registriert seit: 28. Feb 2011
Ort: Mannheim
1.384 Beiträge
 
Delphi 10.4 Sydney
 
#41

AW: Einheiten parsen

  Alt 14. Mär 2015, 19:20
Genau so ist es.

"3 kN/m * 4 kN / 3 m" = [KeineEinheit][kN/m] * [KeineEinheit][kN] / [KeineEinheit][m]

[KeineEinheit][IrgendeineEinheit] ersetzen wir zu [IrgendeineEinheit]

-> [kN/m] * [kN] / [m]

Wenn an einer Operation [KeineEinheit] beteiligt ist, dann ist das Ergebnis dieser Operation die andere Einheit.

Delphi-Quellcode:
function TParserUnits.Valid(const Value: TParserUnitStyle): boolean;
begin
  Result := Value <> pusNone; // pusNone = Ergebnis einer inkompatiblen Operation
end;

function TParserUnits.Default(const Value: TParserUnitStyle): boolean;
begin
  Result := Value = pusDefault; // pusDefault = Keine Einheit;
end;

function TParserUnits.GetAdd(const A, B: TParserUnitStyle): TParserUnitStyle;
begin
  Result := pusNone;
  if Valid(A) and Valid(B) then
  begin
    if A = B then
      Result := A
    else
      if Default(A) then
        Result := B
      else
        if Default(B) then
          Result := A;
  end;
end;

function TParserUnits.GetMult(const A, B: TParserUnitStyle): TParserUnitStyle;
var
  Style: TParserUnitStyle;
  KN, M: integer;
begin
  Result := pusNone;
  if Valid(A) and Valid(B) then
  begin
    if Default(A) then
      Result := B
    else
      if Default(B) then
        Result := A
      else
      begin
        KN := FItems[A, pubKN] + FItems[B, pubKN];
        M := FItems[A, pubM] + FItems[B, pubM];
        for Style := pusDefault to pusM do
          if (KN = FItems[Style, pubKN]) and (M = FItems[Style, pubM]) then
            Result := Style;
      end;
  end;
end;

function TParserUnits.GetDiv(const A, B: TParserUnitStyle): TParserUnitStyle;
var
  Style: TParserUnitStyle;
  KN, M: integer;
begin
  Result := pusNone;
  if Valid(A) and Valid(B) then
  begin
    if Default(A) then
      Result := B
    else
      if Default(B) then
        Result := A
      else
      begin
        KN := FItems[A, pubKN] - FItems[B, pubKN];
        M := FItems[A, pubM] - FItems[B, pubM];
        for Style := pusDefault to pusM do
          if (KN = FItems[Style, pubKN]) and (M = FItems[Style, pubM]) then
            Result := Style;
      end;
  end;
end;

Geändert von Bjoerk (14. Mär 2015 um 19:31 Uhr) Grund: Schreibfehler
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 5 von 5   « Erste     345   


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:39 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