Menu

spaces test when $ exist

Anonymous
2021-07-12
2021-07-20
  • Anonymous

    Anonymous - 2021-07-12

    Running the code below, I get the message displayed "1-MSG1" - Why?

    01  x    pic x(50).
    ...
    MOVE "$12.5" TO X.
    IF X=SPACES THEN DISPLAY "1-MSG1"  STOP RUN END-IF
    

    If I remove the $ sign, the message does not display.

    I can't understand the first behaviour with the $.

    I am running GNU COBOL 3.1.2.0 on Windows 10.

     
  • Simon Sobisch

    Simon Sobisch - 2021-07-12

    Not sure, the following works fine with the MinGW build from Arnold and the MSYS2 package:

    PROGRAM-ID. 'test'.
    DATA DIVISION.
    WORKING-STORAGE SECTION.
    01  x    pic x(50).
    PROCEDURE DIVISION.
    MOVE "2.5" TO X.
    IF X=SPACES THEN DISPLAY "1-MSG1"
    ELSE             DISPLAY "ALL FINE"
    END-IF
    GOBACK.
    
     
  • Simon Sobisch

    Simon Sobisch - 2021-07-12

    Double-gotcha... Tested with the dollar sign in free format results in the unexpected "1-MSG1".

    MOVE "$12.5" TO X.
    

    leads to

    test.cob:6: warning: spurious '$' detected - ignored [-Wothers]

    --> it is parsed half as MicroFocus compiler directive that is not understood, then the complete line is discarded.

     MOVE "$12.5" TO X.
    

    I think I'll remove that special handling from OpenCOBOL days altogether, because either we see it as valid (possibly unknown) directive, or as ACUCOBOL-GT comment (which those implemented to ignore any MF-style directive), or pass as-is.

    Thank you for bringing up that question!

     
  • Emmad

    Emmad - 2021-07-12

    Thank you for looking into the above issue. I also noticed that the "$" causes other issues, for example, the following code will not display anything:

    ...
    01 X PIC X(10).
    ....
    MOVE "$126.1"  TO X.  *> I Guess this won't execute when the $ is in the string!
    PERFORM  T
    STOP RUN.
    T.
    DISPLAY "---------". 
    
     

    Last edit: Emmad 2021-07-12
    • Simon Sobisch

      Simon Sobisch - 2021-07-13

      Yes, in free-format any line with a $ in column seven that is not recognized as a MF-style directive is skipped completely.
      I'm doing some other cleanup of my local changes, then likely will drop that old leftover code completely.

       
      • David Wall

        David Wall - 2021-07-13

        Will this be the change you suggested back in late 2019 - with reference to [bugs:#577]??.

         

        Related

        Bugs: #577


        Last edit: Simon Sobisch 2021-07-13
        • Simon Sobisch

          Simon Sobisch - 2021-07-13

          (not) cool, we have already an issue for that. No, the change will likely be to get completely rid of that rule.

           
  • Anonymous

    Anonymous - 2021-07-13

    What about $FCDREG. Is there another way short of using the MF "$".
    Should the FCDREG invocation be a "-f" parameter ?

     
    • Simon Sobisch

      Simon Sobisch - 2021-07-13

      That's a topic drift... (and already an existing 4.x feature, which may get backported to 3.x)

       
  • Simon Sobisch

    Simon Sobisch - 2021-07-14

    The "$ in column 7" issue is now fixed in 3.x branch; if you need a binary package for Win32 and the fix "quite bad", then you could upgrade to the latest nightly build (both Mingw and VSCode passed), otherwise you could wait for Arnold to create a new one, but this may be some weeks...

     
    • David Wall

      David Wall - 2021-07-17

      Are you likely to patch 4.beta with the same in the near future ??.

       
      • Simon Sobisch

        Simon Sobisch - 2021-07-17

        Trunk will be updated, step by step and the merges will only be finished shortly after the 3.2 release - but as you've asked nicely I just merged that and a bunch of other easy ones with [r4283].

         

        Related

        Commit: [r4283]

        • David Wall

          David Wall - 2021-07-17

          Thank you Simon - much appreciated.

           
    • David Wall

      David Wall - 2021-07-20

      I see the change in 3.2.dev & also in 4.0.early-dev but NOT in 3.1.2 - unless I'm very much mistaken..
      I'm looking in Files\gnucobol - both the 3.1 folder & the Download Latest Version files appear to be unchanged from 23/12/2020.
      Specifically - https://sourceforge.net/projects/gnucobol/files/latest/download & https://sourceforge.net/projects/gnucobol/files/gnucobol/3.1/gnucobol-3.1.1.tar.xz/download

       

      Last edit: David Wall 2021-07-20
      • Simon Sobisch

        Simon Sobisch - 2021-07-20

        3.1.2 is a released version, we don't change the past. 3.2 is its direct successor and considered to be as stable as 3.1.2, because it is in "dev" state it gets updates - until it gets a release (and maybe this is already the end of 3.x, but I guess not).
        After 3.2 is released the main focus switches to 4.x.

         
        • David Wall

          David Wall - 2021-07-20

          Thanks Simon - I understand - I'll patch the source at my end.

           
  • Anonymous

    Anonymous - 2021-07-14

    Thank you very much for all your efforts and speedy response.

     

Anonymous
Anonymous

Add attachments
Cancel