Solved

Converting an array of char to a string...

Posted on 1998-03-21
2
322 Views
Last Modified: 2010-04-06
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
Comment
Question by:aztec
2 Comments
 
LVL 2

Accepted Solution

by:
rene100 earned 50 total points
ID: 1360685
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
 

Author Comment

by:aztec
ID: 1360686
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now