Concat a space in a string?

Have an array of char as part of a record...

name: array[0..35] of char;

Using BlockRead, I read from a binary file and get data into this field.

So afterwards, I'm trying to place this field into a FoxPro with a field that is of type FTString. A direct assignment doesn't work, so I wrote a loop to loop thru the characters and concat them in a new string and then assign that string to the table.

The problem now is that if there are spaces in the array, it doesn't get concatenated.

For example, suppose my array look like this:
'P','R','O','G','R','A','M','M','E','R','S', ' ', 'H','E','A','V','E','N'

My resulting string ends up being:
PROGRAMMERSHEAVEN instead of PROGRAMMERS HEAVEN

I'm currently using the concat function....is there another way to do this...but get the correct string?

Thanks.

Comments

  • : Have an array of char as part of a record...
    :
    : name: array[0..35] of char;
    :
    : Using BlockRead, I read from a binary file and get data into this field.
    :
    : So afterwards, I'm trying to place this field into a FoxPro with a field that is of type FTString. A direct assignment doesn't work, so I wrote a loop to loop thru the characters and concat them in a new string and then assign that string to the table.
    :
    : The problem now is that if there are spaces in the array, it doesn't get concatenated.
    :
    : For example, suppose my array look like this:
    : 'P','R','O','G','R','A','M','M','E','R','S', ' ', 'H','E','A','V','E','N'
    :
    : My resulting string ends up being:
    : PROGRAMMERSHEAVEN instead of PROGRAMMERS HEAVEN
    :
    : I'm currently using the concat function....is there another way to do this...but get the correct string?
    :
    : Thanks.
    :
    You could try one of the following codes (for each code s=resulting string):
    [code]
    s := name;
    [/code]
    or
    [code]
    SetLength(s, 36);
    for i := 0 to 35 do
    s[i+1] := name[i];
    [/code]
    or
    [code]
    SetLength(s, 36);
    Move(Name, s[1], SizeOf(Name));
    [/code]
    I've tested the first successfully.
  • The direct assignment did the trick.

    Thanks!

    : [code]
    : s := name;
    : [/code]

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories