Path: utzoo!attcan!uunet!tektronix!percival!bucket!leonard
From: leonard@bucket.UUCP (Leonard Erickson)
Newsgroups: comp.lang.pascal
Subject: Re: How to find declared length of strings in TP 4.0 ??
Message-ID: <957@bucket.UUCP>
Date: 16 Jul 88 03:27:22 GMT
References: <16378@brl-adm.ARPA> <950011@hpclldw.HP.COM> <14475@santra.UUCP>
Reply-To: leonard@bucket.UUCP (Leonard Erickson)
Organization: Rick's Home Grown Unix; Portland, OR
Lines: 26

 ldw@hpclldw.HP.COM (Larry Woods) writes:
<>Do you mean at runtime?  The answer is that you don't.  It isn't stored
<>anywhere for implementations of Pascal I'm familiar with.  It is merely
<>passed as a value parameter to run time routines for checking purposes.

I've been waiting, assuming that *someone* would post the obvious... 
no one has...

Program test;
  var
    s : string[20];
    n : integer;

begin
   n := sizeof(s) - 1;
   writeln(n);
end.

This has been tested and works! I suspect that sizeof is a mere compiler
directive that hardcodes the answer at compile time, but who cares? It 
produces the correct answer.
-- 
Leonard Erickson		...!tektronix!reed!percival!bucket!leonard
CIS: [70465,203]
"I used to be a hacker. Now I'm a 'microcomputer specialist'.
You know... I'd rather be a hacker."