Re: Alternative COBOL "telco" source program

From: David Frank (dave_frank_at_hotmail.com)
Date: 05/30/04


Date: Sun, 30 May 2004 06:56:29 GMT


"L Russ" <lruss@superlink.net> wrote in message
news:cfaeadf3.0405291901.250f89e@posting.google.com...
> "David Frank" <dave_frank@hotmail.com> wrote in message
> news:<7YCtc.32762$Ol3.8747@twister.tampabay.rr.com>...
>> > #include <string>
>> > #include <iostream>
>> > int main() {
>> > const std::string s = "The quick brown fox jumps over the lazy dog's
>> > back. ";
>> > std::cout << s.substr(0, s.find_last_not_of(" ")+1) << std::endl;
>> > return 0;
>> > }
>> >
>>
>> IMO, horrific syntax, but thats nothing new for C++ statements is it?
>
> It's actually quite beautiful.
>
>
>> and its sure not apparent to me that above outputs 2 lines, does it?
>
> No. You're right. I made a mistake when I wrote that code.
> Here is the corrected version, which I believe outputs exactly what
> your code does, including the trailing blanks which result from
> FORTRAN's fixed length strings. It's a little difficult to format
> things when I post. Google is unfriendly to long lines and tabs.
>
> #include <string>
> #include <iostream>
> int main() {
> const int lengthOfDavidFranksFortranString = 80;
> const std::string s1 = "The quick brown fox jumps over the lazy dog's
> back.";
> const std::string s = s1 +
> std::string(lengthOfDavidFranksFortranString-s1.length(),'
> ');
> const std::string::size_type lastNonBlank = s.find_last_not_of(" ");
> const std::string::size_type lastWordIndex =
>
> s.substr(0,lastNonBlank).find_last_of(" ");
> std::cout << s.substr(0, lastWordIndex+1) << "\n" <<
> s.substr(lastWordIndex+1) <<
> std::endl;
> return 0;
> }
>
> Does FORTRAN have support for a varying length string? I mean other
> than that thing that allows functions to be called with different
> length strings, which isn't the same thing. Wrong group to ask in?
>

I'm not sure its even part of the new F2003 standard, there is a
user-developed
varying length string module avail. that provides support.
I personally think using c-strings is all thats really needed if strings
must be
manipulated while holding on to trailing blanks and have my own simple
little
varying string module using c-strings that met challenges presented to
translate
various PL/I varying string examples several years back..

> BTW, you might find this link of interest. Someone who has some bad
> things to say about C++ and OOP, and some interesting things to say
> about software development in general. Can't say that I'm totally
> convinced by all of it, but some thought provoking stuff.
> http://www.leshatton.org/index.html
>
> LR
>



Relevant Pages

  • simple F2003 varying string?
    ... Will my S2P function below provide varying string support ... overhead in its execution? ...
    (comp.lang.fortran)
  • F2003 and varying strings
    ... any of the various monstrous varying string add-ins? ...
    (comp.lang.fortran)
  • Re: Memory management and type casting in XS
    ... the library contain a string and list module. ... the result is a perl object in a scalar. ... it will invoke DESTROY function. ... Because the string module don't have reference ...
    (comp.lang.perl.misc)
  • Re: pointer calling trouble
    ... > string. ... > virtual void parseFilename(const char* fname, ... followed by pointers to char pointers that ... C-strings aren't exactly bad, but they make code ...
    (comp.lang.cpp)
  • Re: String functions deprication
    ... The methods of string and Unicode objects are not deprecated. ... the functions in the string module existed long before ...
    (comp.lang.python)