Re: Alternative COBOL "telco" source program
From: David Frank (dave_frank_at_hotmail.com)
Date: 05/29/04
- Previous message: jason: "Re: win98 to XP"
- In reply to: LX-i: "Re: Alternative COBOL "telco" source program"
- Next in thread: William M. Klein: "How to "write a spec" (was: Alternative COBOL "telco" source program"
- Reply: William M. Klein: "How to "write a spec" (was: Alternative COBOL "telco" source program"
- Reply: LX-i: "Re: Alternative COBOL "telco" source program"
- Reply: LX-i: "Re: Alternative COBOL "telco" source program"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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.
- Previous message: jason: "Re: win98 to XP"
- In reply to: LX-i: "Re: Alternative COBOL "telco" source program"
- Next in thread: William M. Klein: "How to "write a spec" (was: Alternative COBOL "telco" source program"
- Reply: William M. Klein: "How to "write a spec" (was: Alternative COBOL "telco" source program"
- Reply: LX-i: "Re: Alternative COBOL "telco" source program"
- Reply: LX-i: "Re: Alternative COBOL "telco" source program"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|