Hello people,
Again, I didn't see this in any FAQs or in the Bug List, so I am going to post the question. The Moveleft and Moveright functions should basically take a source and destination and copy the length number of bytes (from the left or right respectively), correct? That is how it worked with the old compiler I had, but I think we have come to the conclusion that it is horribly nonstandard, and since there are no help files on moveleft and moveright on the GPC page, I have to ask, and then ask if this is a bug.
My sample source is this: TYPE AnyStr = STRING[40]; AnyStrPtr = ^AnyStr;
VAR TestVar1 : AnyStrPtr; TestVar2 : AnyStrPtr; TestVar3 : AnyStr; TestVar4 : AnyStr;
BEGIN TestVar3 := 'TEST1'; TestVar1 := AnyStrPtr(@TestVar3); TestVar4 := 'TEST3'; TestVar2 := AnyStrPtr(@TestVar4); writeln(TestVar1^); writeln(TestVar2^); MOVELEFT (TestVar1^, TestVar2^, (LENGTH(TestVar1^) + 1)); writeln(""); writeln("After"); writeln(TestVar1^); writeln(TestVar2^); END. { unit pSos }
With GPC, the output is: TEST1 -> (TestVar1) TEST3 -> (TestVar2)
After TEST1 -> (TestVar1 after MoveLeft) TEST3 -> (TestVar2 after MoveLeft)
With my old compiler, the output is: TEST1 TEST3
After TEST1 TEST1
As it basically copies the length bytes of TestVar1 into TestVar2. Now, my question, does GPC work differently for this function, and if yes or no, is this a bug.
Also, if you guys need some help finishing the GPC manual, let me know, I am willing to lend a hand.
Adam Oldham
----------------------------------------------------------------------- C. Adam Oldham Marconi Commerce Systems Inc. Software Engineer 7300 West Friendly Ave. adam.oldham@marconi.com Greensboro, NC 27420-2087 Phone : 336.547.5952 Fax : 336.547.5079 ----------------------------------------------------------------------- This document contains confidential information of Marconi Commerce Systems Inc. In consideration of the receipt of this document, the recipient agrees not to reproduce, copy, use or transmit this document and/or the information contained herein, in whole or in part, or to suffer such actions by others, for any purpose except with written permission, first obtained, of Marconi Commerce Systems Inc., and further agrees to surrender the same to Marconi Commerce Systems Inc. upon demand. -----------------------------------------------------------------------
On 6 Jul 2001, at 8:08, Oldham, Adam wrote:
Hello people,
Again, I didn't see this in any FAQs or in the Bug List, so I am going to post the question. The Moveleft and Moveright functions should basically take a source and destination and copy the length number of bytes (from the left or right respectively), correct? That is how it worked with the old compiler I had, but I think we have come to the conclusion that it is horribly nonstandard, and since there are no help files on moveleft and moveright on the GPC page, I have to ask, and then ask if this is a bug.
My sample source is this: TYPE AnyStr = STRING[40]; AnyStrPtr = ^AnyStr;
VAR TestVar1 : AnyStrPtr; TestVar2 : AnyStrPtr; TestVar3 : AnyStr; TestVar4 : AnyStr;
BEGIN TestVar3 := 'TEST1'; TestVar1 := AnyStrPtr(@TestVar3); TestVar4 := 'TEST3'; TestVar2 := AnyStrPtr(@TestVar4); writeln(TestVar1^); writeln(TestVar2^); MOVELEFT (TestVar1^, TestVar2^, (LENGTH(TestVar1^) + 1)); writeln(""); writeln("After"); writeln(TestVar1^); writeln(TestVar2^); END. { unit pSos }
With GPC, the output is: TEST1 -> (TestVar1) TEST3 -> (TestVar2)
After TEST1 -> (TestVar1 after MoveLeft) TEST3 -> (TestVar2 after MoveLeft)
With my old compiler, the output is: TEST1 TEST3
After TEST1 TEST1
As it basically copies the length bytes of TestVar1 into TestVar2. Now, my question, does GPC work differently for this function, and if yes or no, is this a bug.
I am not sure that it is a bug. What you are assiging above is addresses. Then you "moveleft" values rather than addresses. I think that GPC's behaviour is correct here. If you move the addresses rather than the values, the result should be as you expected.
Best regards, The Chief --------- Prof. Abimbola Olowofoyeku (The African Chief) Author of Chief's Installer Pro for Win32 Email: African_Chief@bigfoot.com http://www.bigfoot.com/~african_chief/
On Fri, 6 Jul 2001, Oldham, Adam wrote:
Again, I didn't see this in any FAQs or in the Bug List, so I am going to post the question. The Moveleft and Moveright functions should basically take a source and destination and copy the length number of bytes (from the left or right respectively), correct? That is how it worked with the old compiler I had, but I think we have come to the conclusion that it is horribly nonstandard, and since there are no help files on moveleft and moveright on the GPC page, I have to ask, and then ask if this is a bug.
A while back wrote a simple text editor for my own amusement. The attachment is the unit using shiftleft and shiftright from that editor.
enjoy Russ
Russ Whitaker wrote:
Again, I didn't see this in any FAQs or in the Bug List, so I am going to post the question. The Moveleft and Moveright functions should basically take a source and destination and copy the length number of bytes (from the left or right respectively), correct? That is how it worked with the old compiler I had, but I think we have come to the conclusion that it is horribly nonstandard, and since there are no help files on moveleft and moveright on the GPC page, I have to ask, and then ask if this is a bug.
A while back wrote a simple text editor for my own amusement. The attachment is the unit using shiftleft and shiftright from that editor.
That's an example of correct usage (applied to the characters within a string, i.e. MoveRight (s [...], ...)). This also most likely works with every other compiler that implements this routine, since AFAIK that's what Move, MoveLeft, MoveRight and FillChar were originally designed for in UCSD Pascal.
Side note: Recent GPCs don't require {$X+} for SetLength anymore.
Of course, in most cases the existing string operations (which use MoveLeft etc. internally) are sufficient already, e.g. Insert, Delete, Copy, or here (as Maurice pointed out) a simple assignment, i.e. TestVar2^ := TestVar1^.
Frank