Code Comments
Programming Forum and web based access to our favorite programming groups.Does anyone have a favourite way of specifying that a PERFORM should continue indefinitely? Consider the following code: move low-values to wpppauthorblurb perform until 1 = 2 perform get-input if itsa-tag OR finished exit perform end-if string wpppauthorblurb delimited by low-values INPUT-RECORD (1:INPUT-LEN) delimited by size '<br> ' delimited by size into wpppauthorblurb end-string end-perform The first PERFORM should keep going until it is exited by the EXIT PERFORM on line 5. The best I could do on the spot was create a condition that can never be true (1 = 2), but I think this is pretty lame...:-) This is Fujitsu NetCOBOL but I'd be interested in seeing any solutions anyone has. PERFORM FOREVER would be... Pete.
Post Follow-up to this messagePete Dashwood wrote: > > Does anyone have a favourite way of specifying that a PERFORM should > continue indefinitely? > > Consider the following code: > > move low-values to wpppauthorblurb > perform until 1 = 2 > perform get-input > if itsa-tag OR finished > exit perform > end-if > string > wpppauthorblurb > delimited by low-values > INPUT-RECORD (1:INPUT-LEN) > delimited by size > '<br> ' > delimited by size > into > wpppauthorblurb > end-string > end-perform > > The first PERFORM should keep going until it is exited by the EXIT PERFORM > on line 5. > > The best I could do on the spot was create a condition that can never be > true (1 = 2), but I think this is pretty lame...:-) > > This is Fujitsu NetCOBOL but I'd be interested in seeing any solutions > anyone has. > > PERFORM FOREVER would be... > > Pete. My favorite way involved defining a condition name. PERFORM UNTIL INFINITE-LOOP-DONE Others might prefer a condition name such as HELL-FREEZES-OVER or DOCDWARF-GETS-THE-LAST-WORD. The actual definition of the condition name is an exercise left to the programmer, but like all old mainframe programmers, I prefer a one character alphanumeric field. With kindest regards, and apologies to DocDwarf... -- http://arnold.trembley.home.att.net/
Post Follow-up to this message> This is Fujitsu NetCOBOL but I'd be interested in seeing > any solutions anyone has. > > PERFORM FOREVER would be... Then look in your Fujitsu manual, Format 5 is: PERFORM WITH NO LIMIT IMHO the EXIT PERFORM is poor usage and should be put in the same bin as GO TO, NEXT SENTENCE, EXIT PARAGRAPH and EXIT SECTION (and a few others). For example, if I wanted to reuse part or all of the imperitive statement in the in-line PERFORM I could extract it and make it a performable paragraph. My definition of 'clean code' is that which can be moved without regard to any positional dependencies. The EXIT PERFORM is not clean code, it would fail to work as designed if moved to a paragraph. (Actually I think it would continue to work correctly in Unisys if I understood what was said).
Post Follow-up to this message> perform until 1 = 2 Some compilers may notice this and could either 1) optimize it as always false or 2) flag an error that comparing two literals is obviously wrong.
Post Follow-up to this message> DOCDWARF-GETS-THE-LAST-WORD Doesn't that always get to be true eventually, no matter how it takes ?
Post Follow-up to this messagePete Dashwood wrote: > > Does anyone have a favourite way of specifying that a PERFORM should > continue indefinitely? > > Consider the following code: > > move low-values to wpppauthorblurb > perform until 1 = 2 > perform get-input > if itsa-tag OR finished > exit perform > end-if > string > wpppauthorblurb > delimited by low-values > INPUT-RECORD (1:INPUT-LEN) > delimited by size > '<br> ' > delimited by size > into > wpppauthorblurb > end-string > end-perform > > The first PERFORM should keep going until it is exited by the EXIT PERFORM > on line 5. > > The best I could do on the spot was create a condition that can never be > true (1 = 2), but I think this is pretty lame...:-) > > This is Fujitsu NetCOBOL but I'd be interested in seeing any solutions > anyone has. > > PERFORM FOREVER would be... > > Pete. > > > In Microfocus PERFORM UNTIL EXIT
Post Follow-up to this messageIn article <Yi8Te.13960$qY1.4299@bgtnsc04-news.ops.worldnet.att.net>, Arnold Trembley <arnold.trembley@worldnet.att.net> wrote: [snip] >With kindest regards, and apologies to DocDwarf... zzzzZZZZzzzzzz... zzzzaaAAWWWKKHHHHhhh... eh? whuh? huh? Oh, sorry, I was just... resting my eyes, did I miss something? DD
Post Follow-up to this message> Consider the following code: I much prefer: perform get-input move low-values to wpppauthorblurb perform with test after until itsa-tag OR finished string wpppauthorblurb delimited by low-values INPUT-RECORD (1:INPUT-LEN) delimited by size '<br> ' delimited by size into wpppauthorblurb end-string perform get-input end-perform
Post Follow-up to this message"Richard" <riplin@Azonic.co.nz> wrote in message news:1126000191.100198.280090@g47g2000cwa.googlegroups.com... > > I much prefer: > > perform get-input > move low-values to wpppauthorblurb > perform > with test after > until itsa-tag OR finished > > string > wpppauthorblurb delimited by low-values > INPUT-RECORD (1:INPUT-LEN) > delimited by size > '<br> ' delimited by size > into wpppauthorblurb > end-string > perform get-input > end-perform > Yes, you make a very good case, Richard. I don't like (and use extremely rarely) PERFORM WITH TEST AFTER, but I understand why it is necessary here and you have managed to remove the requirement for PERFORM FOREVER..., which is a very useful way to solve problems... :-) I think your solution is elegant and I'm going to use it. Thanks. Pete.
Post Follow-up to this messageThanks Arnold. Comments below... "Arnold Trembley" <arnold.trembley@worldnet.att.net> wrote in message news:Yi8Te.13960$qY1.4299@bgtnsc04-news.ops.worldnet.att.net... > > > Pete Dashwood wrote: > > > My favorite way involved defining a condition name. > > PERFORM UNTIL INFINITE-LOOP-DONE I immediately thought of using a condition name like FOREVER, but I'm ashamed to say I couldn't see how it would it work. (I was thinking of how I could attach an 88 level to a comparison, but of course, it really only needs to be a set value...Guess I've been away from COBOL too long :-)) Of course, some hours later, in theof the evening, I can see immediately, but I just couldn't at the time... > > Others might prefer a condition name such as HELL-FREEZES-OVER or > DOCDWARF-GETS-THE-LAST-WORD. The actual definition of the condition name > is an exercise left to the programmer, but like all old mainframe > programmers, I prefer a one character alphanumeric field. I agree on the one character (can't shake off my IBM youth where a CLI instruction was better than any alternative... :-)), but I studiously make no comment regarding the temperature of Hell or the loquaciousness of a certain dwarf... :-) Pete.
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.