Solved

CREATING SUBSTRINGS

Posted on 2003-10-30
7
212 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
  • 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
We have come a long way with backup and data protection — from backing up to floppies, external drives, CDs, Blu-ray, flash drives, SSD drives, and now to the cloud.
This video discusses moving either the default database or any database to a new volume.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

746 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

17 Experts available now in Live!

Get 1:1 Help Now