Russ Whitaker wrote:
hi Frank is this a miss-use of move, a bug, or something that has already been fixed?
The former. The capacity is stored internally as the first field of a string, so if you move to "temp", you'll overwrite temp's capacity. What you can do (and that's about the only case where a "move" seems acceptable besides low-level stuff) is to move the characters of a string, like the following:
program astrings;
var srcstr : string(255); temp : string(120);
begin srcstr := 'abcdefghi'; writeln( srcstr.capacity, ' ', length(srcstr), ' ', srcstr); writeln( temp.capacity ); move( srcstr [1], temp [1], length(srcstr)); writeln( temp.capacity, ' ', length(temp), ' ', temp); {$X+} SetLength (temp, length (srcstr)); {$X-} writeln( temp.capacity, ' ', length(temp), ' ', temp); end.
However, as you see in this program, to modify the length of a string, you need `SetLength', and this requires extended syntax, so I don't really recommend this method. It's usually easier to use the existing string operations (in this case, of course, a simple `:=' assignment would do, but I assume you have something more complicated in mind -- if you don't know how to achieve it with the string operations, be welcome to ask).
Frank