Path: utzoo!utgpu!water!watmath!clyde!bellcore!rutgers!gatech!ncar!ames!pasteur!ucbvax!GOLD.BACS.INDIANA.EDU!ijah400%ivax.DECnet From: ijah400%ivax.DECnet@GOLD.BACS.INDIANA.EDU ("IVAX::IJAH400") Newsgroups: comp.os.vms Subject: Re: Pascal strings Message-ID: <8807110621.AA06315@ucbvax.Berkeley.EDU> Date: 8 Jul 88 18:54:00 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 41 In article <2864@bsu-cs.UUCP>, cfchiesa@bsu-cs.UUCP (Christopher Chiesa) writes: > > That's a VERY GOOD question! Perhaps we have different versions or releases > of Vax Pascal? Although I would think the operation of the LENGTH function > would not change... > All I can say is that I *always* have to write my OWN "string length" function > when I want to work with type VARYING OF CHAR in Vax Pascal... For: module my_length; [global] function my_length (var str : varying[u1] of char): integer; begin my_length := length(str) end { my_length }; end { module }. Pascal version 3.5-196 generates the following code (comments mine): .TITLE MY_LENGTH .IDENT \01\ .PSECT $CODE,PIC,CON,REL,LCL,SHR,EXE,RD,NOWRT,2 .ENTRY MY_LENGTH,^M<> ; 0003 SUBL2 #8,SP ; Make room for a temp string descriptor MOVQ @4(AP),-8(FP) ; Copy the string descriptor to the temp 1$: MOVL -4(FP),AP ; 0005 Pick up address of length word MOVZWL (AP),AP ; Get contents (this is *current* length) MOVL AP,R0 ; 0006 Return it as the function value. RET Definitely appears to be the *current* length of the string to me. I wouldn't be surprised if older versions of the Pascal were wrong though; I've seen other bugs in VMS related to (Digital) programmer confusion about how to get the current length of a varying-length string. James Harvey IJAH400@INDYVAX (BITNET) or IJAH400%IVAX.DECNET@GOLD.BACS.INDIANA.EDU