Reading Blank Lines with Borland C++ Builder 3

Hey, i need some help in reading over a blank line in borland C++ Builder. I've loded a file into a Memo box and am using 2 for loops to read individual chars to a string and look for a particular string. The only prolbem i have is that i cannot read over a blank line, when i try to do so i get an access violation. That particular line looks something like this
if(Memo1->Lines->Strings[x][y]!='\0')
The only prolbem with this is i still get an access violation when i try to run this. If anyone could help i'd be glad to help them out in any way possible.

Tom
CrovaxAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Stevex2Commented:
Try something similar to this.
Memo1->Lines->Strings[x].operator [](y) != '\0';


Also make sure your access violation is not coming from overshooting the lines/strings array.

0
Stevex2Commented:
of course put the if brackets I forgot them :)
0
nietodCommented:
It would help if we knew how lines and strings were declared. and how they work.  For example, if the blank line is represented using a NULL pointer, this would crash.
0
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

Stevex2Commented:
Very true. If thats the case you could check those lines against the NULL before trying to read the chars.
0
CrovaxAuthor Commented:
Well, the actual coding is
for (x=0;x<=Memo1->Lines->Count;x++)
        {

            for(y=1; y<=7;y++    )
            {
                if(Memo1->Lines->Strings[x][y]!='\0')
                string[y]=Memo1->Lines->Strings[x][y];
                else x+=0;
            }

            if(string[1]=='L' && string[2]=='O' && string[3]=='G' && string[4]=='O')
            {
                LineNum=x;
                break;
            }


        }
Once x becomes equil to 4 in the memo box there's a blank line (the actual file i'm reading is Msdos.sys and the 5th line of that file is blank on my computer). I tried Stevex2's method but to no avail...and the others i'm not quite sure i know what they mean (kinda new at this programming stuff).
0
Stevex2Commented:
if(Memo1->Lines->Strings[x][y]!='\0')
               

this line add this check to it

if(Memo1->Lines->Strings[x] != NULL && Memo1->Lines->Strings[x][y]!='\0')
  string[y]=Memo1->Lines->Strings[x][y];
               
0
nietodCommented:
but what is "Strings"!  How is it declared?  How is the data placed in it?
0
Stevex2Commented:
That makes it check for a null first before continuing through to check for characters
0
Stevex2Commented:
Ahh good check there Nietod.
0
CrovaxAuthor Commented:
Nothin doin i guess. Tried
if(Memo1->Lines->Strings[x] != NULL && Memo1->Lines->Strings[x][y]!='\0')

but still got the access violation...it's a good idea checking for a NULL line before continuing, which is exactly what i was aiming for, but i'm not exactly sure how to do that. I was thinking alone the lines of checking to see if the first char in that line was null but i cant do that or the whole null line. I also though about loading the file into a list box and checking the individual lines there, but my limited knowledge of programming isnt doing me much good :(

Strings in Memo1->Lines->Strings is declaired by Borland C++ compiler and i'm not exactly how it declairs them. I think it's just a 2 dimensional array of chars. (i think so anywayz)

If it would help i could upload the entire Cpp file and give it to yall
0
CrovaxAuthor Commented:
Adjusted points to 200
0
CrovaxAuthor Commented:
Lemme give ya guys some more points for helpin me out here :)
0
Stevex2Commented:
OKay one question real quick.  When you walk through it what line exactly does it bust out with the exception?
0
Stevex2Commented:
And whats the x and y values at that time?
0
nietodCommented:
CRTOVAX, LISTEN,

 WHAT IS "Strings"?

WE MUST KNOW HOW IT IS DECLARED  THE PROBLEM MAY VERY WELL BE THAT YOU'VE SIMPLY DECLARED IT WRONG BUT WE CAN'T TELL UNLESS YOU POST THE CODE USED TO DECLARE

HOW DO YOU FILL THE DATA INTO "Strings"?

WE MUST KNOW

WE CANNOT HELP YOU WITHOUT THIS SORT OF INFORMATION.
0
Stevex2Commented:
I see whats happening.

i Think

The second variables string like nietod had commented might not be getting filled properly.  And yes we need to know how string is declared. did you declare it

char string[25]; or
CString string;

if(Memo1->Lines->String[x].GetLength > 4)//this is due to the string variables having the need for 4 filled slots.
{

for(y=1; y<=7;y++    )
            {
                if(Memo1->Lines->Strings[x][y]!='\0')
                string[y]=Memo1->Lines->Strings[x][y];
                else x+=0;
            }

            if(string[1]=='L' && string[2]=='O' && string[3]=='G' && string[4]=='O')
            {
                LineNum=x;
                break;
            }
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Stevex2Commented:
forgot the () on the GetLength
0
CrovaxAuthor Commented:
Stevex, you are the MAN
0
Stevex2Commented:
That fixed it right up?
0
CrovaxAuthor Commented:
yep, actually, i was inspired by that comment, what i found was that it was actually skipping that blank line but sence y become equil to 7 and tried to check the 7th char of line 11 which happened to be only 6 chars long, it was causing an access violation. All the other lines (excluding the blank one which was skipped) were longer then 7 chars. I didnt need to search 7 chars, i only needed 4...LOGO. So simply by changing the y<=7 in the second for loop i solved the prolbem with a little inspiration. Thanks man, i owe ya. E-mail me if ya need anything (hawk002@bellsouth.net)
0
CrovaxAuthor Commented:
yep, actually, i was inspired by that comment, what i found was that it was actually skipping that blank line but sence y become equil to 7 and tried to check the 7th char of line 11 which happened to be only 6 chars long, it was causing an access violation. All the other lines (excluding the blank one which was skipped) were longer then 7 chars. I didnt need to search 7 chars, i only needed 4...LOGO. So simply by changing the y<=7 in the second for loop i solved the prolbem with a little inspiration. Thanks man, i owe ya. E-mail me if ya need anything (hawk002@bellsouth.net)
0
CrovaxAuthor Commented:
yep, actually, i was inspired by that comment, what i found was that it was actually skipping that blank line but sence y become equil to 7 and tried to check the 7th char of line 11 which happened to be only 6 chars long, it was causing an access violation. All the other lines (excluding the blank one which was skipped) were longer then 7 chars. I didnt need to search 7 chars, i only needed 4...LOGO. So simply by changing the y<=7 in the second for loop i solved the prolbem with a little inspiration. Thanks man, i owe ya. E-mail me if ya need anything (hawk002@bellsouth.net)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.