Skip to main content

Problem:

Create an EXE program in NX and then under Project>Build Settings, select the Link tab and select 'static' and 'character'. The following program runs just fine with the following file supplied as a variable length sequential file and produces the output below:

Resolution:

      $set rdw nobound

       Identification Division.

       Program-Id.  LORINCE.

       Environment Division.

       Input-Output Section.

       File-Control.

           Select In1  Assign to 'Vli.Dat' Status is InFs.

           Select Out1 Assign to 'Vlo.Dat' Status is OutFs.

       Data Division.

       File Section.

       Fd  In1

           Recording Mode is V.

       1   InRdw.

        2   FileLen     Pic S9(4) Comp

                                  Occurs 1 to 2 Times

                                  Depending on Ctr.

       1   InRec.

        2   IrOdo       Pic 9(3).

        2   InData      Pic X Occurs 0 to 27 Times

                              Depending on IrOdo.

       Fd  Out1

           Recording Mode is V.

       1   OutRec.

        2   OrOdo       Pic 9(3).

        2   OutData     Pic X Occurs 0 to 27 Times

                              Depending on OrOdo.

       Working-Storage Section.

       1   WsRecArea.

        2               Pic X(3).

        2   TarGet      Pic X(11).

        2               Pic X(16).

       1   Trackers.

        2   Ctr         Pic S9.

        2   EofSw       Pic X.

        2   InFs        Pic 9(2).

        2   OutFs       Pic 9(2).

        2   RdwArea     Pic 9(4).

        2   RecCnt      Pic 9(8).

        2   TrueLen     Pic 9(8).

       Procedure Division.

       P1.

           Initialize Trackers

           Move 'n' to EofSw

           Open Input  In1

                Output Out1

           Perform P2 Until EofSw = 'y'

           Close In1 Out1

           Goback.

       P2.

           Read  In1 Into WsRecArea

                At End Move 'y' to EofSw

            Not At End

                Add 1 to RecCnt

                Move -1 to Ct

r

                Move FileLen (Ctr) to RdwArea

                Subtract 4 From RdwArea Giving TrueLen

                Display '  Record Count= ' RecCnt

                        '  Rdw Length= ' RdwArea

                        '  True Length= ' TrueLen

                If TarGet = 'Micro Focus'

                   Display '  match found '

                   Move InRec to OutRec

                   Write OutRec

                   Move Spaces to WsRecArea

                 Else

                   Display ' match not found '

                   Move InRec to OutRec

                   Write OutRec

                   Move Spaces to WsRecArea

                End-If

           End-Read.

003Mic

005Micro

011Micro Focus

027Microsoft is not there, yet

001X

011Micro Focus

027Microsoft is not there, yet

030for one to be looking forth

000

011Micro Focus

005Micro

003Mic

       Record Count= 00000001  Rdw Length= 0010  True Length= 00000006

      match not found

       Record Count= 00000002  Rdw Length= 0012  True Length= 00000008

      match not found

       Record Count= 00000003  Rdw Length= 0018  True Length= 00000014

       match found

       Record Count= 00000004  Rdw Length= 0034  True Length= 00000030

      match not found

       Record Count= 00000005  Rdw Length= 0008  True Length= 00000004

      match not found

       Record Count= 00000006  Rdw Length= 0018  True Length= 00000014

       match found

       Record Count= 00000007  Rdw Length= 0034  True Length= 00000030

      match not found

       Record Count= 00000008  Rdw Length= 0034  True Length= 00000030

      match not found

       Record Count= 00000009  Rdw Length= 0007  True Length= 00000003

      match not found

       Record Count= 00000010  Rdw Length= 0018  True Length= 00000014

       match found

       Record Count= 00000011  Rdw Length= 0012  True Length= 00000008

      match not found

       Record Count= 00000012  Rdw Length= 0010  True Length= 00000006

      match not found

Old KB# 6881