Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How to get data from a char array to a string variable?

Posted on 2009-02-18
2
Medium Priority
?
321 Views
Last Modified: 2013-11-23
Hi Experts,
I'm using Delphi 7.

How do I get character data in an array to a string?  I'm using a For loop because I only want a subset of the data from the array.
The code below does not


Thanks much!

var
  Buffer : array [0..MAXFILESIZE] of char;
  OCRString : string;
 
for i := posBegin to posEnd do
    OCRString := OCRString + (Str[I]) ;
 
My string looks like this:
ABCD#/ABC|DEF|GHIJK\#l;f-3 094QWERalsefd
            
I want to extract pos 4 to 19 (start with first # and end with K before the \).
 
The output OCRString in debug mode looks like this: #0#$12#0#0#0#1#0#0#0#1#0#0#0'4'#0#0#0

Open in new window

0
Comment
Question by:IT79637
2 Comments
 
LVL 19

Accepted Solution

by:
MerijnB earned 800 total points
ID: 23675277
You didn't show what type Str is, but you can try:

OCRString := Copy(Buffer, 4, 19 - 4);
0
 
LVL 1

Author Closing Comment

by:IT79637
ID: 31548501
Works great.  All I had to do was adjust the start position and length to adjust for my starting and ending delimiters.

Thanks much.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
Suggested Courses

581 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