TIP: Click on subject to list as thread! ANSI
echo: z3_pascal
to: Nicholas Klopfer-Webber
from: Doug Brendish
date: 1996-07-15 05:02:38
subject: Function Move

NK> I am curently writing a program which speed is of the 
NK> ut-most importance. But apart from that I need to be able to 
NK> access each char of a string at a time efficently.  At the 
NK> moment I am using a array of char but I still have processes 
NK> which only a string can handle.  As you know strings and 
NK> arrays are not compatable.  One way but not both.
NK>   So far I have tried to use the Quick Pascal function move 
NK> which moves a spesified number of chars from one part of 
NK> memory to another.  However it adds a char to the begining 
NK> of the string being copied.  This stuffes my program and I 
NK> cant easily compencate.

Let me start by saying I can't really grasp what you're trying to do
from you description(it's 6:10 am and I ain't been to bed yet), so if I'm
off the mark you know why. 
A string in pascal is basically an array[0..256] of char(unless told
otherwise), the first element (zero) tells write and writeln how many chars
of that array to write (eg "for i:= 1 to ord(array[0])
write(array[i])"). If you move an array straight into the address your
string, it'll stuff it up because the frist char in a string is the length
char. EG string[0] is the CHARACTER = to the length of the string. A 12
char string would have CHAR(12) in string[0] and therfore is really 13
bytes long. This is probably what is mucking up your moves. If you wrote
EVERY char in the 12 char string by "for i:= 0 to 13 write
string[i];" then it would look like "AAAAAAAAAAAA". If I
moved something else into string[0] by doing
"string[0]:=char(3);" and then said "writeln(string);"
the string printed would only be 3 chars long, ie "AAA".

NK>   Can anyone suggest some code to copy data in this way or a 
NK> way of making strings and arrays compatable.  I realy need 
NK> some help here and any suggestions would be helpfull.
NK>  

I presume that moving chars between the array and string by using something like:
for i:= x to count do array[i] = string[i] and vis versa is too slow for you?

Hope I made sense all this helps you sort it out.

Doug.

--- Msgedsq/2 3.10
* Origin: Tir na nOc 066 245944 -=Cead mile failte=- (3:626/667)
SEEN-BY: 633/267 270
@PATH: 626/667 660 711/401 808 50/99 635/544 727 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.