Solved

CREATING SUBSTRINGS

Posted on 2003-10-30
7
222 Views
Last Modified: 2010-04-16
Dear Pascal Experts,

Could you please help me for building a program to create two lists of words or substrings from a list of compound words?

For example:

If I have the following list:

brief overview
be concise
enough information
your question

.........
etc. etc.

How I create two different lists. The first with the first word and the
2nd list with the second word?

In this way:

1st list:

brief
be
enough
your

2nd list:

overview
concise
information
question

Thank you for your help.

EN
0
Comment
Question by:eminitta
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
7 Comments
 
LVL 11

Expert Comment

by:bcladd
ID: 9649557
Sounds a lot like homework.

We would be happy to help you track down problems in your code or answer specific questions but this is not a place where we do homework.

That said:

You will want to be able to read all the lines from the file.

Having read a line into a string you will want to split it on a space. Finding where the space is will use the Pos function; splitting it will use the Copy  function.

You will want to have arrays of strings for first words and for second words.

Hope this helps, -bcl
0
 

Author Comment

by:eminitta
ID: 9656905
There is not a homework.

Ok. I found the right substring and left substring from a pair of words.

AHA! and if I need separate the middle words in phrases with three words?

Thank you.

EN

0
 
LVL 11

Accepted Solution

by:
bcladd earned 50 total points
ID: 9657108
If you know the string is separated by spaces you could try writing a procedure that takes two string variables by reference, the first word variable and the whole string. Your procedure could use what you have figured out to slice off a word from the front of the second parameter, place the word in the first parameter, and modify the second parameter to be the rest of the string. That is:

Line := 'This is a test';
Word := '';

nextWord(Word, Line);
{ Now Word = 'This' and Line = 'is a test' }

nextWord(Word, Line);
{ Word = 'is', Line = 'a test' }


This would permit you to easily handle any number of words.

-bcl

0
 
LVL 11

Expert Comment

by:bcladd
ID: 9681786
My not so humble opinion is that I answered the question(s) posted.

Thus I am sure that there should  be no refund of points. I don't particularly care about points so I won't argue for awarding them to me.

-bcl
0
 

Author Comment

by:eminitta
ID: 9685928
I asked for a solution, not sparse code lines. So, my question was not answered as I want.

EN
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying 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

Suggested Solutions

Configuring Remote Assistance for use with SCCM
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…

738 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