Basic Data Manipulation
Posted on 2004-11-15
hello fellow coder-monkeys
i'm using c++builder 4 (old version off a coverdisk) to read data from a remote file and grab some of it into an array
The problem I have is :
The data file has 3 fields in comma sparated format, the third field is not required. Fields 1 and 2 are numeric, field 3 (when its there) is alpha-numeric
For example :
1231231, 456456456456, hglkghjlgkhjlfhjlkfjh
9594939, 439588023453, fghoerhowerhoguhwergwergw
you get the idea
I'm only interested in field 1
I have managed to get the file imported into a memo field, and that all works fine, but i cant seem to get just the part i need.
For the moment, i'm just trying to copy the required data from 1 memo field to another, and throw the rest away, so Memo4 should contain :
1123123, 1123124, 1123125, 1123126, 1123127 ......
What i've CURRENTLY got is (in a loop):
Memo2->SelStart = 0;
Memo2->SelLength = 7;
Memo2->SelStart = 0;
Memo2->SelLength = Memo2->Lines->IndexOf("\r\n");
you can see what i'm TRYING to do here....get the first 7 character of a line (always the data i want), paste in into Memo4, and then grab the rest of the line and throw it.
this is the closest i've got to what i want, but i only get the same data repeated, for example
it doesnt seem to be picking up the newline character. Ive tried it with "\n" and "\r" by themselves too.
I know the loop works, because my revious code just selected 7 characters and pasted those and i ended up with the entire file being pasted from one field to the other, so its definately part of the above code that needs changing.
Am i along the right lines, or barking up completely the wrong tree.
I also though of grabbing the whole line, then reading just the first 7 characters, and clearing the read line from the box, but I couldnt seem to get that working either.
I think i should also point out that i have NEVER codes in a c++ RAD tool before, and not touched c++ at ALL since the last verison 4 of standard borland c++ many many years ago.
thanks guys...i know you wont let me down......please.....dont let me down :o)