• How to remove characters in a string in GNUCobol

    From Bruce Axtens@21:1/5 to All on Mon Jan 9 17:59:58 2023
    The statement
    MOVE FUNCTION SUBSTITUTE(WS-PHRASE, "-", "") TO WS-PHRASE-TEMP.
    during compile gives
    warning: alphanumeric literal has zero length; a SPACE will be assumed
    and thus dashes get replaced with spaces.

    How do I *remove* dashes?

    -- Bruce

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From [email protected]@21:1/5 to [email protected] on Tue Jan 10 03:37:58 2023
    In article <[email protected]>,
    Bruce Axtens <[email protected]> wrote:
    The statement
    MOVE FUNCTION SUBSTITUTE(WS-PHRASE, "-", "") TO WS-PHRASE-TEMP.
    during compile gives
    warning: alphanumeric literal has zero length; a SPACE will be assumed
    and thus dashes get replaced with spaces.

    How do I *remove* dashes?

    INITIALIZE SUB2
    WS-FLDB.
    MOVE FUNCTION LENGTH(WS-FLDA) TO WS-FLDLEN.
    PERFORM VARYING SUB1 FROM 1 BY 1
    UNTIL SUB1 > WS-FLDLEN
    IF WS-FLDA(SUB1:1) NOT = '-'
    ADD 1 TO SUB2
    MOVE WS-FLDA(SUB1:1) TO WS-FLDB(SUB2:1)
    END-IF
    END-PERFORM.

    ... or something like that.

    DD

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bruce Axtens@21:1/5 to [email protected] on Mon Jan 9 21:15:31 2023
    On Tuesday, 10 January 2023 at 11:37:59 am UTC+8, [email protected] wrote:

    ... or something like that.

    Indeed, something like that. Thank you very much, sir.

    -- Bruce

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From [email protected]@21:1/5 to [email protected] on Tue Jan 10 18:54:25 2023
    In article <[email protected]>,
    Bruce Axtens <[email protected]> wrote:
    On Tuesday, 10 January 2023 at 11:37:59 am UTC+8, [email protected] wrote:

    ... or something like that.

    Indeed, something like that. Thank you very much, sir.

    Mr Axtens, you did your own homework, showed it to the group and asked for assistance. All I did was continue in the spirit, a mere bagatelle.

    (and that's Sergeant, not Sir... *my* parents were married)

    DD

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Vincent Coen@21:1/5 to Bruce Axtens on Wed Jan 11 14:52:49 2023
    Hello Bruce!

    Tuesday January 10 2023 01:59, Bruce Axtens wrote to All:

    The statement
    MOVE FUNCTION SUBSTITUTE(WS-PHRASE, "-", "") TO WS-PHRASE-TEMP.
    during compile gives
    warning: alphanumeric literal has zero length; a SPACE will be
    assumed and thus dashes get replaced with spaces.

    How do I *remove* dashes?

    Does using SUBSTITUTE-CASE work ?


    Vincent

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From [email protected]@21:1/5 to [email protected] on Thu Mar 9 19:35:07 2023
    In article <[email protected]>,
    Bruce Axtens <[email protected]> wrote:
    The statement
    MOVE FUNCTION SUBSTITUTE(WS-PHRASE, "-", "") TO WS-PHRASE-TEMP.
    during compile gives
    warning: alphanumeric literal has zero length; a SPACE will be assumed
    and thus dashes get replaced with spaces.

    How do I *remove* dashes?

    Pardon the hardcoded lengths.

    01 FILLER.
    05 WS-PHRASE PIC X(50) VALUE SPACES.
    05 WS-PHRASE-TEMP PIC X(50) VALUE SPACES.

    MOVE ZEROES TO SUB2.
    PERFORM VARYING SUB1 FROM 1 BY 1 UNTIL SUB1 > 50
    IF WS-PHRASE(SUB1:1) NOT = '-'
    ADD 1 TO SUB2
    MOVE WS-PHRASE(SUB1:1) TO WS-PHRASE-TEMP(SUB2:1)
    END-IF
    END-PERFORM.

    ... or something like that.

    DD

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)