----boundary-LibPST-iamunique-635970720_-_-
Content-type: text/plain
Hello, Gérard!
GM> Douglas G. Danforth a écrit :
>> Folks,
>> I just discovered that the length of a string varies depending
>> upon whether it is used directly or passed as an argument to
>> a procedure for example
>>
>> VAR x: ARRAY 32 OF CHAR;
>> x := "HI";
>>
>> will have length
>> LEN(x$) = 2
>> but will have length
>> LEN(y) = 3
>> when it is passed to a procedure with argument y.
>>
>> Here is the code that shows this.
>>
>> MODULE Foo;
>> IMPORT Out:=StdLog;
>>
>> PROCEDURE Test*;
>> VAR x: ARRAY 32 OF CHAR;
>> PROCEDURE Inside (IN y: ARRAY OF CHAR);
>> VAR i: INTEGER;
>> BEGIN
>> Out.String("LEN(y)="); Out.Int(LEN(y)); Out.Ln;
>> (* dump the string *)
>> FOR i:= 0 TO LEN(y)-1 DO Out.Char(y[i]) END;
>> Out.Ln;
>> END Inside;
>> BEGIN
>> x := "HI";
>> Out.String("LEN(x$)="); Out.Int(LEN(x$)); Out.Ln;
>> Inside(x$);
>> END Test;
>>
>> END Foo.
>>
>> -Doug Danforth
>>
GM> It's because you pass x$, and not x itself. x$ is the string inside the
GM> array of char, so its length is the length of the string plus 1
GM> (terminal 0X).
Yeah, Doug! What about LEN(y$)?
---===---
Alexander
--- BlackBox
--- send subject HELP or UNSUBSCRIBE to blackbox{([at]})nowhere.xy
----boundary-LibPST-iamunique-635970720_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzc1xmY2hhcnNldDAgQXJpYWw7fQ0Ke1xmMVxmbW9kZXJuIENvdXJpZXIgTmV3O30NCntcZjJc
Zm5pbFxmY2hhcnNldDIgU3ltYm9sO30NCntcZjNcZm1vZGVyblxmY2hhcnNldDAgQ291cmllciBO
ZXc7fX0NCntcY29sb3J0YmxccmVkMFxncmVlbjBcYmx1ZT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sZXhhbmRlclxwYXINClxwYXINCi0t
LSBCbGFja0JveFxwYXINCi0tLSBzZW5kIHN1YmplY3QgSEVMUCBvciBVTlNVQlNDUklCRSB0byBi
bGFja2JveEBvYmVyb24uY2h9fQBRAwEQxzL3BgAG
----boundary-LibPST-iamunique-635970720_-_---
Received on Fri Sep 29 2006 - 20:01:27 UTC