Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Pascal Borland > String and Char...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 13 Topic 1025 of 1102
Post > Topic >>

String and Char handling limitations:

by CheckWilliamOut <wduplooy@[EMAIL PROTECTED] > Apr 25, 2007 at 03:13 PM

Dear all,

Why does Pascal limit functions you can perform on Strings and Chars.
There are two functions
in particular that only work with Intergers and other number types:

The Case statment and the "and", "or" and "xor" operators. Check these
illegal examples:

----------------------------------------------

var
   This_word : string[30];

Begin
   Case This_word of
      'hello' : Write('Greetings');
      'done'  : Write('It is Finished');
   end;
end.

----------------------------------------------

var
   This_letter : char;


begin
   If this_letter <> 'a' or 'b' then
      Writeln('Neither A nor B were detected');
end.

----------------------------------------------

Is there another way perform these operations on a string or
character?

My purpose is to extract certain words from a text file, then convert
them to something else and write the conversions in a new text file.

For example: I want to open My_Text_File extract or search for all
occurances of "one" then make the program convert it to "1" and then
write the conversions (including any unconverted words) in
a new text file.

The problem is, I'm having trouble extracting only the words I want--
and getting the program to ignore spaces, commas, quotation marks,
carriage returns, and every other symbol and punctuation mark on the
keyboard.

First I tried using

repeat
   Read(text_file, data);
   Write(temporary_file, data);
until data = ' ';

Then I close the temporary file, and re-open it for reading, read the
characters--or the word--that has been stored there, then match it and
convert.

However that method is causing an infinite loop and there is no way a
"While not EOF" command can be used successfully to avoid the infinite
loop. This also causes problems because I want the computer to
recognize:

then

as being = to

Then
then.
then,
then!
"then"
then."
then?

and any other combination you can think of

Also when it comes to the end of a file, it doesn't find anymore
spaces and that is what is causing the infinit loop.

Ideally I want to be able to define the "until" part as:

until data <> 'a'..'z' or 'A'..'Z';

Sadly you can only do that with integers!

Perhaps in the above example if I change each letter to it's numeric
equivalent?

CheckWilliamOut




 13 Posts in Topic:
String and Char handling limitations:
CheckWilliamOut <wdupl  2007-04-25 15:13:54 
Re: String and Char handling limitations:
Wolf Behrenhoff <NoSpa  2007-04-26 12:07:07 
Re: String and Char handling limitations:
Wolf Behrenhoff <NoSpa  2007-04-26 12:19:16 
Re: String and Char handling limitations:
Femme Verbeek <fv@[EMA  2007-04-26 18:28:22 
Re: String and Char handling limitations:
Jyrki Lahtonen <lahton  2007-04-26 23:10:07 
Re: String and Char handling limitations:
Marco van de Voort <ma  2007-04-27 21:44:33 
Re: String and Char handling limitations:
CheckWilliamOut <wdupl  2007-05-05 03:31:57 
Re: String and Char handling limitations:
"Jochen" <jo  2007-05-05 16:16:09 
Re: String and Char handling limitations:
Jyrki Lahtonen <lahton  2007-05-07 23:44:27 
Re: String and Char handling limitations:
Marco van de Voort <ma  2007-05-07 20:50:56 
Re: String and Char handling limitations:
Jyrki Lahtonen <lahton  2007-05-08 00:10:34 
Re: String and Char handling limitations:
"Jochen" <jo  2007-05-08 01:24:33 
Re: String and Char handling limitations:
Tony Stanford <tonysta  2007-05-08 14:42:41 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed May 14 22:36:45 CDT 2008.