t96_valint.pas 588 B

1234567891011121314151617181920212223242526
  1. program t96_valint;
  2. { t96 -- Val(string, integer, error). CALC.INC's Help converts the line count
  3. string into EndOfFile with Val; the error position must be 0 on a valid
  4. string and the 1-based position of the first bad character otherwise. On
  5. error the destination is unchanged (TPSRC2 valerr). }
  6. var
  7. S : string[10];
  8. I, E : integer;
  9. begin
  10. S := '42';
  11. I := 0;
  12. Val (S, I, E);
  13. writeln (I, ' ', E);
  14. S := '-7';
  15. Val (S, I, E);
  16. writeln (I, ' ', E);
  17. S := '12x';
  18. I := 0;
  19. Val (S, I, E);
  20. writeln (I, ' ', E);
  21. S := '';
  22. Val (S, I, E);
  23. writeln (I, ' ', E)
  24. end.