Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

May all your PUSHes be POPped.


computers / comp.sys.tandem / Re: Ascii char to Decimal value Conversion in Cobol or Screen Cobol

SubjectAuthor
* Ascii char to Decimal value ConversionRupesh Sonawane
`* Re: Ascii char to Decimal value Conversion in Cobol or Screen CobolRupesh Sonawane
 `* Re: Ascii char to Decimal value Conversion in Cobol or Screen CobolBill Honaker
  `* Re: Ascii char to Decimal value Conversion in Cobol or Screen CobolKeith Dick
   `* Re: Ascii char to Decimal value Conversion in Cobol or Screen CobolBill Honaker
    `* Re: Ascii char to Decimal value Conversion in Cobol or Screen CobolKeith Dick
     `* Re: Ascii char to Decimal value Conversion in Cobol or Screen CobolBill Honaker
      `* Re: Ascii char to Decimal value Conversion in Cobol or Screen CobolRupesh Sonawane
       `- Re: Ascii char to Decimal value Conversion in Cobol or Screen CobolKeith Dick

1
Ascii char to Decimal value Conversion

<44fd4f15-b097-4248-89dd-4194871c54c1n@googlegroups.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=325&group=comp.sys.tandem#325

  copy link   Newsgroups: comp.sys.tandem
X-Received: by 2002:a05:620a:440d:: with SMTP id v13mr3600410qkp.111.1641917594402;
Tue, 11 Jan 2022 08:13:14 -0800 (PST)
X-Received: by 2002:a05:6902:1107:: with SMTP id o7mr7918627ybu.465.1641917594149;
Tue, 11 Jan 2022 08:13:14 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.sys.tandem
Date: Tue, 11 Jan 2022 08:13:11 -0800 (PST)
Injection-Info: google-groups.googlegroups.com; posting-host=117.195.59.143; posting-account=3CC5DAoAAABEQfhsjday-xPtjI4fs744
NNTP-Posting-Host: 117.195.59.143
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <44fd4f15-b097-4248-89dd-4194871c54c1n@googlegroups.com>
Subject: Ascii char to Decimal value Conversion
From: rupsonaw...@gmail.com (Rupesh Sonawane)
Injection-Date: Tue, 11 Jan 2022 16:13:14 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 0
 by: Rupesh Sonawane - Tue, 11 Jan 2022 16:13 UTC

How can we convert Ascii string char to its decimal value?

Re: Ascii char to Decimal value Conversion in Cobol or Screen Cobol

<604e34e8-f9d3-43d7-8bfa-5387fba35502n@googlegroups.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=326&group=comp.sys.tandem#326

  copy link   Newsgroups: comp.sys.tandem
X-Received: by 2002:a05:622a:1787:: with SMTP id s7mr4271766qtk.550.1641917658546;
Tue, 11 Jan 2022 08:14:18 -0800 (PST)
X-Received: by 2002:a25:3456:: with SMTP id b83mr7853991yba.178.1641917658329;
Tue, 11 Jan 2022 08:14:18 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.sys.tandem
Date: Tue, 11 Jan 2022 08:14:18 -0800 (PST)
In-Reply-To: <44fd4f15-b097-4248-89dd-4194871c54c1n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=117.195.59.143; posting-account=3CC5DAoAAABEQfhsjday-xPtjI4fs744
NNTP-Posting-Host: 117.195.59.143
References: <44fd4f15-b097-4248-89dd-4194871c54c1n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <604e34e8-f9d3-43d7-8bfa-5387fba35502n@googlegroups.com>
Subject: Re: Ascii char to Decimal value Conversion in Cobol or Screen Cobol
From: rupsonaw...@gmail.com (Rupesh Sonawane)
Injection-Date: Tue, 11 Jan 2022 16:14:18 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 0
 by: Rupesh Sonawane - Tue, 11 Jan 2022 16:14 UTC

How can we convert Ascii string char to its decimal value in Cobol or Screen Cobol requester?

Re: Ascii char to Decimal value Conversion in Cobol or Screen Cobol

<m3irtgtd4eidfgit4faieqnltr33pa4e5e@4ax.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=327&group=comp.sys.tandem#327

  copy link   Newsgroups: comp.sys.tandem
Path: i2pn2.org!i2pn.org!aioe.org!news.mixmin.net!newsreader4.netcologne.de!news.netcologne.de!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx02.iad.POSTED!not-for-mail
From: no_spam_...@x_i_d.com (Bill Honaker)
Newsgroups: comp.sys.tandem
Subject: Re: Ascii char to Decimal value Conversion in Cobol or Screen Cobol
Organization: XID, Ltd.
Message-ID: <m3irtgtd4eidfgit4faieqnltr33pa4e5e@4ax.com>
References: <44fd4f15-b097-4248-89dd-4194871c54c1n@googlegroups.com> <604e34e8-f9d3-43d7-8bfa-5387fba35502n@googlegroups.com>
X-Newsreader: Forte Agent 6.00/32.1186
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 24
X-Complaints-To: abuse@easynews.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Tue, 11 Jan 2022 12:15:29 -0600
X-Received-Bytes: 1644
 by: Bill Honaker - Tue, 11 Jan 2022 18:15 UTC

On Tue, 11 Jan 2022 08:14:18 -0800 (PST), Rupesh Sonawane <rupsonawane@gmail.com> wrote:

> How can we convert Ascii string char to its decimal value in Cobol or Screen Cobol requester?

Rupesh,

In most COBOL languages this is done with a REDEFINES structure. For example:

01 CHAR-TEST-INT PIC 9(4) COMP.
01 CHAR-TEST-CHAR REDEFINES CHAR-TEST-INT.
02 FILLER PIC X.
02 CHAR-TEST-CHAR-VAL PIC X.

....

MOVE ZERO TO CHAR-TEST-INT.
MOVE CHAR-TO-TEST to CHAR-TEST-CHAR-VAL.

....

After the above two statements, the CHAR-TEST-INT variable will contain the decimal value you need.

Disclaimer - this example as entered from memory and may contain syntax errors. It's meant as a description of the solution only.
Bill

Re: Ascii char to Decimal value Conversion in Cobol or Screen Cobol

<1c6aa43e-11c2-494a-b41d-be1315a5f757n@googlegroups.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=328&group=comp.sys.tandem#328

  copy link   Newsgroups: comp.sys.tandem
X-Received: by 2002:a37:6288:: with SMTP id w130mr2263783qkb.691.1641930155076;
Tue, 11 Jan 2022 11:42:35 -0800 (PST)
X-Received: by 2002:a05:6902:1201:: with SMTP id s1mr8524272ybu.4.1641930154918;
Tue, 11 Jan 2022 11:42:34 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.sys.tandem
Date: Tue, 11 Jan 2022 11:42:34 -0800 (PST)
In-Reply-To: <m3irtgtd4eidfgit4faieqnltr33pa4e5e@4ax.com>
Injection-Info: google-groups.googlegroups.com; posting-host=98.42.228.104; posting-account=Lua_ZwoAAADivbVXQF8uKE7dZSUNm9vj
NNTP-Posting-Host: 98.42.228.104
References: <44fd4f15-b097-4248-89dd-4194871c54c1n@googlegroups.com>
<604e34e8-f9d3-43d7-8bfa-5387fba35502n@googlegroups.com> <m3irtgtd4eidfgit4faieqnltr33pa4e5e@4ax.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1c6aa43e-11c2-494a-b41d-be1315a5f757n@googlegroups.com>
Subject: Re: Ascii char to Decimal value Conversion in Cobol or Screen Cobol
From: rkd...@gmail.com (Keith Dick)
Injection-Date: Tue, 11 Jan 2022 19:42:35 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 56
 by: Keith Dick - Tue, 11 Jan 2022 19:42 UTC

On Tuesday, January 11, 2022 at 10:15:31 AM UTC-8, Bill Honaker wrote:
> On Tue, 11 Jan 2022 08:14:18 -0800 (PST), Rupesh Sonawane <rupso...@gmail..com> wrote:
>
> > How can we convert Ascii string char to its decimal value in Cobol or Screen Cobol requester?
> Rupesh,
>
> In most COBOL languages this is done with a REDEFINES structure. For example:
>
> 01 CHAR-TEST-INT PIC 9(4) COMP.
> 01 CHAR-TEST-CHAR REDEFINES CHAR-TEST-INT.
> 02 FILLER PIC X.
> 02 CHAR-TEST-CHAR-VAL PIC X.
>
> ...
>
> MOVE ZERO TO CHAR-TEST-INT.
> MOVE CHAR-TO-TEST to CHAR-TEST-CHAR-VAL.
>
> ...
>
> After the above two statements, the CHAR-TEST-INT variable will contain the decimal value you need.
>
> Disclaimer - this example as entered from memory and may contain syntax errors. It's meant as a description of the solution only.
> Bill

The REDEFINES idea is a valid way to approach the task, but you got a lot of the details wrong. Don't feel bad. I imagine it has been a long time since you have done any COBOL programming!

I think what would work a little better (but is not perfect) would be:

01 ASCII-TEXT PIC X(5).
01 DISPLAY-NUMERIC REDEFINES ASCII-TEXT PIC 9(5).

01 INPUT-TEXT PIC X(5).
01 BINARY-VALUE PIC 9(5) COMP.

MOVE INPUT-TEXT TO ASCII-TEXT.
MOVE DISPLAY-NUMERIC TO BINARY-VALUE.

The above would only work if INPUT-TEXT contained 5 digit characters -- no leading, trailing, or embedded spaces, no sign. With further programming, those limitations can be addressed, but I'm not going to try to do that right now.

For COBOL, not Screen COBOL, it would be possible to call a system procedure that scans an ASCII string that contains a representation of a numeric value and returns a binary value. That would have a lot fewer restrictions that the simple code above has. If I were doing the programming, that probably is the way I would go, unless it was important that the COBOL program be portable to other operating systems.

Re: Ascii char to Decimal value Conversion in Cobol or Screen Cobol

<6kprtg1vmav7m5h8spf2hgsn40vr8kksoc@4ax.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=329&group=comp.sys.tandem#329

  copy link   Newsgroups: comp.sys.tandem
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!newsreader4.netcologne.de!news.netcologne.de!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx26.iad.POSTED!not-for-mail
From: no_spam_...@x_i_d.com (Bill Honaker)
Newsgroups: comp.sys.tandem
Subject: Re: Ascii char to Decimal value Conversion in Cobol or Screen Cobol
Organization: XID, Ltd.
Message-ID: <6kprtg1vmav7m5h8spf2hgsn40vr8kksoc@4ax.com>
References: <44fd4f15-b097-4248-89dd-4194871c54c1n@googlegroups.com> <604e34e8-f9d3-43d7-8bfa-5387fba35502n@googlegroups.com> <m3irtgtd4eidfgit4faieqnltr33pa4e5e@4ax.com> <1c6aa43e-11c2-494a-b41d-be1315a5f757n@googlegroups.com>
X-Newsreader: Forte Agent 6.00/32.1186
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 53
X-Complaints-To: abuse@easynews.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Tue, 11 Jan 2022 14:23:46 -0600
X-Received-Bytes: 3471
 by: Bill Honaker - Tue, 11 Jan 2022 20:23 UTC

On Tue, 11 Jan 2022 11:42:34 -0800 (PST), Keith Dick <rkdick@gmail.com> wrote:

>On Tuesday, January 11, 2022 at 10:15:31 AM UTC-8, Bill Honaker wrote:
>> On Tue, 11 Jan 2022 08:14:18 -0800 (PST), Rupesh Sonawane <rupso...@gmail.com> wrote:
>>
>> > How can we convert Ascii string char to its decimal value in Cobol or Screen Cobol requester?
>> Rupesh,
>>
>> In most COBOL languages this is done with a REDEFINES structure. For example:
>>
>> 01 CHAR-TEST-INT PIC 9(4) COMP.
>> 01 CHAR-TEST-CHAR REDEFINES CHAR-TEST-INT.
>> 02 FILLER PIC X.
>> 02 CHAR-TEST-CHAR-VAL PIC X.
>>
>> ...
>>
>> MOVE ZERO TO CHAR-TEST-INT.
>> MOVE CHAR-TO-TEST to CHAR-TEST-CHAR-VAL.
>>
>> ...
>>
>> After the above two statements, the CHAR-TEST-INT variable will contain the decimal value you need.
>>
>> Disclaimer - this example as entered from memory and may contain syntax errors. It's meant as a description of the solution only.
>> Bill
>
>The REDEFINES idea is a valid way to approach the task, but you got a lot of the details wrong. Don't feel bad. I imagine it has been a long time since you have done any COBOL programming!
>
>I think what would work a little better (but is not perfect) would be:
>
>01 ASCII-TEXT PIC X(5).
>01 DISPLAY-NUMERIC REDEFINES ASCII-TEXT PIC 9(5).
>
>01 INPUT-TEXT PIC X(5).
>01 BINARY-VALUE PIC 9(5) COMP.
>
>MOVE INPUT-TEXT TO ASCII-TEXT.
>MOVE DISPLAY-NUMERIC TO BINARY-VALUE.
>
>The above would only work if INPUT-TEXT contained 5 digit characters -- no leading, trailing, or embedded spaces, no sign. With further programming, those limitations can be addressed, but I'm not going to try to do that right now.
>
>For COBOL, not Screen COBOL, it would be possible to call a system procedure that scans an ASCII string that contains a representation of a numeric value and returns a binary value. That would have a lot fewer restrictions that the simple code above has. If I were doing the programming, that probably is the way I would go, unless it was important that the COBOL program be portable to other operating systems.

Keith,

I understood the question differently than you. I thought he was looking to find the integral equivalent of the ASCII character. That is, a space would be equal to 32.
This would be equivalent to the Basic (or Visuaal Basic) chr() function.

If the OP intended to convert a sequence of numeric characters to a comp field, then your solution is correct.

Bill

Re: Ascii char to Decimal value Conversion in Cobol or Screen Cobol

<7337476e-a662-4387-8092-01f5e618df8an@googlegroups.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=330&group=comp.sys.tandem#330

  copy link   Newsgroups: comp.sys.tandem
X-Received: by 2002:a05:622a:308:: with SMTP id q8mr5136980qtw.463.1641933455032;
Tue, 11 Jan 2022 12:37:35 -0800 (PST)
X-Received: by 2002:a05:6902:1201:: with SMTP id s1mr8836073ybu.4.1641933454914;
Tue, 11 Jan 2022 12:37:34 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.sys.tandem
Date: Tue, 11 Jan 2022 12:37:34 -0800 (PST)
In-Reply-To: <6kprtg1vmav7m5h8spf2hgsn40vr8kksoc@4ax.com>
Injection-Info: google-groups.googlegroups.com; posting-host=98.42.228.104; posting-account=Lua_ZwoAAADivbVXQF8uKE7dZSUNm9vj
NNTP-Posting-Host: 98.42.228.104
References: <44fd4f15-b097-4248-89dd-4194871c54c1n@googlegroups.com>
<604e34e8-f9d3-43d7-8bfa-5387fba35502n@googlegroups.com> <m3irtgtd4eidfgit4faieqnltr33pa4e5e@4ax.com>
<1c6aa43e-11c2-494a-b41d-be1315a5f757n@googlegroups.com> <6kprtg1vmav7m5h8spf2hgsn40vr8kksoc@4ax.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <7337476e-a662-4387-8092-01f5e618df8an@googlegroups.com>
Subject: Re: Ascii char to Decimal value Conversion in Cobol or Screen Cobol
From: rkd...@gmail.com (Keith Dick)
Injection-Date: Tue, 11 Jan 2022 20:37:35 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 79
 by: Keith Dick - Tue, 11 Jan 2022 20:37 UTC

On Tuesday, January 11, 2022 at 12:23:48 PM UTC-8, Bill Honaker wrote:
> On Tue, 11 Jan 2022 11:42:34 -0800 (PST), Keith Dick <rkd...@gmail.com> wrote:
>
> >On Tuesday, January 11, 2022 at 10:15:31 AM UTC-8, Bill Honaker wrote:
> >> On Tue, 11 Jan 2022 08:14:18 -0800 (PST), Rupesh Sonawane <rupso...@gmail.com> wrote:
> >>
> >> > How can we convert Ascii string char to its decimal value in Cobol or Screen Cobol requester?
> >> Rupesh,
> >>
> >> In most COBOL languages this is done with a REDEFINES structure. For example:
> >>
> >> 01 CHAR-TEST-INT PIC 9(4) COMP.
> >> 01 CHAR-TEST-CHAR REDEFINES CHAR-TEST-INT.
> >> 02 FILLER PIC X.
> >> 02 CHAR-TEST-CHAR-VAL PIC X.
> >>
> >> ...
> >>
> >> MOVE ZERO TO CHAR-TEST-INT.
> >> MOVE CHAR-TO-TEST to CHAR-TEST-CHAR-VAL.
> >>
> >> ...
> >>
> >> After the above two statements, the CHAR-TEST-INT variable will contain the decimal value you need.
> >>
> >> Disclaimer - this example as entered from memory and may contain syntax errors. It's meant as a description of the solution only.
> >> Bill
> >
> >The REDEFINES idea is a valid way to approach the task, but you got a lot of the details wrong. Don't feel bad. I imagine it has been a long time since you have done any COBOL programming!
> >
> >I think what would work a little better (but is not perfect) would be:
> >
> >01 ASCII-TEXT PIC X(5).
> >01 DISPLAY-NUMERIC REDEFINES ASCII-TEXT PIC 9(5).
> >
> >01 INPUT-TEXT PIC X(5).
> >01 BINARY-VALUE PIC 9(5) COMP.
> >
> >MOVE INPUT-TEXT TO ASCII-TEXT.
> >MOVE DISPLAY-NUMERIC TO BINARY-VALUE.
> >
> >The above would only work if INPUT-TEXT contained 5 digit characters -- no leading, trailing, or embedded spaces, no sign. With further programming, those limitations can be addressed, but I'm not going to try to do that right now.
> >
> >For COBOL, not Screen COBOL, it would be possible to call a system procedure that scans an ASCII string that contains a representation of a numeric value and returns a binary value. That would have a lot fewer restrictions that the simple code above has. If I were doing the programming, that probably is the way I would go, unless it was important that the COBOL program be portable to other operating systems.
> Keith,
>
> I understood the question differently than you. I thought he was looking to find the integral equivalent of the ASCII character. That is, a space would be equal to 32.
> This would be equivalent to the Basic (or Visuaal Basic) chr() function.
>
> If the OP intended to convert a sequence of numeric characters to a comp field, then your solution is correct.
>
> Bill

Bill,

Ah, I see now. Yes, the original question could be interpreted either way. That's a frequent problem with remote help like this. I wonder which interpretation is the one the original poster had in mind.

Re: Ascii char to Decimal value Conversion in Cobol or Screen Cobol

<263stghmjlvlr5bvi2qdkqpibqg36231h5@4ax.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=331&group=comp.sys.tandem#331

  copy link   Newsgroups: comp.sys.tandem
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx23.iad.POSTED!not-for-mail
From: no_spam_...@x_i_d.com (Bill Honaker)
Newsgroups: comp.sys.tandem
Subject: Re: Ascii char to Decimal value Conversion in Cobol or Screen Cobol
Organization: XID, Ltd.
Message-ID: <263stghmjlvlr5bvi2qdkqpibqg36231h5@4ax.com>
References: <44fd4f15-b097-4248-89dd-4194871c54c1n@googlegroups.com> <604e34e8-f9d3-43d7-8bfa-5387fba35502n@googlegroups.com> <m3irtgtd4eidfgit4faieqnltr33pa4e5e@4ax.com> <1c6aa43e-11c2-494a-b41d-be1315a5f757n@googlegroups.com> <6kprtg1vmav7m5h8spf2hgsn40vr8kksoc@4ax.com> <7337476e-a662-4387-8092-01f5e618df8an@googlegroups.com>
X-Newsreader: Forte Agent 6.00/32.1186
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 63
X-Complaints-To: abuse@easynews.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Tue, 11 Jan 2022 17:04:27 -0600
X-Received-Bytes: 4235
 by: Bill Honaker - Tue, 11 Jan 2022 23:04 UTC

On Tue, 11 Jan 2022 12:37:34 -0800 (PST), Keith Dick <rkdick@gmail.com> wrote:

>On Tuesday, January 11, 2022 at 12:23:48 PM UTC-8, Bill Honaker wrote:
>> On Tue, 11 Jan 2022 11:42:34 -0800 (PST), Keith Dick <rkd...@gmail.com> wrote:
>>
>> >On Tuesday, January 11, 2022 at 10:15:31 AM UTC-8, Bill Honaker wrote:
>> >> On Tue, 11 Jan 2022 08:14:18 -0800 (PST), Rupesh Sonawane <rupso...@gmail.com> wrote:
>> >>
>> >> > How can we convert Ascii string char to its decimal value in Cobol or Screen Cobol requester?
>> >> Rupesh,
>> >>
>> >> In most COBOL languages this is done with a REDEFINES structure. For example:
>> >>
>> >> 01 CHAR-TEST-INT PIC 9(4) COMP.
>> >> 01 CHAR-TEST-CHAR REDEFINES CHAR-TEST-INT.
>> >> 02 FILLER PIC X.
>> >> 02 CHAR-TEST-CHAR-VAL PIC X.
>> >>
>> >> ...
>> >>
>> >> MOVE ZERO TO CHAR-TEST-INT.
>> >> MOVE CHAR-TO-TEST to CHAR-TEST-CHAR-VAL.
>> >>
>> >> ...
>> >>
>> >> After the above two statements, the CHAR-TEST-INT variable will contain the decimal value you need.
>> >>
>> >> Disclaimer - this example as entered from memory and may contain syntax errors. It's meant as a description of the solution only.
>> >> Bill
>> >
>> >The REDEFINES idea is a valid way to approach the task, but you got a lot of the details wrong. Don't feel bad. I imagine it has been a long time since you have done any COBOL programming!
>> >
>> >I think what would work a little better (but is not perfect) would be:
>> >
>> >01 ASCII-TEXT PIC X(5).
>> >01 DISPLAY-NUMERIC REDEFINES ASCII-TEXT PIC 9(5).
>> >
>> >01 INPUT-TEXT PIC X(5).
>> >01 BINARY-VALUE PIC 9(5) COMP.
>> >
>> >MOVE INPUT-TEXT TO ASCII-TEXT.
>> >MOVE DISPLAY-NUMERIC TO BINARY-VALUE.
>> >
>> >The above would only work if INPUT-TEXT contained 5 digit characters -- no leading, trailing, or embedded spaces, no sign. With further programming, those limitations can be addressed, but I'm not going to try to do that right now.
>> >
>> >For COBOL, not Screen COBOL, it would be possible to call a system procedure that scans an ASCII string that contains a representation of a numeric value and returns a binary value. That would have a lot fewer restrictions that the simple code above has. If I were doing the programming, that probably is the way I would go, unless it was important that the COBOL program be portable to other operating systems.
>> Keith,
>>
>> I understood the question differently than you. I thought he was looking to find the integral equivalent of the ASCII character. That is, a space would be equal to 32.
>> This would be equivalent to the Basic (or Visuaal Basic) chr() function.
>>
>> If the OP intended to convert a sequence of numeric characters to a comp field, then your solution is correct.
>>
>> Bill
>
>Bill,
>
>Ah, I see now. Yes, the original question could be interpreted either way. That's a frequent problem with remote help like this. I wonder which interpretation is the one the original poster had in mind.

Keith,

Hopefully the OP will reply to us. Rupesh, please clarify and let us know if your question got answered.
Bill

Re: Ascii char to Decimal value Conversion in Cobol or Screen Cobol

<afc6fe5c-437d-4a73-b075-fe18312ba644n@googlegroups.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=332&group=comp.sys.tandem#332

  copy link   Newsgroups: comp.sys.tandem
X-Received: by 2002:a05:622a:1787:: with SMTP id s7mr6639640qtk.550.1641973254205;
Tue, 11 Jan 2022 23:40:54 -0800 (PST)
X-Received: by 2002:a25:3456:: with SMTP id b83mr12393071yba.178.1641973253790;
Tue, 11 Jan 2022 23:40:53 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.sys.tandem
Date: Tue, 11 Jan 2022 23:40:53 -0800 (PST)
In-Reply-To: <263stghmjlvlr5bvi2qdkqpibqg36231h5@4ax.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2402:8100:231b:1ed9:10dd:6a7c:3c67:f006;
posting-account=3CC5DAoAAABEQfhsjday-xPtjI4fs744
NNTP-Posting-Host: 2402:8100:231b:1ed9:10dd:6a7c:3c67:f006
References: <44fd4f15-b097-4248-89dd-4194871c54c1n@googlegroups.com>
<604e34e8-f9d3-43d7-8bfa-5387fba35502n@googlegroups.com> <m3irtgtd4eidfgit4faieqnltr33pa4e5e@4ax.com>
<1c6aa43e-11c2-494a-b41d-be1315a5f757n@googlegroups.com> <6kprtg1vmav7m5h8spf2hgsn40vr8kksoc@4ax.com>
<7337476e-a662-4387-8092-01f5e618df8an@googlegroups.com> <263stghmjlvlr5bvi2qdkqpibqg36231h5@4ax.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <afc6fe5c-437d-4a73-b075-fe18312ba644n@googlegroups.com>
Subject: Re: Ascii char to Decimal value Conversion in Cobol or Screen Cobol
From: rupsonaw...@gmail.com (Rupesh Sonawane)
Injection-Date: Wed, 12 Jan 2022 07:40:54 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 99
 by: Rupesh Sonawane - Wed, 12 Jan 2022 07:40 UTC

Thanks for your response.
Yes Bill, Keith,
I was looking to find the integral equivalent of the ASCII character. That is, a space would be equal to 32.
So will it work with REDEFINES as mentioned earlier?
I have 7 alphanumeric chars strings and need to convert in Numeric data so I was referring to convert it to the equivalent decimal value of ASCII char..

On Wednesday, January 12, 2022 at 4:34:29 AM UTC+5:30, Bill Honaker wrote:
> On Tue, 11 Jan 2022 12:37:34 -0800 (PST), Keith Dick <rkd...@gmail.com> wrote:
>
> >On Tuesday, January 11, 2022 at 12:23:48 PM UTC-8, Bill Honaker wrote:
> >> On Tue, 11 Jan 2022 11:42:34 -0800 (PST), Keith Dick <rkd...@gmail.com> wrote:
> >>
> >> >On Tuesday, January 11, 2022 at 10:15:31 AM UTC-8, Bill Honaker wrote:
> >> >> On Tue, 11 Jan 2022 08:14:18 -0800 (PST), Rupesh Sonawane <rupso...@gmail.com> wrote:
> >> >>
> >> >> > How can we convert Ascii string char to its decimal value in Cobol or Screen Cobol requester?
> >> >> Rupesh,
> >> >>
> >> >> In most COBOL languages this is done with a REDEFINES structure. For example:
> >> >>
> >> >> 01 CHAR-TEST-INT PIC 9(4) COMP.
> >> >> 01 CHAR-TEST-CHAR REDEFINES CHAR-TEST-INT.
> >> >> 02 FILLER PIC X.
> >> >> 02 CHAR-TEST-CHAR-VAL PIC X.
> >> >>
> >> >> ...
> >> >>
> >> >> MOVE ZERO TO CHAR-TEST-INT.
> >> >> MOVE CHAR-TO-TEST to CHAR-TEST-CHAR-VAL.
> >> >>
> >> >> ...
> >> >>
> >> >> After the above two statements, the CHAR-TEST-INT variable will contain the decimal value you need.
> >> >>
> >> >> Disclaimer - this example as entered from memory and may contain syntax errors. It's meant as a description of the solution only.
> >> >> Bill
> >> >
> >> >The REDEFINES idea is a valid way to approach the task, but you got a lot of the details wrong. Don't feel bad. I imagine it has been a long time since you have done any COBOL programming!
> >> >
> >> >I think what would work a little better (but is not perfect) would be:
> >> >
> >> >01 ASCII-TEXT PIC X(5).
> >> >01 DISPLAY-NUMERIC REDEFINES ASCII-TEXT PIC 9(5).
> >> >
> >> >01 INPUT-TEXT PIC X(5).
> >> >01 BINARY-VALUE PIC 9(5) COMP.
> >> >
> >> >MOVE INPUT-TEXT TO ASCII-TEXT.
> >> >MOVE DISPLAY-NUMERIC TO BINARY-VALUE.
> >> >
> >> >The above would only work if INPUT-TEXT contained 5 digit characters -- no leading, trailing, or embedded spaces, no sign. With further programming, those limitations can be addressed, but I'm not going to try to do that right now.
> >> >
> >> >For COBOL, not Screen COBOL, it would be possible to call a system procedure that scans an ASCII string that contains a representation of a numeric value and returns a binary value. That would have a lot fewer restrictions that the simple code above has. If I were doing the programming, that probably is the way I would go, unless it was important that the COBOL program be portable to other operating systems.
> >> Keith,
> >>
> >> I understood the question differently than you. I thought he was looking to find the integral equivalent of the ASCII character. That is, a space would be equal to 32.
> >> This would be equivalent to the Basic (or Visuaal Basic) chr() function.
> >>
> >> If the OP intended to convert a sequence of numeric characters to a comp field, then your solution is correct.
> >>
> >> Bill
> >
> >Bill,
> >
> >Ah, I see now. Yes, the original question could be interpreted either way. That's a frequent problem with remote help like this. I wonder which interpretation is the one the original poster had in mind.
> Keith,
>
> Hopefully the OP will reply to us. Rupesh, please clarify and let us know if your question got answered.
> Bill

Re: Ascii char to Decimal value Conversion in Cobol or Screen Cobol

<6b53dc6f-8a5a-42cd-871c-627ab1d17fcdn@googlegroups.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=333&group=comp.sys.tandem#333

  copy link   Newsgroups: comp.sys.tandem
X-Received: by 2002:a05:6214:21ea:: with SMTP id p10mr7371242qvj.65.1641983174323;
Wed, 12 Jan 2022 02:26:14 -0800 (PST)
X-Received: by 2002:a05:6902:1107:: with SMTP id o7mr13056898ybu.465.1641983174092;
Wed, 12 Jan 2022 02:26:14 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.sys.tandem
Date: Wed, 12 Jan 2022 02:26:13 -0800 (PST)
In-Reply-To: <afc6fe5c-437d-4a73-b075-fe18312ba644n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=98.42.228.104; posting-account=Lua_ZwoAAADivbVXQF8uKE7dZSUNm9vj
NNTP-Posting-Host: 98.42.228.104
References: <44fd4f15-b097-4248-89dd-4194871c54c1n@googlegroups.com>
<604e34e8-f9d3-43d7-8bfa-5387fba35502n@googlegroups.com> <m3irtgtd4eidfgit4faieqnltr33pa4e5e@4ax.com>
<1c6aa43e-11c2-494a-b41d-be1315a5f757n@googlegroups.com> <6kprtg1vmav7m5h8spf2hgsn40vr8kksoc@4ax.com>
<7337476e-a662-4387-8092-01f5e618df8an@googlegroups.com> <263stghmjlvlr5bvi2qdkqpibqg36231h5@4ax.com>
<afc6fe5c-437d-4a73-b075-fe18312ba644n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <6b53dc6f-8a5a-42cd-871c-627ab1d17fcdn@googlegroups.com>
Subject: Re: Ascii char to Decimal value Conversion in Cobol or Screen Cobol
From: rkd...@gmail.com (Keith Dick)
Injection-Date: Wed, 12 Jan 2022 10:26:14 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 145
 by: Keith Dick - Wed, 12 Jan 2022 10:26 UTC

On Tuesday, January 11, 2022 at 11:40:54 PM UTC-8, rupso...@gmail.com wrote:
> Thanks for your response.
> Yes Bill, Keith,
> I was looking to find the integral equivalent of the ASCII character. That is, a space would be equal to 32.
> So will it work with REDEFINES as mentioned earlier?
> I have 7 alphanumeric chars strings and need to convert in Numeric data so I was referring to convert it to the equivalent decimal value of ASCII char.
> On Wednesday, January 12, 2022 at 4:34:29 AM UTC+5:30, Bill Honaker wrote:
> > On Tue, 11 Jan 2022 12:37:34 -0800 (PST), Keith Dick <rkd...@gmail.com> wrote:
> >
> > >On Tuesday, January 11, 2022 at 12:23:48 PM UTC-8, Bill Honaker wrote:
> > >> On Tue, 11 Jan 2022 11:42:34 -0800 (PST), Keith Dick <rkd...@gmail.com> wrote:
> > >>
> > >> >On Tuesday, January 11, 2022 at 10:15:31 AM UTC-8, Bill Honaker wrote:
> > >> >> On Tue, 11 Jan 2022 08:14:18 -0800 (PST), Rupesh Sonawane <rupso....@gmail.com> wrote:
> > >> >>
> > >> >> > How can we convert Ascii string char to its decimal value in Cobol or Screen Cobol requester?
> > >> >> Rupesh,
> > >> >>
> > >> >> In most COBOL languages this is done with a REDEFINES structure. For example:
> > >> >>
> > >> >> 01 CHAR-TEST-INT PIC 9(4) COMP.
> > >> >> 01 CHAR-TEST-CHAR REDEFINES CHAR-TEST-INT.
> > >> >> 02 FILLER PIC X.
> > >> >> 02 CHAR-TEST-CHAR-VAL PIC X.
> > >> >>
> > >> >> ...
> > >> >>
> > >> >> MOVE ZERO TO CHAR-TEST-INT.
> > >> >> MOVE CHAR-TO-TEST to CHAR-TEST-CHAR-VAL.
> > >> >>
> > >> >> ...
> > >> >>
> > >> >> After the above two statements, the CHAR-TEST-INT variable will contain the decimal value you need.
> > >> >>
> > >> >> Disclaimer - this example as entered from memory and may contain syntax errors. It's meant as a description of the solution only.
> > >> >> Bill
> > >> >
> > >> >The REDEFINES idea is a valid way to approach the task, but you got a lot of the details wrong. Don't feel bad. I imagine it has been a long time since you have done any COBOL programming!
> > >> >
> > >> >I think what would work a little better (but is not perfect) would be:
> > >> >
> > >> >01 ASCII-TEXT PIC X(5).
> > >> >01 DISPLAY-NUMERIC REDEFINES ASCII-TEXT PIC 9(5).
> > >> >
> > >> >01 INPUT-TEXT PIC X(5).
> > >> >01 BINARY-VALUE PIC 9(5) COMP.
> > >> >
> > >> >MOVE INPUT-TEXT TO ASCII-TEXT.
> > >> >MOVE DISPLAY-NUMERIC TO BINARY-VALUE.
> > >> >
> > >> >The above would only work if INPUT-TEXT contained 5 digit characters -- no leading, trailing, or embedded spaces, no sign. With further programming, those limitations can be addressed, but I'm not going to try to do that right now.
> > >> >
> > >> >For COBOL, not Screen COBOL, it would be possible to call a system procedure that scans an ASCII string that contains a representation of a numeric value and returns a binary value. That would have a lot fewer restrictions that the simple code above has. If I were doing the programming, that probably is the way I would go, unless it was important that the COBOL program be portable to other operating systems.
> > >> Keith,
> > >>
> > >> I understood the question differently than you. I thought he was looking to find the integral equivalent of the ASCII character. That is, a space would be equal to 32.
> > >> This would be equivalent to the Basic (or Visuaal Basic) chr() function.
> > >>
> > >> If the OP intended to convert a sequence of numeric characters to a comp field, then your solution is correct.
> > >>
> > >> Bill
> > >
> > >Bill,
> > >
> > >Ah, I see now. Yes, the original question could be interpreted either way. That's a frequent problem with remote help like this. I wonder which interpretation is the one the original poster had in mind.
> > Keith,
> >
> > Hopefully the OP will reply to us. Rupesh, please clarify and let us know if your question got answered.
> > Bill

Yes, the code that Bill posted will get the value of the ASCII code for a single character.

You said you need to get the value of each character of a seven-character string. If you don't already have each character in a separate data field, you might need to use REDEFINES and OCCURS to let you pick out each character individually.

Something like this, I believe:

01 SEVEN-CHAR-FIELD PIC X(7).
01 ARRAY-GROUP REDEFINES SEVEN-CHAR-FIELD..
02 ONE-CHAR PIC X OCCURS 7 TIMES.
01 I PIC 9.

PERFORM 200-GET-ONE-CHAR-VALUE VARYING I FROM 1 TO 7.

....

200-GET-ONE-CHAR-VALUE.
MOVE ZERO TO CHAR-TEST-INT.
MOVE ONE-CHAR (I) TO CHAR-TEST-CHAR-VAL.
DISPLAY CHAR-TEST-INT.

The fields I didn't declare here are from Bill's code. This code just displays the decimal code value of each character. You'll probably want to do something besides that with those values.

I never remember the rules about using OCCURS and REDEFINES together, and I always need to check the manual. I think the rule is that you cannot use both REDEFINES and OCCURS on the same data item. That is why I nested the OCCUR under the item that uses REDEFINES. But I am not sure that is the rule, and I did not check the manual before writing this suggested code, so I might have gotten the syntax wrong for putting an array of one-character fields over the seven-character field. Check the manual before believing what I wrote is exactly correct.

I believe Screen COBOL is somewhat limited in this kind of manipulation, so this suggested code might only work in ordinary COBOL, not in Screen COBOL.. Right now, I don't remember what limitation of Screen COBOL would keep this from working (and maybe I'm mistaken about it not working in Screen COBOL).

Good luck!

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor