[DUG] [computing]XE2 string conversion question

Stefan Mueller muellers at orcl-toolbox.com
Thu Jan 19 19:52:03 NZDT 2012


No, Jolyon is correct, I got it wrong - Shortstring was always 256bytes but
shortstring with a length was always length+1 bytes in memory.

Nevertheless, having a max of 255 ascii characters is a bit limiting in
todays world. I don't think many programmers still use shortstrings - at
least I haven't used it in any of my many projects since the old days of
Turbo Pascal.

 


Kind Regards,
Stefan Mueller 
_______________________
R&D Manager
ORCL Toolbox LLP, Japan
 <http://www.orcl-toolbox.com/> http://www.orcl-toolbox.com

 

From: delphi-bounces at listserver.123.net.nz
[mailto:delphi-bounces at listserver.123.net.nz] On Behalf Of Alister Christie
Sent: Thursday, January 19, 2012 6:08 AM
To: NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] [computing]XE2 string conversion question

 

>From memory (which is not as good as it use to be), Delphi 1* introduced
variable length strings, String[32] was a string of up to 32 characters (I
think it's actually size was 33 bytes - an extra byte to indicate length
stored in position 0).  Prior to that strings were always 256 bytes (1
length byte and 255 character bytes) - which when you only have 64k of
memory....

*It may have been a version of Turbo Pascal.



Alister Christie
Computers for People
Ph: 04 471 1849 Fax: 04 471 1266
http://www.salespartner.co.nz
Follow us on Twitter http://twitter.com/salespartner
PO Box 13085
Johnsonville
Wellington 


On 17/01/2012 9:48 p.m., Jolyon Smith wrote: 

@Stefan 

 

Of course there are reasons to use short strings, just as there are reasons
for using ANSIString, RawByteString and all the other string types.  Horses
for courses.

 

In the case of short strings, the reasons are the same reasons there always
were - most especially for use in records used for structured file access
(file of <record type>).  And I am not so sure about the idea that 255 bytes
are always allocated - surely the whole point of a declared short string
type of a specified length is that it will hold a string of that declared
length, come what may. 

 

Otherwise using file of <record type> containing short string fields would
never have worked!

 

+0.02

 

Jolyon






_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: delphi at listserver.123.net.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-request at listserver.123.net.nz with
Subject: unsubscribe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20120119/017153a3/attachment.html 


More information about the Delphi mailing list