t68_length.pas 734 B

1234567891011121314151617181920212223
  1. program t68_length;
  2. { t68 -- LENGTH, the first string builtin FUNCTION. CALC.INC:20 is
  3. for I := 1 to ((80-Length(S)) div 2) do Write(' ');
  4. A string's length is the byte at [address], so Length is loaded inline - no
  5. runtime entry and no address pushed. A literal is emitted inline
  6. (EmStrBlob) and its length byte read from that image offset.
  7. CALC also writes LENGTH(StandardfunctionNames[sf]) - a string ELEMENT of an
  8. array with a variable index - which needs the variable-index work and is not
  9. what this fixture tests; here the argument is a variable and a literal. }
  10. var
  11. s : string[20];
  12. begin
  13. s := 'hello';
  14. writeln (Length (s));
  15. writeln (Length ('abc'));
  16. s := '';
  17. writeln (Length (s))
  18. end.