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