home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.os.vms      DEC's VAX* line of computers & VMS.      264,096 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 263,864 of 264,096   
   =?UTF-8?Q?Arne_Vajh=C3=B8j?= to All   
   Re: And so? (VMS/XDE) (2/2)   
   01 Dec 25 20:14:15   
   
   [continued from previous message]   
      
            move i to temp-i   
            move xa-elm(i) to temp-xa-elm   
            display temp-i " : " temp-xa-elm   
        end-perform.   
   end program print-x.   
   $ type m2.cob   
   identification division.   
   program-id.m2.   
   *   
   data division.   
   working-storage section.   
   01 ia.   
       03 ia-elm pic 9(8) comp occurs 5 times.   
   01 bia.   
       03 bia-elm pic 9(8) comp occurs 7 times.   
   01 xa.   
       03 xa-elm comp-2 occurs 5 times.   
   01 n pic 9(8) comp.   
   01 i pic 9(8) comp.   
   01 j pic 9(8) comp.   
   01 startj pic 9(8) comp.   
   01 temp-ia-elm pic 9(8) display.   
   01 temp-bia-elm pic 9(8) display.   
   01 temp-xa-elm pic 9(8)v9(2) display.   
   01 temp-i pic 9(8) display.   
   01 temp-ia pic 9(8) comp.   
   01 temp-bia pic 9(8) comp.   
   01 temp-xa comp-2.   
   *   
   procedure division.   
   main-paragraph.   
        move 3 to ia-elm(1)   
        move 5 to ia-elm(2)   
        move 7 to ia-elm(3)   
        move 6 to ia-elm(4)   
        move 4 to ia-elm(5)   
        move 5 to n   
        display "Before:"   
        call "print-i" using n, ia   
        call "sort-i" using n, ia   
        display "After:"   
        call "print-i" using n, ia   
        move 3 to bia-elm(1)   
        move 5 to bia-elm(2)   
        move 7 to bia-elm(3)   
        move 6 to bia-elm(4)   
        move 4 to bia-elm(5)   
        move 2 to bia-elm(6)   
        move 8 to bia-elm(7)   
        move 7 to n   
        display "Before:"   
        call "print-i" using n, bia   
        call "sort-i" using n, bia   
        display "After:"   
        call "print-i" using n, bia   
        move 3.3 to xa-elm(1)   
        move 5.5 to xa-elm(2)   
        move 7.7 to xa-elm(3)   
        move 6.6 to xa-elm(4)   
        move 4.4 to xa-elm(5)   
        move 5 to n   
        display "Before:"   
        call "print-x" using n, xa   
        call "sort-x" using n, xa   
        display "After:"   
        call "print-x" using n, xa   
        stop run.   
   $ cob M2   
   $ cob LIB2   
   $ link M2 + LIB2   
   $ run M2   
   Before:   
   00000001 : 00000003   
   00000002 : 00000005   
   00000003 : 00000007   
   00000004 : 00000006   
   00000005 : 00000004   
   After:   
   00000001 : 00000003   
   00000002 : 00000004   
   00000003 : 00000005   
   00000004 : 00000006   
   00000005 : 00000007   
   Before:   
   00000001 : 00000003   
   00000002 : 00000005   
   00000003 : 00000007   
   00000004 : 00000006   
   00000005 : 00000004   
   00000006 : 00000002   
   00000007 : 00000008   
   After:   
   00000001 : 00000002   
   00000002 : 00000003   
   00000003 : 00000004   
   00000004 : 00000005   
   00000005 : 00000006   
   00000006 : 00000007   
   00000007 : 00000008   
   Before:   
   00000001 : 0000000330   
   00000002 : 0000000550   
   00000003 : 0000000770   
   00000004 : 0000000660   
   00000005 : 0000000440   
   After:   
   00000001 : 0000000330   
   00000002 : 0000000440   
   00000003 : 0000000550   
   00000004 : 0000000660   
   00000005 : 0000000770   
   $ type sort.cob   
   identification division.   
   program-id.:NAME:.   
      
   data division.   
   working-storage section.   
   01 i pic 9(8) comp.   
   01 j pic 9(8) comp.   
   01 startj pic 9(8) comp.   
   01 temp-a :T:.   
   linkage section.   
   01 n-a pic 9(8) comp.   
   01 a.   
       03 a-elm :T: occurs 0 to 1000 times depending on n-a.   
      
   procedure division using n-a, a.   
   main-paragraph.   
        perform varying i from 1 by 1 until i >= n-a   
            compute startj = i + 1   
            perform varying j from startj by 1 until j > n-a   
                if a-elm(j) < a-elm(i) then   
                    move a-elm(j) to temp-a   
                    move a-elm(i) to a-elm(j)   
                    move temp-a to a-elm(i)   
                end-if   
            end-perform   
        end-perform.   
   end program :NAME:.   
   $ type print.cob   
   identification division.   
   program-id.:NAME:.   
      
   data division.   
   working-storage section.   
   01 i pic 9(8) comp.   
   01 temp-a-elm :PT:.   
   01 temp-i pic 9(8) display.   
   linkage section.   
   01 n-a pic 9(8) comp.   
   01 a.   
       03 a-elm :T: occurs 0 to 1000 times depending on n-a.   
      
   procedure division using n-a, a.   
   main-paragraph.   
        perform varying i from 1 by 1 until i > n-a   
            move i to temp-i   
            move a-elm(i) to temp-a-elm   
            display temp-i " : " temp-a-elm   
        end-perform.   
   end program :NAME:.   
   $ type lib3.cob   
   copy "sort.cob" replacing ==:NAME:== by ==sort-i== ==:T:== by ==pic 9(8)   
   comp==.   
   ****   
   copy "print.cob" replacing ==:NAME:== by ==print-i== ==:T:== by ==pic   
   9(8) comp== ==:PT:== by ==pic 9(8) display==.   
   ****   
   copy "sort.cob" replacing ==:NAME:== by ==sort-x== ==:T:== by ==comp-2==.   
   ****   
   copy "print.cob" replacing ==:NAME:== by ==print-x== ==:T:== by   
   ==comp-2== ==:PT:== by ==pic 9(8)v9(2) display==.   
   $ type m3.cob   
   identification division.   
   program-id.m2.   
   *   
   data division.   
   working-storage section.   
   01 ia.   
       03 ia-elm pic 9(8) comp occurs 5 times.   
   01 bia.   
       03 bia-elm pic 9(8) comp occurs 7 times.   
   01 xa.   
       03 xa-elm comp-2 occurs 5 times.   
   01 n pic 9(8) comp.   
   01 i pic 9(8) comp.   
   01 j pic 9(8) comp.   
   01 startj pic 9(8) comp.   
   01 temp-ia-elm pic 9(8) display.   
   01 temp-bia-elm pic 9(8) display.   
   01 temp-xa-elm pic 9(8)v9(2) display.   
   01 temp-i pic 9(8) display.   
   01 temp-ia pic 9(8) comp.   
   01 temp-bia pic 9(8) comp.   
   01 temp-xa comp-2.   
   *   
   procedure division.   
   main-paragraph.   
        move 3 to ia-elm(1)   
        move 5 to ia-elm(2)   
        move 7 to ia-elm(3)   
        move 6 to ia-elm(4)   
        move 4 to ia-elm(5)   
        move 5 to n   
        display "Before:"   
        call "print-i" using n, ia   
        call "sort-i" using n, ia   
        display "After:"   
        call "print-i" using n, ia   
        move 3 to bia-elm(1)   
        move 5 to bia-elm(2)   
        move 7 to bia-elm(3)   
        move 6 to bia-elm(4)   
        move 4 to bia-elm(5)   
        move 2 to bia-elm(6)   
        move 8 to bia-elm(7)   
        move 7 to n   
        display "Before:"   
        call "print-i" using n, bia   
        call "sort-i" using n, bia   
        display "After:"   
        call "print-i" using n, bia   
        move 3.3 to xa-elm(1)   
        move 5.5 to xa-elm(2)   
        move 7.7 to xa-elm(3)   
        move 6.6 to xa-elm(4)   
        move 4.4 to xa-elm(5)   
        move 5 to n   
        display "Before:"   
        call "print-x" using n, xa   
        call "sort-x" using n, xa   
        display "After:"   
        call "print-x" using n, xa   
        stop run.   
   $ cob M3   
   $ cob LIB3   
   $ link M3 + LIB3   
   $ run M3   
   Before:   
   00000001 : 00000003   
   00000002 : 00000005   
   00000003 : 00000007   
   00000004 : 00000006   
   00000005 : 00000004   
   After:   
   00000001 : 00000003   
   00000002 : 00000004   
   00000003 : 00000005   
   00000004 : 00000006   
   00000005 : 00000007   
   Before:   
   00000001 : 00000003   
   00000002 : 00000005   
   00000003 : 00000007   
   00000004 : 00000006   
   00000005 : 00000004   
   00000006 : 00000002   
   00000007 : 00000008   
   After:   
   00000001 : 00000002   
   00000002 : 00000003   
   00000003 : 00000004   
   00000004 : 00000005   
   00000005 : 00000006   
   00000006 : 00000007   
   00000007 : 00000008   
   Before:   
   00000001 : 0000000330   
   00000002 : 0000000550   
   00000003 : 0000000770   
   00000004 : 0000000660   
   00000005 : 0000000440   
   After:   
   00000001 : 0000000330   
   00000002 : 0000000440   
   00000003 : 0000000550   
   00000004 : 0000000660   
   00000005 : 0000000770   
      
   Note that I am not good enough in Cobol to know if this is   
   all standard Cobol, but it happens to work with VMS Cobol.   
      
   I am somewhat skeptical about if any Cobol developers use   
   the generic style in the '3' example.   
      
   Arne   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca