Re: Alternative COBOL "telco" source program

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

  • Next message: William M. Klein: "How to "write a spec" (was: Alternative COBOL "telco" source program"
    Date: Sat, 29 May 2004 05:30:42 GMT
    
    

    "LX-i" <lxi0007@netscape.net> wrote in message
    news:10bfu1iimqi3te9@corp.supernews.com...
    >L Russ wrote:
    >
    >> Here's my version using C++, no loop. Another FORTRAN CAN'T. Big
    >> deal.
    >> And yes, string and iostream are part of the C++ standard, so it's not
    >> like anyone can't duplicate this code if you've got a conformant
    >> compiler.
    >>
    >> #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;
    >> }
    >>
    >> And I expect, as you've said, that PL/I offers something similar.
    >>
    >> Anyone care to try this in SNOBOL?
    >
    > Here's a COBOL version. (Comments on newsreader-induced wrapping follow -
    > it was compiled using Fujistu v3, using compiler options "MAIN" and
    > "SRF(FREE,FREE)". "*>" marks a comment.)
    >
    > identification division.
    > program-id. numberEighteen.
    > data division.
    > working-storage section.
    > *> Note - COBOL space-pads, so this string has lots of spaces at the end
    > 77 textString pic X(80) value "The quick brown fox jumps over the lazy
    > dog's back.".
    > 77 spaceLength pic 9(02) value zero.
    > procedure division.
    > doIt.
    > *> Two statements, no loop
    > inspect function reverse (textString) tallying spaceLength for leading
    > space
    > display "[" textString (1:80 - spaceLength) "]"
    > *> Three statements in a loop
    > perform varying spaceLength from 80 by -1 until textString (spaceLength:1)
    > not = space
    > continue
    > end-perform
    > display "[" textString(1:spaceLength) "]"
    > *> All done
    > stop run.
    >
    > OK - it looks like the definition for "textString" wrapped, along with the
    > line with the "inspect" statement and the "perform" statements. Bring the
    > lines under them up (if they're wrapped in your reader) and you should be
    > able to run it just fine.
    >
    > (In theory, the loop could work as a one-liner too - just bring the
    > "continue" and the "end-perform" up on the same line as the perform, and
    > make sure they're separated by at least one space.)
    >
    > Output from the above...
    >
    > [The quick brown fox jumps over the lazy dog's back.]
    > [The quick brown fox jumps over the lazy dog's back.]
    >
    >
    > (That'll be $200 USD... ;> )
    >
    >

    Not so fast, the objective is to find the index of the last word
    and as my challenge at http://home.cfl.rr.com/davegemini/pli_cant.faq
    clearly shows, the subsequent output breaks the output into
    2 lines...
    The quick brown fox jumps over the lazy dog's
    back.


  • Next message: William M. Klein: "How to "write a spec" (was: Alternative COBOL "telco" source program"

    Relevant Pages

    • Re: somebody dropped a (warning) bomb
      ... But THE CALLER CANNOT AND MUST NOT CARE! ... warning sounds obviously insane. ... because with another compiler, or with the *same* compiler on another ... Make even "int" arguments (which ...
      (Linux-Kernel)
    • Re: size_t problems
      ... jacob navia wrote: ... int i, j, k; ... Many people would rather NOT TAKE CARE OF THIS STUFF! ... it would have been nice if the *compiler* had warned me about the bug. ...
      (comp.lang.c)
    • Re: Cant find sqrt() definition! Going nuts!
      ... int i,j; ... Stick that through your Microsoft visual C compiler and see what values ... Anyone care to guess. ... Geoff ...
      (uk.comp.os.linux)
    • Re: program
      ... > int main ... > Would it be legal for a compiler (through optimization), ... care, ...
      (comp.lang.c)
    • Re: It Pays to Enrich Your C Skills
      ... Check if you can score a perfect 10 (without using a compiler). ... int main{ ... struct bitfield { ... out if it is a negative integer constant or a constant expression ...
      (comp.lang.c.moderated)

    Loading