[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 333
  • Last Modified:

Converting an array of char to a string...

Hi...
  Very simple. How do I convert an array of char to a string variable? I have a variable x which is declared as array[1..200] of char and I have a string variable y. I simply want the contents of x to go into y. I tried the 'Strpas' function to convert a null-terminated string to Pascal type sting but it gave me an error 'Incompatible types : Array and PChar'. There must be an easy way to do this. Can you help?

Cheers!
   Shawn Halfpenny
   drumme59@sprint.ca
0
aztec
Asked:
aztec
1 Solution
 
rene100Commented:
Hi aztec

in fact, you mustn't convert the types. You simply can use
y:=x; that fills y with all 200 chars of x. if you want to get
only a few of the chars, use y:=copy(x,StartIndex,Count);

regards
rene100
0
 
aztecAuthor Commented:
You are quite right! Thanks!

I mistakenly entered the same question as this twice. Can someone delete the other one?

Thanks
   Shawn
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now