Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4095
Number of posts: 14004

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
removing characters from a string variable Posted by delljohnb on 6 Oct 2003 at 7:17 AM
I'm wanting to peel the last several characters off a string variable, and I'm looking for a good routine/function what will perform this. Here is the situation....

read a line from a file into a string variable.

the length of the string is variable, and it has several commas on the end of the "usable" data. While the number of commas is variable, at the time that I read the line, the number of commas in the line is known. Does anyone know of a good routine to accomplish this?

Thanks in advance;
Delljohnb
Report
Re: removing characters from a string variable Posted by zibadian on 6 Oct 2003 at 7:23 AM
: I'm wanting to peel the last several characters off a string variable, and I'm looking for a good routine/function what will perform this. Here is the situation....
:
: read a line from a file into a string variable.
:
: the length of the string is variable, and it has several commas on the end of the "usable" data. While the number of commas is variable, at the time that I read the line, the number of commas in the line is known. Does anyone know of a good routine to accomplish this?
:
: Thanks in advance;
: Delljohnb
:
You can use the Delete() function for this. Here is a small code, which will remove all commas from the end.
  while s[Length(s)]=',' do
    Delete(s, Length(s), 1);

This code also works if the number of commas is unknown.
Report
Re: removing characters from a string variable : THANKS!!! Posted by delljohnb on 6 Oct 2003 at 7:55 AM
: : I'm wanting to peel the last several characters off a string variable, and I'm looking for a good routine/function what will perform this. Here is the situation....
: :
: : read a line from a file into a string variable.
: :
: : the length of the string is variable, and it has several commas on the end of the "usable" data. While the number of commas is variable, at the time that I read the line, the number of commas in the line is known. Does anyone know of a good routine to accomplish this?
: :
: : Thanks in advance;
: : Delljohnb
: :
: You can use the Delete() function for this. Here is a small code, which will remove all commas from the end.
:
:   while s[Length(s)]=',' do
:     Delete(s, Length(s), 1);
: 

: This code also works if the number of commas is unknown.
:
EXCELLENT!!! Wow...fast response. That works great!!! I knew there was a short routine out there. I just couldn't put together the logic manipulation to get a concise one....this will work GREAT!. Thanks.

Delljohnb




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.