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

Posted on 2009-02-18
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!


  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

Question by:IT79637
    LVL 19

    Accepted Solution

    You didn't show what type Str is, but you can try:

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

    Author Closing Comment

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

    Thanks much.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Suggested Solutions

    Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
    How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from ( Go to that link and select download selenium in the right hand columnThat will then direct you to their downlo…
    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 and create new code templates in NetBeans IDE 8.0 for Windows.

    745 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

    19 Experts available now in Live!

    Get 1:1 Help Now