Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

More simple newbie questions......

More simple newbie questions......

More simple newbie questions......

Ok, I've decided, programming is not for me, but I need to get this assignment finished so I'm putting it to you guys. Simple(!?) setup. The user enters a string of text in the following format John Doe*123 Baker Street*SomeCity*RG12 2AP. Now, the idea is that once the code is entered, the * will break the string down onto seperate lines. I managed to design the program to stop at the first * but now I'm stuck as to how to get it to read in the next part. My code is attached to give you some idea.

Thanks for any suggestions.

AnsiString Line;
int Index;
    Line = ReadStringPr("Enter a non-empty line of text: ");
//insist on a non-empty line
    while (Line == "")
       Line = ReadStringPr("Please enter a non-empty line: ");
    Index = 1;
    while ((Index <= Length(Line)) && (Line[Index] == '*'))
       Index = Index + 1;
       if (Index <= Length(Line))
while ((Index <= Length(Line)) && (Line[Index] != '*'))
        Index = Index + 1;
else WriteStringCr("You have entered a line without input.");

        return 0;

RE: More simple newbie questions......

first, most implementations of a string are zero-based, so the condition should be (index<length), but I have never seen your style of programming before anyway, so its up to you to figure that one out.

second, you have a while loop with a condition that is identical to that of the if-statement directly above it.

I'm sorry, but that is all I could pick out of there with the time I have.

Hope this helps,

RE: More simple newbie questions......

    AnsiString is 1 based. It is based on a Pascal string.

    In addition to CINC's comment, AnsiString has a length method that is called like Line.Length().

James P. Cottingham

I am the Unknown lead by the Unknowing.
I have done so much with so little
for so long that I am now qualified
to do anything with nothing.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close