Sign in Join
Wiki copytemporary

Val/de

Deutsch · English · Русский

Val

Beschreibung

Mit Val, kann man einen String in einen numerischen Wert konvertieren.

Note: Bei Float-Typen muss beachtet werden, das immer ein Punkt als Dezimaltrenner verwendet wird, egal wie die Ländereinstellungen des OS eingestellt sind.

Beispiel

pascal
var
  s: string;
  e, i: integer;
  f: single;

begin
  s := '123';
  Val(s, i, e);
  WriteLn(i);
  s := '123.456';
  Val(s, f, e);
  WriteLn(f);

Wen der 3. Parameter <> 0 ist, konnte keine Konvertierung durchgeführt werden, als numerischen Wert wird dann 0, oder 0.0 zurückgegeben.

pascal
var
  s: string;
  e, i: integer;
  f: single;

begin
  s := 'abc';
  Val(s, f, e);
  if e <> 0 then begin
    WriteLn('Ungültiger Wert !');
  end;
  WriteLn(f); // Gibt 0.0 aus

Siehe auch:

Autor: Mathias


From the Free Pascal wiki, page "Val/de", as it stood on 2020-01-16 after a change by Bart, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 1, last changed by WikiArchive .

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.