Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 227
  • Last Modified:

CREATING SUBSTRINGS

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
eminitta
Asked:
eminitta
  • 3
  • 2
1 Solution
 
bcladdCommented:
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
 
eminittaAuthor Commented:
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
 
bcladdCommented:
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
 
bcladdCommented:
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
 
eminittaAuthor Commented:
I asked for a solution, not sparse code lines. So, my question was not answered as I want.

EN
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now