FormatText

FormatText 1:

Formatiert und setzt den Nachrichtentext mit einer variablen Anzahl von Argumenten (1 bis 5). Diese Methoden-Familie speichert das formatierte Ergebnis in der Eigenschaft sText. Der formatierte Text wird später durch Finish() mit den Dekorationen kombiniert.

Verfügbare Varianten

Methode

Argumente

Beschreibung

FormatText1

1

Formatiert mit 1 Platzhalter-Argument

FormatText2

2

Formatiert mit 2 Platzhalter-Argumenten

FormatText3

3

Formatiert mit 3 Platzhalter-Argumenten

FormatText4

4

Formatiert mit 4 Platzhalter-Argumenten

FormatText5

5

Formatiert mit 5 Platzhalter-Argumenten

Syntax (Beispiel: FormatText3)

METHOD FormatText3 : BOOL
VAR_INPUT
  sFormat : T_MaxString;
  tArg1   : T_Arg;
  tArg2   : T_Arg;
  tArg3   : T_Arg;
END_VAR

FormatText 2: Eingänge

Name

Typ

Beschreibung

sFormat

T_MaxString

Der Formatierungsstring mit Platzhaltern (z.B. '%d' für Integer, '%s' für String).

tArg1 bis tArgN

T_Arg

Die Argumente für die entsprechenden Platzhalter (Anzahl je nach Methode).

Beispiel

VAR
  fbMsg : FB_BA_DecorMessage;
END_VAR

Nachrichtentext mit 2 Argumenten formatieren:

fbMsg.FormatText2('Temperature: %d°C, Humidity: %d%%', F_INT(25), F_INT(65));

Dekoration hinzufügen:

fbMsg.AddDecor1('Sensor: %s', F_STRING('Room1'));

Abschließen:

fbMsg.Finish();

fbMsg.sOutput = "Temperature: 25°C, Humidity: 65% (Sensor: Room1)"