home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.pascal.borland      Borland Pascal was actually pretty neat      2,978 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 2,154 of 2,978   
   Marco van de Voort to Jason Burgon   
   Re: Password   
   29 Apr 06 11:01:13   
   
   From: marcov@stack.nl   
      
   On 2006-04-29, Jason Burgon  wrote:   
   > It does. Referencing the 0th character of a string  is   
   > implementation-specifc though, so the o/p could do worse than declare a   
   > global function called SetLength and use this instead. This makes the code   
   > more portable (eg to Delphi and FreePascal - which both have a "SetLength"   
   > procedure as well) because the implementation-specific code is in just one   
   > place.   
      
   Note that both Delphi and FPC support TP strings pretty much fully, however   
   Jason is right that these little mods help tremendously when porting to the   
   AnsiString type (no 255 char limit)   
      
   And to be complete:   
   - the substitute of reading s[0] is of course preexisting; length(s)   
   - Another really important detail is that one should only read/write   
   	characters <=length(s)   
      
   so assuming the string is empty,   
      
    setlength(s,1);	// eq to s[0]:=#1;   
    s[1]:='a';   
      
   and not   
      
    s[1]:='a';          // string might not be allocated yet with other   
   		    // stringtypes   
    setlength(s,1);     // This allocates, but too late!   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca