Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

On the Internet, nobody knows you're a dog. -- Cartoon caption


devel / comp.lang.forth / get a number from system & convert it to an int into an array

SubjectAuthor
* get a number from system & convert it to an int into an arraygobli...@gmail.com
+* Re: get a number from system & convert it to an int into an arraynone
|+* Re: get a number from system & convert it to an int into an arraygobli...@gmail.com
||`* Re: get a number from system & convert it to an int into an arrayBrian Fox
|| +* Re: get a number from system & convert it to an int into an arrayBrian Fox
|| |`- Re: get a number from system & convert it to an int into an arraygobli...@gmail.com
|| `* Re: get a number from system & convert it to an int into an arrayAnton Ertl
||  `* Re: get a number from system & convert it to an int into an arrayminforth
||   `* Re: get a number from system & convert it to an int into an arraydxforth
||    `* Re: get a number from system & convert it to an int into an arrayminforth
||     +* Re: get a number from system & convert it to an int into an arraydxforth
||     |`* Re: get a number from system & convert it to an int into an arrayNN
||     | `* Re: get a number from system & convert it to an int into an arraynone
||     |  +- Re: get a number from system & convert it to an int into an arraydxforth
||     |  `* Re: get a number from system & convert it to an int into an arraygobli...@gmail.com
||     |   `- Re: get a number from system & convert it to an int into an arraydxforth
||     `- Re: get a number from system & convert it to an int into an arraynone
|+* Re: get a number from system & convert it to an int into an arrayAnton Ertl
||`* Re: get a number from system & convert it to an int into an arraynone
|| +* Re: get a number from system & convert it to an int into an arrayAnton Ertl
|| |`* Re: get a number from system & convert it to an int into an arraynone
|| | `- Re: get a number from system & convert it to an int into an arrayAnton Ertl
|| `- Re: get a number from system & convert it to an int into an arraySpiros Bousbouras
|`* Re: get a number from system & convert it to an int into an arrayHans Bezemer
| `- Re: get a number from system & convert it to an int into an arrayRon AARON
+- Re: get a number from system & convert it to an int into an arrayminforth
+- Re: get a number from system & convert it to an int into an arrayRon AARON
`* Re: get a number from system & convert it to an int into an arraygobli...@gmail.com
 `* Re: get a number from system & convert it to an int into an arrayBrian Fox
  `- Re: get a number from system & convert it to an int into an arraygobli...@gmail.com

Pages:12
get a number from system & convert it to an int into an array

<ce094d5f-a29f-4a1e-ad61-7e7d156f2e35n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23812&group=comp.lang.forth#23812

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ad4:58b0:0:b0:62d:e1f6:82ec with SMTP id ea16-20020ad458b0000000b0062de1f682ecmr801219qvb.5.1686598605279;
Mon, 12 Jun 2023 12:36:45 -0700 (PDT)
X-Received: by 2002:a05:622a:49:b0:3f3:64cd:7c60 with SMTP id
y9-20020a05622a004900b003f364cd7c60mr3457599qtw.3.1686598605096; Mon, 12 Jun
2023 12:36:45 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Mon, 12 Jun 2023 12:36:44 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=2a01:e0a:118:ea0:d24e:999f:d461:dceb;
posting-account=3HjpJwoAAACwXD1UyRZwC1Lkp4Lq1jcg
NNTP-Posting-Host: 2a01:e0a:118:ea0:d24e:999f:d461:dceb
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ce094d5f-a29f-4a1e-ad61-7e7d156f2e35n@googlegroups.com>
Subject: get a number from system & convert it to an int into an array
From: goblinri...@gmail.com (gobli...@gmail.com)
Injection-Date: Mon, 12 Jun 2023 19:36:45 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2141
 by: gobli...@gmail.com - Mon, 12 Jun 2023 19:36 UTC

hello,

I would reuse some external data to do something with

My idea was to :
1.capture data (get some string)
2. display
3. convertit to number
4. dostuff
5. display results

So I defined some

create buffer 1024 allot
5 constant SIZE
variable out
create outputgraph SIZE cells allot
: commandout ( "cmd" -- variable out as string )
r/o open-pipe throw dup buffer swap 256 swap read-file throw swap
close-pipe throw drop buffer swap out 2!
; : [] ( n addr -- addr[n] ) swap cells + ; \ if i understood correctly the array model

here I can now test the capture

s\" psql -c \qselect sum(exp) from experience where champs ilike 'langues' ;\q | sed '3!d' " commandout
out 2@ type \ should be 40 40
ok

now the goal is to convert it as an int inside my array
so I thouthg I could just

out 2@ s>number drop 0 outputgraph [] ! \ may be

but before that even the out 2@ s>number just output 0 0 to the stack & not a number ...

Ideas to fit my goal to capture the "40" value from that example ?

regards

Re: get a number from system & convert it to an int into an array

<nnd$1cf5bc01$55dfbbaf@efa2e9b0bbde3054>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23813&group=comp.lang.forth#23813

  copy link   Newsgroups: comp.lang.forth
Newsgroups: comp.lang.forth
Subject: Re: get a number from system & convert it to an int into an array
References: <ce094d5f-a29f-4a1e-ad61-7e7d156f2e35n@googlegroups.com>
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
From: alb...@cherry (none)
Originator: albert@cherry.(none) (albert)
Message-ID: <nnd$1cf5bc01$55dfbbaf@efa2e9b0bbde3054>
Organization: KPN B.V.
Date: Mon, 12 Jun 2023 21:51:14 +0200
Path: i2pn2.org!i2pn.org!news.swapon.de!newsreader4.netcologne.de!news.netcologne.de!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feed.abavia.com!abe004.abavia.com!abp001.abavia.com!news.kpn.nl!not-for-mail
Lines: 38
Injection-Date: Mon, 12 Jun 2023 21:51:14 +0200
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
X-Received-Bytes: 1698
 by: none - Mon, 12 Jun 2023 19:51 UTC

In article <ce094d5f-a29f-4a1e-ad61-7e7d156f2e35n@googlegroups.com>,
gobli...@gmail.com <goblinrieur@gmail.com> wrote:
>hello,
>
>I would reuse some external data to do something with
>
>My idea was to :
>1.capture data (get some string)
>2. display
>3. convertit to number
>4. dostuff
>5. display results
>
>So I defined some
>
>create buffer 1024 allot
>5 constant SIZE
>variable out
> create outputgraph SIZE cells allot
>: commandout ( "cmd" -- variable out as string )
> r/o open-pipe throw dup buffer swap 256 swap read-file throw swap

I know no Forth that know "open-pipe" like that

<SNIP>

>
>regards
>
Groetjes Albert
>
>
--
Don't praise the day before the evening. One swallow doesn't make spring.
You must not say "hey" before you have crossed the bridge. Don't sell the
hide of the bear until you shot it. Better one bird in the hand than ten in
the air. First gain is a cat spinning. - the Wise from Antrim -

Re: get a number from system & convert it to an int into an array

<2d9978b7-07c1-4210-a2c1-ed9e5cc2269an@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23814&group=comp.lang.forth#23814

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ae9:e846:0:b0:75c:9c99:6e13 with SMTP id a67-20020ae9e846000000b0075c9c996e13mr1540560qkg.5.1686599712765;
Mon, 12 Jun 2023 12:55:12 -0700 (PDT)
X-Received: by 2002:a37:6306:0:b0:760:9298:86af with SMTP id
x6-20020a376306000000b00760929886afmr224927qkb.8.1686599712552; Mon, 12 Jun
2023 12:55:12 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Mon, 12 Jun 2023 12:55:12 -0700 (PDT)
In-Reply-To: <nnd$1cf5bc01$55dfbbaf@efa2e9b0bbde3054>
Injection-Info: google-groups.googlegroups.com; posting-host=2a01:e0a:118:ea0:d24e:999f:d461:dceb;
posting-account=3HjpJwoAAACwXD1UyRZwC1Lkp4Lq1jcg
NNTP-Posting-Host: 2a01:e0a:118:ea0:d24e:999f:d461:dceb
References: <ce094d5f-a29f-4a1e-ad61-7e7d156f2e35n@googlegroups.com> <nnd$1cf5bc01$55dfbbaf@efa2e9b0bbde3054>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <2d9978b7-07c1-4210-a2c1-ed9e5cc2269an@googlegroups.com>
Subject: Re: get a number from system & convert it to an int into an array
From: goblinri...@gmail.com (gobli...@gmail.com)
Injection-Date: Mon, 12 Jun 2023 19:55:12 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2568
 by: gobli...@gmail.com - Mon, 12 Jun 2023 19:55 UTC

Le lundi 12 juin 2023 à 21:51:20 UTC+2, none albert a écrit :
> In article <ce094d5f-a29f-4a1e...@googlegroups.com>,
> gobli...@gmail.com <gobli...@gmail.com> wrote:
> >hello,
> >
> >I would reuse some external data to do something with
> >
> >My idea was to :
> >1.capture data (get some string)
> >2. display
> >3. convertit to number
> >4. dostuff
> >5. display results
> >
> >So I defined some
> >
> >create buffer 1024 allot
> >5 constant SIZE
> >variable out
> > create outputgraph SIZE cells allot
> >: commandout ( "cmd" -- variable out as string )
> > r/o open-pipe throw dup buffer swap 256 swap read-file throw swap
> I know no Forth that know "open-pipe" like that
>
> <SNIP>
>
> >
> >regards
> >
> Groetjes Albert
> >
> >
> --
> Don't praise the day before the evening. One swallow doesn't make spring.
> You must not say "hey" before you have crossed the bridge. Don't sell the
> hide of the bear until you shot it. Better one bird in the hand than ten in
> the air. First gain is a cat spinning. - the Wise from Antrim -

this is just a part of code that works perfectly the issue is on number conversion

Re: get a number from system & convert it to an int into an array

<c4a03d7d-64fd-4c6f-8171-bb4ff7d21403n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23815&group=comp.lang.forth#23815

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:622a:19a2:b0:3f9:aa64:7dbf with SMTP id u34-20020a05622a19a200b003f9aa647dbfmr3364244qtc.4.1686601281458;
Mon, 12 Jun 2023 13:21:21 -0700 (PDT)
X-Received: by 2002:ae9:e803:0:b0:75e:bfde:fd6c with SMTP id
a3-20020ae9e803000000b0075ebfdefd6cmr1551470qkg.1.1686601281251; Mon, 12 Jun
2023 13:21:21 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Mon, 12 Jun 2023 13:21:21 -0700 (PDT)
In-Reply-To: <ce094d5f-a29f-4a1e-ad61-7e7d156f2e35n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=87.157.105.164; posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 87.157.105.164
References: <ce094d5f-a29f-4a1e-ad61-7e7d156f2e35n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c4a03d7d-64fd-4c6f-8171-bb4ff7d21403n@googlegroups.com>
Subject: Re: get a number from system & convert it to an int into an array
From: minfo...@arcor.de (minforth)
Injection-Date: Mon, 12 Jun 2023 20:21:21 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 1540
 by: minforth - Mon, 12 Jun 2023 20:21 UTC

gobli...@gmail.com schrieb am Montag, 12. Juni 2023 um 21:36:46 UTC+2:
> so I thouthg I could just
> out 2@ s>number drop 0 outputgraph [] ! \ may be

Standard with stack diagram:
>NUMBER ( ud1 c-addr1 u1 – – ud2 c-addr2 u2 )
So it expects and returns 4 stack items.

What is the stack diagram of your s>number?

Re: get a number from system & convert it to an int into an array

<3dbed30d-9c8f-4cff-a3df-0b12c9d45947n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23816&group=comp.lang.forth#23816

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a37:5c2:0:b0:74d:dcc:c9b7 with SMTP id 185-20020a3705c2000000b0074d0dccc9b7mr907771qkf.0.1686601446987;
Mon, 12 Jun 2023 13:24:06 -0700 (PDT)
X-Received: by 2002:ae9:ed50:0:b0:75d:4f5f:edbd with SMTP id
c77-20020ae9ed50000000b0075d4f5fedbdmr1527639qkg.11.1686601446782; Mon, 12
Jun 2023 13:24:06 -0700 (PDT)
Path: i2pn2.org!i2pn.org!news.niel.me!glou.org!news.glou.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Mon, 12 Jun 2023 13:24:06 -0700 (PDT)
In-Reply-To: <2d9978b7-07c1-4210-a2c1-ed9e5cc2269an@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=184.75.211.148; posting-account=2z7GawoAAADc70p5SM5AbaCyzjLblS3g
NNTP-Posting-Host: 184.75.211.148
References: <ce094d5f-a29f-4a1e-ad61-7e7d156f2e35n@googlegroups.com>
<nnd$1cf5bc01$55dfbbaf@efa2e9b0bbde3054> <2d9978b7-07c1-4210-a2c1-ed9e5cc2269an@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <3dbed30d-9c8f-4cff-a3df-0b12c9d45947n@googlegroups.com>
Subject: Re: get a number from system & convert it to an int into an array
From: brian....@brianfox.ca (Brian Fox)
Injection-Date: Mon, 12 Jun 2023 20:24:06 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Brian Fox - Mon, 12 Jun 2023 20:24 UTC

On Monday, June 12, 2023 at 3:55:13 PM UTC-4, gobli...@gmail.com wrote:

gForth seems to have NUMBER? .
It takes a byte counted string and returns the number and flag

S" 9999" PAD PLACE ok
ok
ok
PAD NUMBER? ok
..S <2> 9999 -1 ok

Re: get a number from system & convert it to an int into an array

<d72f1f66-e28e-4368-966a-5b6a325a8aefn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23817&group=comp.lang.forth#23817

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ad4:5884:0:b0:626:adc:33c9 with SMTP id dz4-20020ad45884000000b006260adc33c9mr1556243qvb.8.1686601631330;
Mon, 12 Jun 2023 13:27:11 -0700 (PDT)
X-Received: by 2002:ad4:4bac:0:b0:5ef:5726:ba25 with SMTP id
i12-20020ad44bac000000b005ef5726ba25mr1265136qvw.0.1686601631178; Mon, 12 Jun
2023 13:27:11 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Mon, 12 Jun 2023 13:27:10 -0700 (PDT)
In-Reply-To: <3dbed30d-9c8f-4cff-a3df-0b12c9d45947n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=184.75.211.148; posting-account=2z7GawoAAADc70p5SM5AbaCyzjLblS3g
NNTP-Posting-Host: 184.75.211.148
References: <ce094d5f-a29f-4a1e-ad61-7e7d156f2e35n@googlegroups.com>
<nnd$1cf5bc01$55dfbbaf@efa2e9b0bbde3054> <2d9978b7-07c1-4210-a2c1-ed9e5cc2269an@googlegroups.com>
<3dbed30d-9c8f-4cff-a3df-0b12c9d45947n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d72f1f66-e28e-4368-966a-5b6a325a8aefn@googlegroups.com>
Subject: Re: get a number from system & convert it to an int into an array
From: brian....@brianfox.ca (Brian Fox)
Injection-Date: Mon, 12 Jun 2023 20:27:11 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2285
 by: Brian Fox - Mon, 12 Jun 2023 20:27 UTC

On Monday, June 12, 2023 at 4:24:08 PM UTC-4, Brian Fox wrote:
> On Monday, June 12, 2023 at 3:55:13 PM UTC-4, gobli...@gmail.com wrote:
>
> gForth seems to have NUMBER? .
> It takes a byte counted string and returns the number and flag
>
> S" 9999" PAD PLACE ok
> ok
> ok
> PAD NUMBER? ok
> .S <2> 9999 -1 ok

If you can tolerate single precision I wrote this one for Camel Forth
It's weird because zero means a good conversion but that was
more consistent with ABORT" in my system.

: NUMBER? ( addr len -- n ?) \ ?=0 is good conversion
( -- addr len) \ bad conversion
OVER C@ [CHAR] - = DUP >R \ save flag for later
IF 1 /STRING THEN \ remove minus sign
0 0 2SWAP >NUMBER NIP NIP \ convert the number
R> IF SWAP NEGATE SWAP THEN \ negate if needed
;

Re: get a number from system & convert it to an int into an array

<9f9bf0cf-15ff-4fd0-a0cd-96151929b840n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23818&group=comp.lang.forth#23818

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:5846:0:b0:3f9:adc6:a9a7 with SMTP id h6-20020ac85846000000b003f9adc6a9a7mr3247240qth.3.1686602440186;
Mon, 12 Jun 2023 13:40:40 -0700 (PDT)
X-Received: by 2002:a37:b47:0:b0:74e:2917:35fe with SMTP id
68-20020a370b47000000b0074e291735femr1531395qkl.0.1686602439977; Mon, 12 Jun
2023 13:40:39 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!3.us.feeder.erje.net!feeder.erje.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Mon, 12 Jun 2023 13:40:39 -0700 (PDT)
In-Reply-To: <d72f1f66-e28e-4368-966a-5b6a325a8aefn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2a01:e0a:118:ea0:d24e:999f:d461:dceb;
posting-account=3HjpJwoAAACwXD1UyRZwC1Lkp4Lq1jcg
NNTP-Posting-Host: 2a01:e0a:118:ea0:d24e:999f:d461:dceb
References: <ce094d5f-a29f-4a1e-ad61-7e7d156f2e35n@googlegroups.com>
<nnd$1cf5bc01$55dfbbaf@efa2e9b0bbde3054> <2d9978b7-07c1-4210-a2c1-ed9e5cc2269an@googlegroups.com>
<3dbed30d-9c8f-4cff-a3df-0b12c9d45947n@googlegroups.com> <d72f1f66-e28e-4368-966a-5b6a325a8aefn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <9f9bf0cf-15ff-4fd0-a0cd-96151929b840n@googlegroups.com>
Subject: Re: get a number from system & convert it to an int into an array
From: goblinri...@gmail.com (gobli...@gmail.com)
Injection-Date: Mon, 12 Jun 2023 20:40:40 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3234
 by: gobli...@gmail.com - Mon, 12 Jun 2023 20:40 UTC

Le lundi 12 juin 2023 à 22:27:12 UTC+2, Brian Fox a écrit :
> On Monday, June 12, 2023 at 4:24:08 PM UTC-4, Brian Fox wrote:
> > On Monday, June 12, 2023 at 3:55:13 PM UTC-4, gobli...@gmail.com wrote:
> >
> > gForth seems to have NUMBER? .
> > It takes a byte counted string and returns the number and flag
> >
> > S" 9999" PAD PLACE ok
> > ok
> > ok
> > PAD NUMBER? ok
> > .S <2> 9999 -1 ok
> If you can tolerate single precision I wrote this one for Camel Forth
> It's weird because zero means a good conversion but that was
> more consistent with ABORT" in my system.
>
> : NUMBER? ( addr len -- n ?) \ ?=0 is good conversion
> ( -- addr len) \ bad conversion
> OVER C@ [CHAR] - = DUP >R \ save flag for later
> IF 1 /STRING THEN \ remove minus sign
> 0 0 2SWAP >NUMBER NIP NIP \ convert the number
> R> IF SWAP NEGATE SWAP THEN \ negate if needed
> ;
thanks you all
il gnuforth there is an internal "evaluate" word that does it well :) but I didn't knew it
all solution around your versions of number? might have worked too I think ..

now


s\" psql -c \qselect sum(exp) from experience where champs ilike 'langues' ;\q | sed '3!d' " commandout
34 17 at-xy 33 colorize out 2@ type 0 colorize
out 2@ evaluate 1000 / 0 outputgraph [] !

works fine now , so
0 outputgraph [] @

now displays the numbers & I could test a loop over 3 values of index
like
[##########]
[###############################################]
[#########################]

using each of
[....]
.." ["
i outputgraph [] @ 0 do
." #"
loop
.." ]"
[...]

Re: get a number from system & convert it to an int into an array

<2023Jun12.224343@mips.complang.tuwien.ac.at>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23820&group=comp.lang.forth#23820

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: get a number from system & convert it to an int into an array
Date: Mon, 12 Jun 2023 20:43:43 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 11
Message-ID: <2023Jun12.224343@mips.complang.tuwien.ac.at>
References: <ce094d5f-a29f-4a1e-ad61-7e7d156f2e35n@googlegroups.com> <nnd$1cf5bc01$55dfbbaf@efa2e9b0bbde3054>
Injection-Info: dont-email.me; posting-host="e9a375646909654b752ba456c10b25bf";
logging-data="3396535"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18YkwAJlq5howfbZ+q9bUHA"
Cancel-Lock: sha1:Cr22rVnRe3DkQoIYf079MYsgETI=
X-newsreader: xrn 10.11
 by: Anton Ertl - Mon, 12 Jun 2023 20:43 UTC

albert@cherry.(none) (albert) writes:
>I know no Forth that know "open-pipe" like that

Maybe Gforth: <https://gforth.org/manual/Pipes.html>

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: https://forth-standard.org/
EuroForth 2022 proceedings: http://www.euroforth.org/ef22/papers/

Re: get a number from system & convert it to an int into an array

<08604286-6089-4662-a8f9-e8e1451fd630n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23821&group=comp.lang.forth#23821

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:622a:1485:b0:3f7:469b:91a with SMTP id t5-20020a05622a148500b003f7469b091amr2930965qtx.6.1686608783756;
Mon, 12 Jun 2023 15:26:23 -0700 (PDT)
X-Received: by 2002:ad4:4e08:0:b0:626:15f7:623a with SMTP id
dl8-20020ad44e08000000b0062615f7623amr1646770qvb.0.1686608783568; Mon, 12 Jun
2023 15:26:23 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!3.us.feeder.erje.net!feeder.erje.net!border-1.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Mon, 12 Jun 2023 15:26:23 -0700 (PDT)
In-Reply-To: <nnd$1cf5bc01$55dfbbaf@efa2e9b0bbde3054>
Injection-Info: google-groups.googlegroups.com; posting-host=77.174.47.232; posting-account=Ebqe4AoAAABfjCRL4ZqOHWv4jv5ZU4Cs
NNTP-Posting-Host: 77.174.47.232
References: <ce094d5f-a29f-4a1e-ad61-7e7d156f2e35n@googlegroups.com> <nnd$1cf5bc01$55dfbbaf@efa2e9b0bbde3054>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <08604286-6089-4662-a8f9-e8e1451fd630n@googlegroups.com>
Subject: Re: get a number from system & convert it to an int into an array
From: the.beez...@gmail.com (Hans Bezemer)
Injection-Date: Mon, 12 Jun 2023 22:26:23 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 46
 by: Hans Bezemer - Mon, 12 Jun 2023 22:26 UTC

On Monday, June 12, 2023 at 9:51:20 PM UTC+2, none albert wrote:
> In article <ce094d5f-a29f-4a1e...@googlegroups.com>,
> gobli...@gmail.com <gobli...@gmail.com> wrote:
> >hello,
> >
> >I would reuse some external data to do something with
> >
> >My idea was to :
> >1.capture data (get some string)
> >2. display
> >3. convertit to number
> >4. dostuff
> >5. display results
> >
> >So I defined some
> >
> >create buffer 1024 allot
> >5 constant SIZE
> >variable out
> > create outputgraph SIZE cells allot
> >: commandout ( "cmd" -- variable out as string )
> > r/o open-pipe throw dup buffer swap 256 swap read-file throw swap
> I know no Forth that know "open-pipe" like that
>
> <SNIP>
>
> >
> >regards
> >
> Groetjes Albert
> >
> >
> --
> Don't praise the day before the evening. One swallow doesn't make spring.
> You must not say "hey" before you have crossed the bridge. Don't sell the
> hide of the bear until you shot it. Better one bird in the hand than ten in
> the air. First gain is a cat spinning. - the Wise from Antrim -

4tH can as well:

s" ls" input pipe + open error? abort" Cannot open pipe"
dup use begin refill while 0 parse type cr repeat close

Hans Bezemer

Re: get a number from system & convert it to an int into an array

<u68r1e$3g47d$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23825&group=comp.lang.forth#23825

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: clf...@8th-dev.com (Ron AARON)
Newsgroups: comp.lang.forth
Subject: Re: get a number from system & convert it to an int into an array
Date: Tue, 13 Jun 2023 07:24:14 +0300
Organization: A noiseless patient Spider
Lines: 48
Message-ID: <u68r1e$3g47d$1@dont-email.me>
References: <ce094d5f-a29f-4a1e-ad61-7e7d156f2e35n@googlegroups.com>
<nnd$1cf5bc01$55dfbbaf@efa2e9b0bbde3054>
<08604286-6089-4662-a8f9-e8e1451fd630n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 13 Jun 2023 04:24:14 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="bd28b20d15e6c06ce7a8f73da4aaa9b2";
logging-data="3674349"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18sK3nNu30054ZbT364lkrL"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.11.2
Cancel-Lock: sha1:UjtAwmSFBeNhJCqqGkaZdOBNAXk=
Content-Language: en-US, he
In-Reply-To: <08604286-6089-4662-a8f9-e8e1451fd630n@googlegroups.com>
 by: Ron AARON - Tue, 13 Jun 2023 04:24 UTC

On 13/06/2023 1:26, Hans Bezemer wrote:
> On Monday, June 12, 2023 at 9:51:20 PM UTC+2, none albert wrote:
>> In article <ce094d5f-a29f-4a1e...@googlegroups.com>,
>> gobli...@gmail.com <gobli...@gmail.com> wrote:
>>> hello,
>>>
>>> I would reuse some external data to do something with
>>>
>>> My idea was to :
>>> 1.capture data (get some string)
>>> 2. display
>>> 3. convertit to number
>>> 4. dostuff
>>> 5. display results
>>>
>>> So I defined some
>>>
>>> create buffer 1024 allot
>>> 5 constant SIZE
>>> variable out
>>> create outputgraph SIZE cells allot
>>> : commandout ( "cmd" -- variable out as string )
>>> r/o open-pipe throw dup buffer swap 256 swap read-file throw swap
>> I know no Forth that know "open-pipe" like that
>>
>> <SNIP>
>>
>>>
>>> regards
>>>
>> Groetjes Albert
>>>
>>>
>> --
>> Don't praise the day before the evening. One swallow doesn't make spring.
>> You must not say "hey" before you have crossed the bridge. Don't sell the
>> hide of the bear until you shot it. Better one bird in the hand than ten in
>> the air. First gain is a cat spinning. - the Wise from Antrim -
>
> 4tH can as well:
>
> s" ls" input pipe + open error? abort" Cannot open pipe"
> dup use begin refill while 0 parse type cr repeat close
>
> Hans Bezemer

So can 8th, of course, using "f:popen" or (in the about to be released
version) "f:popen3".

Re: get a number from system & convert it to an int into an array

<u68rcq$3g47d$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23826&group=comp.lang.forth#23826

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: clf...@8th-dev.com (Ron AARON)
Newsgroups: comp.lang.forth
Subject: Re: get a number from system & convert it to an int into an array
Date: Tue, 13 Jun 2023 07:30:17 +0300
Organization: A noiseless patient Spider
Lines: 58
Message-ID: <u68rcq$3g47d$2@dont-email.me>
References: <ce094d5f-a29f-4a1e-ad61-7e7d156f2e35n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 13 Jun 2023 04:30:18 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="bd28b20d15e6c06ce7a8f73da4aaa9b2";
logging-data="3674349"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+wpUTJDW6DOMgRzS7bQSbZ"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.11.2
Cancel-Lock: sha1:xbwBguPKD4afoUMEQKjJMr19B8E=
Content-Language: en-US, he
In-Reply-To: <ce094d5f-a29f-4a1e-ad61-7e7d156f2e35n@googlegroups.com>
 by: Ron AARON - Tue, 13 Jun 2023 04:30 UTC

On 12/06/2023 22:36, gobli...@gmail.com wrote:
> hello,
>
> I would reuse some external data to do something with
>
> My idea was to :
> 1.capture data (get some string)
> 2. display
> 3. convertit to number
> 4. dostuff
> 5. display results
>
> So I defined some
>
> create buffer 1024 allot
> 5 constant SIZE
> variable out
> create outputgraph SIZE cells allot
> : commandout ( "cmd" -- variable out as string )
> r/o open-pipe throw dup buffer swap 256 swap read-file throw swap
> close-pipe throw drop buffer swap out 2!
> ;
> : [] ( n addr -- addr[n] ) swap cells + ; \ if i understood correctly the array model
>
> here I can now test the capture
>
> s\" psql -c \qselect sum(exp) from experience where champs ilike 'langues' ;\q | sed '3!d' " commandout
> out 2@ type \ should be 40 40
> ok
>
> now the goal is to convert it as an int inside my array
> so I thouthg I could just
>
> out 2@ s>number drop 0 outputgraph [] ! \ may be
>
> but before that even the out 2@ s>number just output 0 0 to the stack & not a number ...
>
> Ideas to fit my goal to capture the "40" value from that example ?
>
> regards

In 8th you would use "sh$" to (easily) capture the output of the shelled
command, though the command is run in another thread:

: cmd \ s -- s
( nip t:parent swap t:push! ) sh$
-1 sleep t:pop ;

Converting the string to a number is simple, though you probably want to
ensure no whitespace surrounds it:

s:trim >n

Putting that into a new array:

1 a:close

The end result would be [40] (assuming that's what you're looking for).

Re: get a number from system & convert it to an int into an array

<2023Jun13.093141@mips.complang.tuwien.ac.at>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23827&group=comp.lang.forth#23827

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: get a number from system & convert it to an int into an array
Date: Tue, 13 Jun 2023 07:31:41 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 31
Message-ID: <2023Jun13.093141@mips.complang.tuwien.ac.at>
References: <ce094d5f-a29f-4a1e-ad61-7e7d156f2e35n@googlegroups.com> <nnd$1cf5bc01$55dfbbaf@efa2e9b0bbde3054> <2d9978b7-07c1-4210-a2c1-ed9e5cc2269an@googlegroups.com> <3dbed30d-9c8f-4cff-a3df-0b12c9d45947n@googlegroups.com>
Injection-Info: dont-email.me; posting-host="66064d46a222b5841e367fd93f06bac1";
logging-data="3714739"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX195IeHLqFZodtn4AGaHKFnI"
Cancel-Lock: sha1:0SCnfD/toBhvGvUFmxh3igZ4hQI=
X-newsreader: xrn 10.11
 by: Anton Ertl - Tue, 13 Jun 2023 07:31 UTC

Brian Fox <brian.fox@brianfox.ca> writes:
>On Monday, June 12, 2023 at 3:55:13=E2=80=AFPM UTC-4, gobli...@gmail.com wr=
>ote:
>
>gForth seems to have NUMBER? .

Not in the development version. As for S>NUMBER (mentioned also in
this thread), the source code says:

\ don't use this, there is no way to tell success

The current recommendation is

'rec-num' ( addr u -- n/d table | notfound ) gforth-experimental "rec-num"
converts a number to a single/double integer

where table is the xt of TRANSLATE-NUM (and n below table) or
TRANSLATE-DNUM (and d below table); or the top of stack ist the xt of
NOTFOUND.

I find the combination of single- and double-cell numbers in one
recognizer suboptimal as an interface, but it actally simplifies the
implemetation compared to a variant that has separate recognizers for
singles and doubles and only combines them at the recognizer level.

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: https://forth-standard.org/
EuroForth 2022 proceedings: http://www.euroforth.org/ef22/papers/

Re: get a number from system & convert it to an int into an array

<nnd$7087c088$5a284ab0@d0cfa9acb81e04b9>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23828&group=comp.lang.forth#23828

  copy link   Newsgroups: comp.lang.forth
Newsgroups: comp.lang.forth
References: <ce094d5f-a29f-4a1e-ad61-7e7d156f2e35n@googlegroups.com> <nnd$1cf5bc01$55dfbbaf@efa2e9b0bbde3054> <2023Jun12.224343@mips.complang.tuwien.ac.at>
Subject: Re: get a number from system & convert it to an int into an array
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
From: alb...@cherry (none)
Originator: albert@cherry.(none) (albert)
Message-ID: <nnd$7087c088$5a284ab0@d0cfa9acb81e04b9>
Organization: KPN B.V.
Date: Tue, 13 Jun 2023 11:27:00 +0200
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!feeder1.feed.usenet.farm!feed.usenet.farm!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feed.abavia.com!abe006.abavia.com!abp002.abavia.com!news.kpn.nl!not-for-mail
Lines: 29
Injection-Date: Tue, 13 Jun 2023 11:27:00 +0200
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
X-Received-Bytes: 1730
 by: none - Tue, 13 Jun 2023 09:27 UTC

In article <2023Jun12.224343@mips.complang.tuwien.ac.at>,
Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
>albert@cherry.(none) (albert) writes:
>>I know no Forth that know "open-pipe" like that
>
>Maybe Gforth: <https://gforth.org/manual/Pipes.html>

I intended to provoke an introductory remark:
"using a bleeding edge version of Gforth." /
"using a Ubuntu installed version of Gforth." /
"using a 2010 version of winforth"

I didn't realize that the open-pipe had nothing to do
with the question he asked.

I wasn't aware of the online documentation of gforth.
Nothing about "pipe" is to be found in the info docs of
gforth installed by Ubuntu.

>
>- anton

Groetjes Albert
--
Don't praise the day before the evening. One swallow doesn't make spring.
You must not say "hey" before you have crossed the bridge. Don't sell the
hide of the bear until you shot it. Better one bird in the hand than ten in
the air. First gain is a cat spinning. - the Wise from Antrim -

Re: get a number from system & convert it to an int into an array

<69902373-ed63-4082-9b3a-69e7e62261c0n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23829&group=comp.lang.forth#23829

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:5c4e:0:b0:3f8:6bf6:73fb with SMTP id j14-20020ac85c4e000000b003f86bf673fbmr3514510qtj.8.1686649749431;
Tue, 13 Jun 2023 02:49:09 -0700 (PDT)
X-Received: by 2002:a05:6214:92f:b0:62d:f382:9f45 with SMTP id
dk15-20020a056214092f00b0062df3829f45mr469256qvb.6.1686649749259; Tue, 13 Jun
2023 02:49:09 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Tue, 13 Jun 2023 02:49:09 -0700 (PDT)
In-Reply-To: <2023Jun13.093141@mips.complang.tuwien.ac.at>
Injection-Info: google-groups.googlegroups.com; posting-host=2003:f7:1f01:f013:4cdd:4611:b0c2:553;
posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 2003:f7:1f01:f013:4cdd:4611:b0c2:553
References: <ce094d5f-a29f-4a1e-ad61-7e7d156f2e35n@googlegroups.com>
<nnd$1cf5bc01$55dfbbaf@efa2e9b0bbde3054> <2d9978b7-07c1-4210-a2c1-ed9e5cc2269an@googlegroups.com>
<3dbed30d-9c8f-4cff-a3df-0b12c9d45947n@googlegroups.com> <2023Jun13.093141@mips.complang.tuwien.ac.at>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <69902373-ed63-4082-9b3a-69e7e62261c0n@googlegroups.com>
Subject: Re: get a number from system & convert it to an int into an array
From: minfo...@arcor.de (minforth)
Injection-Date: Tue, 13 Jun 2023 09:49:09 +0000
Content-Type: text/plain; charset="UTF-8"
 by: minforth - Tue, 13 Jun 2023 09:49 UTC

Anton Ertl schrieb am Dienstag, 13. Juni 2023 um 09:48:28 UTC+2:
> Brian Fox <bria...@brianfox.ca> writes:
> >On Monday, June 12, 2023 at 3:55:13=E2=80=AFPM UTC-4, gobli...@gmail.com wr=
> >ote:
> >
> >gForth seems to have NUMBER? .
> Not in the development version. As for S>NUMBER (mentioned also in
> this thread), the source code says:
>
> \ don't use this, there is no way to tell success
>
> The current recommendation is
>
> 'rec-num' ( addr u -- n/d table | notfound ) gforth-experimental "rec-num"
> converts a number to a single/double integer
>
> where table is the xt of TRANSLATE-NUM (and n below table) or
> TRANSLATE-DNUM (and d below table); or the top of stack ist the xt of
> NOTFOUND.
>
> I find the combination of single- and double-cell numbers in one
> recognizer suboptimal as an interface, but it actally simplifies the
> implemetation compared to a variant that has separate recognizers for
> singles and doubles and only combines them at the recognizer level.

I use a non-standard
NUMBER? \ ( a u -- 0 | n 1 | d 2 ) convert to single or double number
that handles prefixes, 'c' chars, and the classic dpl. So no surprises here.
Okay for interpreting legacy code.

I use recognizers to differentiate
- when 12. and 1.2 shall be treated differently (for fixed point math)
- when 12. and 1.2 shall be recognized as fp-numbers
- when to be "half-standard": 12. is a double, 1.2 is a float

Somewhat convoluted due to old Forth code heritage, but works well
so far.

Re: get a number from system & convert it to an int into an array

<2023Jun13.185532@mips.complang.tuwien.ac.at>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23833&group=comp.lang.forth#23833

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: get a number from system & convert it to an int into an array
Date: Tue, 13 Jun 2023 16:55:32 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 30
Message-ID: <2023Jun13.185532@mips.complang.tuwien.ac.at>
References: <ce094d5f-a29f-4a1e-ad61-7e7d156f2e35n@googlegroups.com> <nnd$1cf5bc01$55dfbbaf@efa2e9b0bbde3054> <2023Jun12.224343@mips.complang.tuwien.ac.at> <nnd$7087c088$5a284ab0@d0cfa9acb81e04b9>
Injection-Info: dont-email.me; posting-host="66064d46a222b5841e367fd93f06bac1";
logging-data="3853516"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18oVrQ9ie7UY58PHQhzEdtm"
Cancel-Lock: sha1:f42VBLz2oYL9Hnbj1McAyrXqgVw=
X-newsreader: xrn 10.11
 by: Anton Ertl - Tue, 13 Jun 2023 16:55 UTC

albert@cherry.(none) (albert) writes:
>In article <2023Jun12.224343@mips.complang.tuwien.ac.at>,
>Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
>>albert@cherry.(none) (albert) writes:
>>>I know no Forth that know "open-pipe" like that
>>
>>Maybe Gforth: <https://gforth.org/manual/Pipes.html>
>
>I intended to provoke an introductory remark:
>"using a bleeding edge version of Gforth."

Bleeding edge since at least gforth-0.2 (1996).

>Nothing about "pipe" is to be found in the info docs of
>gforth installed by Ubuntu.

That's not surprising given that Ubuntu follows Debian in not
installing the Gforth documentation (not even as a "non-free"
package).

What "info docs of gforth installed by Ubuntu" are you referring to?
There are no info docs of Gforth on my Ubuntu 22.04 laptop except
those that I installed myself.

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: https://forth-standard.org/
EuroForth 2022 proceedings: http://www.euroforth.org/ef22/papers/

Re: get a number from system & convert it to an int into an array

<nnd$0be5d0e7$749f7360@4886b990900e544d>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23835&group=comp.lang.forth#23835

  copy link   Newsgroups: comp.lang.forth
Newsgroups: comp.lang.forth
References: <ce094d5f-a29f-4a1e-ad61-7e7d156f2e35n@googlegroups.com> <2023Jun12.224343@mips.complang.tuwien.ac.at> <nnd$7087c088$5a284ab0@d0cfa9acb81e04b9> <2023Jun13.185532@mips.complang.tuwien.ac.at>
Subject: Re: get a number from system & convert it to an int into an array
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
From: alb...@cherry (none)
Originator: albert@cherry.(none) (albert)
Message-ID: <nnd$0be5d0e7$749f7360@4886b990900e544d>
Organization: KPN B.V.
Date: Tue, 13 Jun 2023 20:49:19 +0200
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!feeder1.feed.usenet.farm!feed.usenet.farm!peer01.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feed.abavia.com!abe005.abavia.com!abp002.abavia.com!news.kpn.nl!not-for-mail
Lines: 42
Injection-Date: Tue, 13 Jun 2023 20:49:19 +0200
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
X-Received-Bytes: 2387
 by: none - Tue, 13 Jun 2023 18:49 UTC

In article <2023Jun13.185532@mips.complang.tuwien.ac.at>,
Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
>albert@cherry.(none) (albert) writes:
>>In article <2023Jun12.224343@mips.complang.tuwien.ac.at>,
>>Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
>>>albert@cherry.(none) (albert) writes:
>>>>I know no Forth that know "open-pipe" like that
>>>
>>>Maybe Gforth: <https://gforth.org/manual/Pipes.html>
>>
>>I intended to provoke an introductory remark:
>>"using a bleeding edge version of Gforth."
>
>Bleeding edge since at least gforth-0.2 (1996).

The goal of this remark is that we can help better,
if we know what Forth is used. Where open-pipe is not standard,
the behaviour can be different on other systems.
>
>>Nothing about "pipe" is to be found in the info docs of
>>gforth installed by Ubuntu.
>
>That's not surprising given that Ubuntu follows Debian in not
>installing the Gforth documentation (not even as a "non-free"
>package).
>
>What "info docs of gforth installed by Ubuntu" are you referring to?
>There are no info docs of Gforth on my Ubuntu 22.04 laptop except
>those that I installed myself.

Maybe I have installed it myself. It commences with
"This manual corresponds to version 0.5.0."
That is later than 0.2.0.

>- anton
groetjes Albert
--
Don't praise the day before the evening. One swallow doesn't make spring.
You must not say "hey" before you have crossed the bridge. Don't sell the
hide of the bear until you shot it. Better one bird in the hand than ten in
the air. First gain is a cat spinning. - the Wise from Antrim -

Re: get a number from system & convert it to an int into an array

<R5M9TZUAhkA5BP6TL@bongo-ra.co>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23836&group=comp.lang.forth#23836

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!paganini.bofh.team!not-for-mail
From: spi...@gmail.com (Spiros Bousbouras)
Newsgroups: comp.lang.forth
Subject: Re: get a number from system & convert it to an int into an array
Date: Tue, 13 Jun 2023 19:14:27 -0000 (UTC)
Organization: To protect and to server
Message-ID: <R5M9TZUAhkA5BP6TL@bongo-ra.co>
References: <ce094d5f-a29f-4a1e-ad61-7e7d156f2e35n@googlegroups.com> <nnd$1cf5bc01$55dfbbaf@efa2e9b0bbde3054> <2023Jun12.224343@mips.complang.tuwien.ac.at>
<nnd$7087c088$5a284ab0@d0cfa9acb81e04b9>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 13 Jun 2023 19:14:27 -0000 (UTC)
Injection-Info: paganini.bofh.team; logging-data="1357143"; posting-host="9H7U5kayiTdk7VIdYU44Rw.user.paganini.bofh.team"; mail-complaints-to="usenet@bofh.team"; posting-account="9dIQLXBM7WM9KzA+yjdR4A";
Cancel-Lock: sha256:BylS8YVTrwHTto7tOPYZBn+KI4i5FDVTmA9P2HMJqjU=
X-Notice: Filtered by postfilter v. 0.9.3
X-Organisation: Weyland-Yutani
X-Server-Commands: nowebcancel
 by: Spiros Bousbouras - Tue, 13 Jun 2023 19:14 UTC

On Tue, 13 Jun 2023 11:27:00 +0200
albert@cherry.(none) (albert) wrote:
> I didn't realize that the open-pipe had nothing to do
> with the question he asked.
>
> I wasn't aware of the online documentation of gforth.
> Nothing about "pipe" is to be found in the info docs of
> gforth installed by Ubuntu.

Do you have any /usr/share/info/gforth* files ? If yes , what does
zcat /usr/share/info/gforth* | grep open-pipe

show ?

Re: get a number from system & convert it to an int into an array

<2023Jun13.215402@mips.complang.tuwien.ac.at>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23837&group=comp.lang.forth#23837

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: get a number from system & convert it to an int into an array
Date: Tue, 13 Jun 2023 19:54:02 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 31
Message-ID: <2023Jun13.215402@mips.complang.tuwien.ac.at>
References: <ce094d5f-a29f-4a1e-ad61-7e7d156f2e35n@googlegroups.com> <2023Jun12.224343@mips.complang.tuwien.ac.at> <nnd$7087c088$5a284ab0@d0cfa9acb81e04b9> <2023Jun13.185532@mips.complang.tuwien.ac.at> <nnd$0be5d0e7$749f7360@4886b990900e544d>
Injection-Info: dont-email.me; posting-host="66064d46a222b5841e367fd93f06bac1";
logging-data="3888408"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19HN+5re5LHuwlaz0Rz3Ft5"
Cancel-Lock: sha1:NvJ6VqKEFYxEABtNt4WXDy3TW+o=
X-newsreader: xrn 10.11
 by: Anton Ertl - Tue, 13 Jun 2023 19:54 UTC

albert@cherry.(none) (albert) writes:
>In article <2023Jun13.185532@mips.complang.tuwien.ac.at>,
>Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
>>albert@cherry.(none) (albert) writes:
>>>In article <2023Jun12.224343@mips.complang.tuwien.ac.at>,
>>>Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
>>>>albert@cherry.(none) (albert) writes:
>>>>>I know no Forth that know "open-pipe" like that
>>>>
>>>>Maybe Gforth: <https://gforth.org/manual/Pipes.html>
>>>
>>>I intended to provoke an introductory remark:
>>>"using a bleeding edge version of Gforth."
>>
>>Bleeding edge since at least gforth-0.2 (1996).
....
>Maybe I have installed it myself. It commences with
>"This manual corresponds to version 0.5.0."

That's from 2000. At that time Debian may still have installed the
manual, but did Ubuntu exist?

Anyway, open-pipe was not documented in 0.5.0, but it was documented
in 0.6.2 (2003).

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: https://forth-standard.org/
EuroForth 2022 proceedings: http://www.euroforth.org/ef22/papers/

Re: get a number from system & convert it to an int into an array

<u6bdko$3tmic$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23842&group=comp.lang.forth#23842

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: get a number from system & convert it to an int into an array
Date: Wed, 14 Jun 2023 13:54:01 +1000
Organization: A noiseless patient Spider
Lines: 34
Message-ID: <u6bdko$3tmic$1@dont-email.me>
References: <ce094d5f-a29f-4a1e-ad61-7e7d156f2e35n@googlegroups.com>
<nnd$1cf5bc01$55dfbbaf@efa2e9b0bbde3054>
<2d9978b7-07c1-4210-a2c1-ed9e5cc2269an@googlegroups.com>
<3dbed30d-9c8f-4cff-a3df-0b12c9d45947n@googlegroups.com>
<2023Jun13.093141@mips.complang.tuwien.ac.at>
<69902373-ed63-4082-9b3a-69e7e62261c0n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 14 Jun 2023 03:54:01 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="825fe1a4e099e12f27daf52d537d5d93";
logging-data="4119116"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19jG6jjlkl/9/oTNXXhHhKt"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.11.2
Cancel-Lock: sha1:CSTbggkkYermcoH4LVRSMO8xlE4=
Content-Language: en-GB
In-Reply-To: <69902373-ed63-4082-9b3a-69e7e62261c0n@googlegroups.com>
 by: dxforth - Wed, 14 Jun 2023 03:54 UTC

On 13/06/2023 7:49 pm, minforth wrote:
> Anton Ertl schrieb am Dienstag, 13. Juni 2023 um 09:48:28 UTC+2:
>> Brian Fox <bria...@brianfox.ca> writes:
>>> On Monday, June 12, 2023 at 3:55:13=E2=80=AFPM UTC-4, gobli...@gmail.com wr=
>>> ote:
>>>
>>> gForth seems to have NUMBER? .
>> Not in the development version. As for S>NUMBER (mentioned also in
>> this thread), the source code says:
>>
>> \ don't use this, there is no way to tell success
>>
>> The current recommendation is
>>
>> 'rec-num' ( addr u -- n/d table | notfound ) gforth-experimental "rec-num"
>> converts a number to a single/double integer
>>
>> where table is the xt of TRANSLATE-NUM (and n below table) or
>> TRANSLATE-DNUM (and d below table); or the top of stack ist the xt of
>> NOTFOUND.
>>
>> I find the combination of single- and double-cell numbers in one
>> recognizer suboptimal as an interface, but it actally simplifies the
>> implemetation compared to a variant that has separate recognizers for
>> singles and doubles and only combines them at the recognizer level.
>
> I use a non-standard
> NUMBER? \ ( a u -- 0 | n 1 | d 2 ) convert to single or double number
> that handles prefixes, 'c' chars, and the classic dpl. So no surprises here.
> Okay for interpreting legacy code.

Some well-known forths use that as it suits the forth interpreter. OTOH
it's overkill for most apps and requires more handling. What's missing
is the intermediate function, similar to >FLOAT but for integer.

Re: get a number from system & convert it to an int into an array

<03f1626b-811e-467e-a691-50742d24bd97n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23843&group=comp.lang.forth#23843

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:6214:14f1:b0:62d:efa8:dc4b with SMTP id k17-20020a05621414f100b0062defa8dc4bmr1056603qvw.4.1686724732535;
Tue, 13 Jun 2023 23:38:52 -0700 (PDT)
X-Received: by 2002:a37:65d2:0:b0:759:15da:1b5c with SMTP id
z201-20020a3765d2000000b0075915da1b5cmr1052415qkb.7.1686724732361; Tue, 13
Jun 2023 23:38:52 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Tue, 13 Jun 2023 23:38:52 -0700 (PDT)
In-Reply-To: <u6bdko$3tmic$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2003:f7:1f01:f081:f984:ecdb:3852:cd36;
posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 2003:f7:1f01:f081:f984:ecdb:3852:cd36
References: <ce094d5f-a29f-4a1e-ad61-7e7d156f2e35n@googlegroups.com>
<nnd$1cf5bc01$55dfbbaf@efa2e9b0bbde3054> <2d9978b7-07c1-4210-a2c1-ed9e5cc2269an@googlegroups.com>
<3dbed30d-9c8f-4cff-a3df-0b12c9d45947n@googlegroups.com> <2023Jun13.093141@mips.complang.tuwien.ac.at>
<69902373-ed63-4082-9b3a-69e7e62261c0n@googlegroups.com> <u6bdko$3tmic$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <03f1626b-811e-467e-a691-50742d24bd97n@googlegroups.com>
Subject: Re: get a number from system & convert it to an int into an array
From: minfo...@arcor.de (minforth)
Injection-Date: Wed, 14 Jun 2023 06:38:52 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3390
 by: minforth - Wed, 14 Jun 2023 06:38 UTC

dxforth schrieb am Mittwoch, 14. Juni 2023 um 05:54:04 UTC+2:
> On 13/06/2023 7:49 pm, minforth wrote:
> > Anton Ertl schrieb am Dienstag, 13. Juni 2023 um 09:48:28 UTC+2:
> >> Brian Fox <bria...@brianfox.ca> writes:
> >>> On Monday, June 12, 2023 at 3:55:13=E2=80=AFPM UTC-4, gobli...@gmail.com wr=
> >>> ote:
> >>>
> >>> gForth seems to have NUMBER? .
> >> Not in the development version. As for S>NUMBER (mentioned also in
> >> this thread), the source code says:
> >>
> >> \ don't use this, there is no way to tell success
> >>
> >> The current recommendation is
> >>
> >> 'rec-num' ( addr u -- n/d table | notfound ) gforth-experimental "rec-num"
> >> converts a number to a single/double integer
> >>
> >> where table is the xt of TRANSLATE-NUM (and n below table) or
> >> TRANSLATE-DNUM (and d below table); or the top of stack ist the xt of
> >> NOTFOUND.
> >>
> >> I find the combination of single- and double-cell numbers in one
> >> recognizer suboptimal as an interface, but it actally simplifies the
> >> implemetation compared to a variant that has separate recognizers for
> >> singles and doubles and only combines them at the recognizer level.
> >
> > I use a non-standard
> > NUMBER? \ ( a u -- 0 | n 1 | d 2 ) convert to single or double number
> > that handles prefixes, 'c' chars, and the classic dpl. So no surprises here.
> > Okay for interpreting legacy code.
> Some well-known forths use that as it suits the forth interpreter. OTOH
> it's overkill for most apps and requires more handling. What's missing
> is the intermediate function, similar to >FLOAT but for integer.

That's besides the point (there is still >NUMBER). The point is whether
recognizers like rec-num or rec-dnum should be part of a Forth kernel.
I won't criticise gforth design decisions, but ISTM that _this_ is overkill
as long as there are easier ways.

Re: get a number from system & convert it to an int into an array

<u6bu97$3vbcn$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23844&group=comp.lang.forth#23844

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: get a number from system & convert it to an int into an array
Date: Wed, 14 Jun 2023 18:38:00 +1000
Organization: A noiseless patient Spider
Lines: 47
Message-ID: <u6bu97$3vbcn$1@dont-email.me>
References: <ce094d5f-a29f-4a1e-ad61-7e7d156f2e35n@googlegroups.com>
<nnd$1cf5bc01$55dfbbaf@efa2e9b0bbde3054>
<2d9978b7-07c1-4210-a2c1-ed9e5cc2269an@googlegroups.com>
<3dbed30d-9c8f-4cff-a3df-0b12c9d45947n@googlegroups.com>
<2023Jun13.093141@mips.complang.tuwien.ac.at>
<69902373-ed63-4082-9b3a-69e7e62261c0n@googlegroups.com>
<u6bdko$3tmic$1@dont-email.me>
<03f1626b-811e-467e-a691-50742d24bd97n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 14 Jun 2023 08:38:00 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="825fe1a4e099e12f27daf52d537d5d93";
logging-data="4173207"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19EA2f9iawFdnuiLxWIJEQU"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.11.2
Cancel-Lock: sha1:8vAPaeB8xcg0r7Us+5uE7hL/5HI=
Content-Language: en-GB
In-Reply-To: <03f1626b-811e-467e-a691-50742d24bd97n@googlegroups.com>
 by: dxforth - Wed, 14 Jun 2023 08:38 UTC

On 14/06/2023 4:38 pm, minforth wrote:
> dxforth schrieb am Mittwoch, 14. Juni 2023 um 05:54:04 UTC+2:
>> On 13/06/2023 7:49 pm, minforth wrote:
>>> Anton Ertl schrieb am Dienstag, 13. Juni 2023 um 09:48:28 UTC+2:
>>>> Brian Fox <bria...@brianfox.ca> writes:
>>>>> On Monday, June 12, 2023 at 3:55:13=E2=80=AFPM UTC-4, gobli...@gmail.com wr=
>>>>> ote:
>>>>>
>>>>> gForth seems to have NUMBER? .
>>>> Not in the development version. As for S>NUMBER (mentioned also in
>>>> this thread), the source code says:
>>>>
>>>> \ don't use this, there is no way to tell success
>>>>
>>>> The current recommendation is
>>>>
>>>> 'rec-num' ( addr u -- n/d table | notfound ) gforth-experimental "rec-num"
>>>> converts a number to a single/double integer
>>>>
>>>> where table is the xt of TRANSLATE-NUM (and n below table) or
>>>> TRANSLATE-DNUM (and d below table); or the top of stack ist the xt of
>>>> NOTFOUND.
>>>>
>>>> I find the combination of single- and double-cell numbers in one
>>>> recognizer suboptimal as an interface, but it actally simplifies the
>>>> implemetation compared to a variant that has separate recognizers for
>>>> singles and doubles and only combines them at the recognizer level.
>>>
>>> I use a non-standard
>>> NUMBER? \ ( a u -- 0 | n 1 | d 2 ) convert to single or double number
>>> that handles prefixes, 'c' chars, and the classic dpl. So no surprises here.
>>> Okay for interpreting legacy code.
>> Some well-known forths use that as it suits the forth interpreter. OTOH
>> it's overkill for most apps and requires more handling. What's missing
>> is the intermediate function, similar to >FLOAT but for integer.
>
> That's besides the point (there is still >NUMBER). The point is whether
> recognizers like rec-num or rec-dnum should be part of a Forth kernel.
> I won't criticise gforth design decisions, but ISTM that _this_ is overkill
> as long as there are easier ways.

If ANS' >NUMBER is the reference then anything over becomes 'overkill'.
Early forths had NUMBER (as did Forth-79 in the Reference wordset).
ANS ignored it - perhaps due to lack of common practice. I'm getting
the sense >NUMBER is not enough. The opportunity and willingness to
determine what is has likely passed us by.

Re: get a number from system & convert it to an int into an array

<0a763f38-bc21-4486-a833-b55e668c0a87n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23845&group=comp.lang.forth#23845

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ad4:559b:0:b0:62d:e30c:10c with SMTP id f27-20020ad4559b000000b0062de30c010cmr1389504qvx.4.1686733815881;
Wed, 14 Jun 2023 02:10:15 -0700 (PDT)
X-Received: by 2002:a05:622a:19a6:b0:3f9:a751:1dac with SMTP id
u38-20020a05622a19a600b003f9a7511dacmr440256qtc.9.1686733815563; Wed, 14 Jun
2023 02:10:15 -0700 (PDT)
Path: i2pn2.org!i2pn.org!news.1d4.us!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Wed, 14 Jun 2023 02:10:15 -0700 (PDT)
In-Reply-To: <u6bu97$3vbcn$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=92.40.213.169; posting-account=9A5f7goAAAD_QfJPZnlK3Xq_UhzYjdP-
NNTP-Posting-Host: 92.40.213.169
References: <ce094d5f-a29f-4a1e-ad61-7e7d156f2e35n@googlegroups.com>
<nnd$1cf5bc01$55dfbbaf@efa2e9b0bbde3054> <2d9978b7-07c1-4210-a2c1-ed9e5cc2269an@googlegroups.com>
<3dbed30d-9c8f-4cff-a3df-0b12c9d45947n@googlegroups.com> <2023Jun13.093141@mips.complang.tuwien.ac.at>
<69902373-ed63-4082-9b3a-69e7e62261c0n@googlegroups.com> <u6bdko$3tmic$1@dont-email.me>
<03f1626b-811e-467e-a691-50742d24bd97n@googlegroups.com> <u6bu97$3vbcn$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <0a763f38-bc21-4486-a833-b55e668c0a87n@googlegroups.com>
Subject: Re: get a number from system & convert it to an int into an array
From: november...@gmail.com (NN)
Injection-Date: Wed, 14 Jun 2023 09:10:15 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 4199
 by: NN - Wed, 14 Jun 2023 09:10 UTC

On Wednesday, 14 June 2023 at 09:38:03 UTC+1, dxforth wrote:
> On 14/06/2023 4:38 pm, minforth wrote:
> > dxforth schrieb am Mittwoch, 14. Juni 2023 um 05:54:04 UTC+2:
> >> On 13/06/2023 7:49 pm, minforth wrote:
> >>> Anton Ertl schrieb am Dienstag, 13. Juni 2023 um 09:48:28 UTC+2:
> >>>> Brian Fox <bria...@brianfox.ca> writes:
> >>>>> On Monday, June 12, 2023 at 3:55:13=E2=80=AFPM UTC-4, gobli...@gmail.com wr=
> >>>>> ote:
> >>>>>
> >>>>> gForth seems to have NUMBER? .
> >>>> Not in the development version. As for S>NUMBER (mentioned also in
> >>>> this thread), the source code says:
> >>>>
> >>>> \ don't use this, there is no way to tell success
> >>>>
> >>>> The current recommendation is
> >>>>
> >>>> 'rec-num' ( addr u -- n/d table | notfound ) gforth-experimental "rec-num"
> >>>> converts a number to a single/double integer
> >>>>
> >>>> where table is the xt of TRANSLATE-NUM (and n below table) or
> >>>> TRANSLATE-DNUM (and d below table); or the top of stack ist the xt of
> >>>> NOTFOUND.
> >>>>
> >>>> I find the combination of single- and double-cell numbers in one
> >>>> recognizer suboptimal as an interface, but it actally simplifies the
> >>>> implemetation compared to a variant that has separate recognizers for
> >>>> singles and doubles and only combines them at the recognizer level.
> >>>
> >>> I use a non-standard
> >>> NUMBER? \ ( a u -- 0 | n 1 | d 2 ) convert to single or double number
> >>> that handles prefixes, 'c' chars, and the classic dpl. So no surprises here.
> >>> Okay for interpreting legacy code.
> >> Some well-known forths use that as it suits the forth interpreter. OTOH
> >> it's overkill for most apps and requires more handling. What's missing
> >> is the intermediate function, similar to >FLOAT but for integer.
> >
> > That's besides the point (there is still >NUMBER). The point is whether
> > recognizers like rec-num or rec-dnum should be part of a Forth kernel.
> > I won't criticise gforth design decisions, but ISTM that _this_ is overkill
> > as long as there are easier ways.
> If ANS' >NUMBER is the reference then anything over becomes 'overkill'.
> Early forths had NUMBER (as did Forth-79 in the Reference wordset).
> ANS ignored it - perhaps due to lack of common practice. I'm getting
> the sense >NUMBER is not enough. The opportunity and willingness to
> determine what is has likely passed us by.

The most important thing to realise is that >number is not meant to be the
final word but a stepping stone..

It applies to integers.

Its weakness is that if there is an overflow there is no signal to the caller.

Re: get a number from system & convert it to an int into an array

<nnd$6e1dc7b0$5570eb63@57a14590d9d22096>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23846&group=comp.lang.forth#23846

  copy link   Newsgroups: comp.lang.forth
Newsgroups: comp.lang.forth
References: <ce094d5f-a29f-4a1e-ad61-7e7d156f2e35n@googlegroups.com> <69902373-ed63-4082-9b3a-69e7e62261c0n@googlegroups.com> <u6bdko$3tmic$1@dont-email.me> <03f1626b-811e-467e-a691-50742d24bd97n@googlegroups.com>
Subject: Re: get a number from system & convert it to an int into an array
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
From: alb...@cherry (none)
Originator: albert@cherry.(none) (albert)
Message-ID: <nnd$6e1dc7b0$5570eb63@57a14590d9d22096>
Organization: KPN B.V.
Date: Wed, 14 Jun 2023 11:22:29 +0200
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!feeder1.feed.usenet.farm!feed.usenet.farm!peer01.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feed.abavia.com!abe004.abavia.com!abp002.abavia.com!news.kpn.nl!not-for-mail
Lines: 78
Injection-Date: Wed, 14 Jun 2023 11:22:29 +0200
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
X-Received-Bytes: 4502
 by: none - Wed, 14 Jun 2023 09:22 UTC

In article <03f1626b-811e-467e-a691-50742d24bd97n@googlegroups.com>,
minforth <minforth@arcor.de> wrote:
>dxforth schrieb am Mittwoch, 14. Juni 2023 um 05:54:04 UTC+2:
>> On 13/06/2023 7:49 pm, minforth wrote:
>> > Anton Ertl schrieb am Dienstag, 13. Juni 2023 um 09:48:28 UTC+2:
>> >> Brian Fox <bria...@brianfox.ca> writes:
>> >>> On Monday, June 12, 2023 at 3:55:13=E2=80=AFPM UTC-4,
>gobli...@gmail.com wr=
>> >>> ote:
>> >>>
>> >>> gForth seems to have NUMBER? .
>> >> Not in the development version. As for S>NUMBER (mentioned also in
>> >> this thread), the source code says:
>> >>
>> >> \ don't use this, there is no way to tell success
>> >>
>> >> The current recommendation is
>> >>
>> >> 'rec-num' ( addr u -- n/d table | notfound ) gforth-experimental "rec-num"
>> >> converts a number to a single/double integer
>> >>
>> >> where table is the xt of TRANSLATE-NUM (and n below table) or
>> >> TRANSLATE-DNUM (and d below table); or the top of stack ist the xt of
>> >> NOTFOUND.
>> >>
>> >> I find the combination of single- and double-cell numbers in one
>> >> recognizer suboptimal as an interface, but it actally simplifies the
>> >> implemetation compared to a variant that has separate recognizers for
>> >> singles and doubles and only combines them at the recognizer level.
>> >
>> > I use a non-standard
>> > NUMBER? \ ( a u -- 0 | n 1 | d 2 ) convert to single or double number
>> > that handles prefixes, 'c' chars, and the classic dpl. So no
>surprises here.
>> > Okay for interpreting legacy code.
>> Some well-known forths use that as it suits the forth interpreter. OTOH
>> it's overkill for most apps and requires more handling. What's missing
>> is the intermediate function, similar to >FLOAT but for integer.
>
>That's besides the point (there is still >NUMBER). The point is whether
>recognizers like rec-num or rec-dnum should be part of a Forth kernel.
>I won't criticise gforth design decisions, but ISTM that _this_ is overkill
>as long as there are easier ways.

I for me would regret that rec-num etc would be forced into the kernel,
and would be not in an optional wordset.
A similar case is the prefixes $ # etc. It refers to numbers and the
general view is that that cannot made optional.
In the design of ciforth I decided that I absolutely want the $ #
prefixes optional. The consequential changes to the interpreter are
minimal, allowing the prefixes to be more or less normal words.
For example you could have a linux wordlist where you redefine $
to mean "fetch the environment variable", and introduce 0x for
hexadecimal.

I explained prefixes before. If you understood them and are tired
of hearing it again, you can skip the remainder.
PREFIX is a property similar to IMMEDIATE and apply to the word just
completed.
A prefix is found in the dictionary, observing the current search
order, as soon as it matches the first part of a word.
Then the parse pointer is advanced by the
length of the word found, be it a prefix or regular word.

That's it. Numbers can be handled by prefixes -+0..9 .
They find the number to be converted in the input stream however,
not as the string passed to INTERPRET.
They are to be made IMMEDIATE to be used in definitions, as usual.
The $ prefix can be added later, or not at all.
A " prefix for strings is easy, and can be added modularly as well.

Groetjes Albert
--
Don't praise the day before the evening. One swallow doesn't make spring.
You must not say "hey" before you have crossed the bridge. Don't sell the
hide of the bear until you shot it. Better one bird in the hand than ten in
the air. First gain is a cat spinning. - the Wise from Antrim -

Re: get a number from system & convert it to an int into an array

<nnd$789b6ef7$5bff0587@e1997fe0452a1706>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23849&group=comp.lang.forth#23849

  copy link   Newsgroups: comp.lang.forth
Newsgroups: comp.lang.forth
References: <ce094d5f-a29f-4a1e-ad61-7e7d156f2e35n@googlegroups.com> <03f1626b-811e-467e-a691-50742d24bd97n@googlegroups.com> <u6bu97$3vbcn$1@dont-email.me> <0a763f38-bc21-4486-a833-b55e668c0a87n@googlegroups.com>
Subject: Re: get a number from system & convert it to an int into an array
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
From: alb...@cherry (none)
Originator: albert@cherry.(none) (albert)
Message-ID: <nnd$789b6ef7$5bff0587@e1997fe0452a1706>
Organization: KPN B.V.
Date: Wed, 14 Jun 2023 11:56:53 +0200
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!feeder1.feed.usenet.farm!feed.usenet.farm!peer01.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feed.abavia.com!abe004.abavia.com!abp003.abavia.com!news.kpn.nl!not-for-mail
Lines: 44
Injection-Date: Wed, 14 Jun 2023 11:56:53 +0200
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
X-Received-Bytes: 2462
 by: none - Wed, 14 Jun 2023 09:56 UTC

In article <0a763f38-bc21-4486-a833-b55e668c0a87n@googlegroups.com>,
NN <november.nihal@gmail.com> wrote:
<SNIP>
>
>
>The most important thing to realise is that >number is not meant to be the
>final word but a stepping stone..
>
>It applies to integers.
>
>Its weakness is that if there is an overflow there is no signal to the caller.

On the contrary, it has all options open. However you have to add overflow.
It is a "Swiss army knife" (or egg vending machine).

The word >NUMBER used as a stepping stone suggest that it should be
used internally. Don't fall for the temptation. Forcing a Forth to use
this "switch army knife" result in a cumbersome Forth implementation.

Come to think of this. >NUMBER is in the ciforth kernel and it is never
used there. It wastes a whopping 300 bytes there and it is one of the
5 most complicated definitions in my whole Forth, making it look worse
than it should be.
>NUMBER should a loadable extension. A typical example where it is used
in is a lisp interpreter.
In normal situation it is rare. E.g. in my 400+ solutions of euler
problems, it came up once.
That was euler 13:
"
Work out the first ten digits of the sum of the following one-hundred
50-digit numbers.
37107287533902102798797998220837590246510135740250
..
"
You can see how that is appropriate.
Groetjes Albert.

>
--
Don't praise the day before the evening. One swallow doesn't make spring.
You must not say "hey" before you have crossed the bridge. Don't sell the
hide of the bear until you shot it. Better one bird in the hand than ten in
the air. First gain is a cat spinning. - the Wise from Antrim -

Re: get a number from system & convert it to an int into an array

<u6c682$d3d$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23851&group=comp.lang.forth#23851

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: get a number from system & convert it to an int into an array
Date: Wed, 14 Jun 2023 20:53:55 +1000
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <u6c682$d3d$1@dont-email.me>
References: <ce094d5f-a29f-4a1e-ad61-7e7d156f2e35n@googlegroups.com>
<03f1626b-811e-467e-a691-50742d24bd97n@googlegroups.com>
<u6bu97$3vbcn$1@dont-email.me>
<0a763f38-bc21-4486-a833-b55e668c0a87n@googlegroups.com>
<nnd$789b6ef7$5bff0587@e1997fe0452a1706>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 14 Jun 2023 10:53:55 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="825fe1a4e099e12f27daf52d537d5d93";
logging-data="13421"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+lxYzrzCriQcwWLFaa/Zf5"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.11.2
Cancel-Lock: sha1:ESSuuRuhyIP6c4g6TYBjdxWVgsY=
Content-Language: en-GB
In-Reply-To: <nnd$789b6ef7$5bff0587@e1997fe0452a1706>
 by: dxforth - Wed, 14 Jun 2023 10:53 UTC

On 14/06/2023 7:56 pm, albert wrote:
> In article <0a763f38-bc21-4486-a833-b55e668c0a87n@googlegroups.com>,
> NN <november.nihal@gmail.com> wrote:
> <SNIP>
>>
>>
>> The most important thing to realise is that >number is not meant to be the
>> final word but a stepping stone..
>>
>> It applies to integers.
>>
>> Its weakness is that if there is an overflow there is no signal to the caller.
>
> On the contrary, it has all options open. However you have to add overflow.
> It is a "Swiss army knife" (or egg vending machine).
>
> The word >NUMBER used as a stepping stone suggest that it should be
> used internally. Don't fall for the temptation. Forcing a Forth to use
> this "switch army knife" result in a cumbersome Forth implementation.

No one is forced to use it. That 99% or more of forths have suggests
it's adequate. There's no overflow protection but IIRC neither has C .


devel / comp.lang.forth / get a number from system & convert it to an int into an array

Pages:12
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor