Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

A person with one watch knows what time it is; a person with two watches is never sure. Proverb


devel / comp.lang.forth / Re: 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
Re: get a number from system & convert it to an int into an array

<d6a9470d-db9d-4d92-b509-7ed45d6d94f7n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a37:6584:0:b0:762:141:62e5 with SMTP id z126-20020a376584000000b00762014162e5mr266429qkb.15.1686740168509;
Wed, 14 Jun 2023 03:56:08 -0700 (PDT)
X-Received: by 2002:a05:620a:6a06:b0:75d:51f8:8e26 with SMTP id
uc6-20020a05620a6a0600b0075d51f88e26mr293011qkn.0.1686740168288; Wed, 14 Jun
2023 03:56:08 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer03.ams1!peer.ams1.xlned.com!news.xlned.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 03:56:07 -0700 (PDT)
In-Reply-To: <nnd$789b6ef7$5bff0587@e1997fe0452a1706>
Injection-Info: google-groups.googlegroups.com; posting-host=2a01:e0a:118:ea0:e23f:49ff:fed4:3289;
posting-account=3HjpJwoAAACwXD1UyRZwC1Lkp4Lq1jcg
NNTP-Posting-Host: 2a01:e0a:118:ea0:e23f:49ff:fed4:3289
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>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d6a9470d-db9d-4d92-b509-7ed45d6d94f7n@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: Wed, 14 Jun 2023 10:56:08 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 5538
 by: gobli...@gmail.com - Wed, 14 Jun 2023 10:56 UTC

Le mercredi 14 juin 2023 à 11:56:57 UTC+2, none albert a écrit :
> In article <0a763f38-bc21-4486...@googlegroups.com>,
> NN <novembe...@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 -

in fact >number or >float & so on words works on natural strings build from any s" mystring" and variables affectation from there

this is why I had to use & adapt a commandout word specifically

Question about open-pipe is just a GFORTH word included in gforth dictonnary

Code open-pipe
0x000055d2e6c5b564 <gforth_engine+10020>: mov %rbp,0x5b3dd(%rip) # 0x55d2e6cb6948 <saved_ip>
0x000055d2e6c5b56b <gforth_engine+10027>: mov (%r15),%rdx
0x000055d2e6c5b56e <gforth_engine+10030>: mov 0x8(%r15),%rsi
0x000055d2e6c5b572 <gforth_engine+10034>: lea 0x1a9a7(%rip),%rax # 0x55d2e6c75f20 <pfileattr>
0x000055d2e6c5b579 <gforth_engine+10041>: lea 0x8(%r15),%r13
0x000055d2e6c5b57d <gforth_engine+10045>: mov 0x10(%r15),%rdi
0x000055d2e6c5b581 <gforth_engine+10049>: mov (%rax,%rdx,8),%r14
0x000055d2e6c5b585 <gforth_engine+10053>: mov $0x1,%edx
0x000055d2e6c5b58a <gforth_engine+10058>: call 0x55d2e6c67970 <cstr>
0x000055d2e6c5b58f <gforth_engine+10063>: mov %rax,%rdi
0x000055d2e6c5b592 <gforth_engine+10066>: mov %r14,%rsi
0x000055d2e6c5b595 <gforth_engine+10069>: call 0x55d2e6c585e0 <popen@plt>
0x000055d2e6c5b59a <gforth_engine+10074>: mov %rax,%r14
0x000055d2e6c5b59d <gforth_engine+10077>: test %rax,%rax
0x000055d2e6c5b5a0 <gforth_engine+10080>: je 0x55d2e6c5d538 <gforth_engine+18168>
0x000055d2e6c5b5a6 <gforth_engine+10086>: xor %eax,%eax
0x000055d2e6c5b5a8 <gforth_engine+10088>: mov %r14,0x8(%r13)
0x000055d2e6c5b5ac <gforth_engine+10092>: add $0x8,%rbp
0x000055d2e6c5b5b0 <gforth_engine+10096>: mov %r13,%r15
0x000055d2e6c5b5b3 <gforth_engine+10099>: mov %rax,0x0(%r13)
0x000055d2e6c5b5b7 <gforth_engine+10103>: mov -0x8(%rbp),%rcx
0x000055d2e6c5b5bb <gforth_engine+10107>: jmp *%rcx
Warning: 'set logging off', an alias for the command 'set logging enabled', is deprecated.
Use 'set logging enabled off'.

end-code
ok

it doen't come from external

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

<u6doec$5coi$1@dont-email.me>

  copy mid

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

  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: Thu, 15 Jun 2023 11:10:37 +1000
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <u6doec$5coi$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>
<d6a9470d-db9d-4d92-b509-7ed45d6d94f7n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 15 Jun 2023 01:10:36 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c1466b19a5468d2fa56e71b1799550e9";
logging-data="176914"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18UZc8wNDfhQ9mFLj1B4FPx"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.11.2
Cancel-Lock: sha1:L8xu688xEAeff4uYP+3Q8qr/VTs=
In-Reply-To: <d6a9470d-db9d-4d92-b509-7ed45d6d94f7n@googlegroups.com>
Content-Language: en-GB
 by: dxforth - Thu, 15 Jun 2023 01:10 UTC

On 14/06/2023 8:56 pm, gobli...@gmail.com wrote:
> ...
> in fact >number or >float & so on words works on natural strings build from any s" mystring" and variables affectation from there

True. If ciForth hasn't used >NUMBER it's because it's converter is customised for,
and relies upon, the forth interpreter. This puts it in the same class as recognizers
in which different interpreters must be switched in to handle different types of numbers.
>NUMBER is a general-purpose factor that can be used independently of the forth
interpreter.

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

<5da46cc1-5400-419b-b80d-81bbb4002917n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:6214:1624:b0:62f:f485:2302 with SMTP id e4-20020a056214162400b0062ff4852302mr37074qvw.5.1686816627041;
Thu, 15 Jun 2023 01:10:27 -0700 (PDT)
X-Received: by 2002:ac8:5a8b:0:b0:3f6:aaac:6fe4 with SMTP id
c11-20020ac85a8b000000b003f6aaac6fe4mr1521675qtc.4.1686816626840; Thu, 15 Jun
2023 01:10:26 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!newsfeed.hasname.com!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: Thu, 15 Jun 2023 01:10:26 -0700 (PDT)
In-Reply-To: <ce094d5f-a29f-4a1e-ad61-7e7d156f2e35n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2a01:e0a:118:ea0:e23f:49ff:fed4:3289;
posting-account=3HjpJwoAAACwXD1UyRZwC1Lkp4Lq1jcg
NNTP-Posting-Host: 2a01:e0a:118:ea0:e23f:49ff:fed4:3289
References: <ce094d5f-a29f-4a1e-ad61-7e7d156f2e35n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <5da46cc1-5400-419b-b80d-81bbb4002917n@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: Thu, 15 Jun 2023 08:10:27 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 4054
 by: gobli...@gmail.com - Thu, 15 Jun 2023 08:10 UTC

Le lundi 12 juin 2023 à 21:36:46 UTC+2, gobli...@gmail.com a écrit :
> 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

Hello,
thanks all for our advices
for now as a quite good solution for now

\ use case test / ideas / and fix
\ help from reddit :; community
create buffer 1024 allot \ for general purpose usage redefined buffer
2variable out \ general purpose output changed to 2variable ; idea from Armok628 on redit
variable var \ just for poc
: commandout ( "system" -- string )
r/o open-pipe throw dup buffer swap 256 swap read-file throw swap close-pipe throw drop buffer swap out 2!
; \ system capture

\ random example to get a value
s" psql -c 'select avg(prct)*100 from jx ;' | sed '3!d' " commandout

\ use delimiter
: DELIMITED ( addr len char -- addr len)
>R 2DUP R> SCAN NIP - \ good idea from bfox9900 reddit
;

: test
dup \ for tailing spaces count
." ["
0 DO ." #" loop
100 swap - 0 do 32 emit loop
." ]"
cr
;

page
out 2@ char . deliMITED evaluate cr test cr
bye

With this delimited word, then it can evaluate correctly to send the entire part of the numeric value captured as a string at first.

test word here is just as his name indicate a test to confirm it has been converted correctly :)
here displaying some sort of bargraph

[############################################### ]

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

<a1fe227e-fd97-447c-b739-47cf4b0cf839n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:5a85:0:b0:3df:bda6:6931 with SMTP id c5-20020ac85a85000000b003dfbda66931mr1683355qtc.2.1686842165166;
Thu, 15 Jun 2023 08:16:05 -0700 (PDT)
X-Received: by 2002:a05:6214:4c19:b0:62d:e61a:ed9b with SMTP id
qh25-20020a0562144c1900b0062de61aed9bmr1527242qvb.3.1686842165005; Thu, 15
Jun 2023 08:16:05 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border-2.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: Thu, 15 Jun 2023 08:16:04 -0700 (PDT)
In-Reply-To: <5da46cc1-5400-419b-b80d-81bbb4002917n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=162.253.129.167; posting-account=2z7GawoAAADc70p5SM5AbaCyzjLblS3g
NNTP-Posting-Host: 162.253.129.167
References: <ce094d5f-a29f-4a1e-ad61-7e7d156f2e35n@googlegroups.com> <5da46cc1-5400-419b-b80d-81bbb4002917n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a1fe227e-fd97-447c-b739-47cf4b0cf839n@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: Thu, 15 Jun 2023 15:16:05 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 15
 by: Brian Fox - Thu, 15 Jun 2023 15:16 UTC

On Thursday, June 15, 2023 at 4:10:30 AM UTC-4, gobli...@gmail.com wrote:

I might as well chime in here too. :-)

Forth has a standard word called SPACES so you can make this simpler.

: test
dup \ for tailing spaces count
.." ["
0 DO ." #" loop
100 swap - SPACES
.." ]"
cr
;

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

<9899e0f1-2c26-49e3-b999-90b2e05bf4b4n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:584c:0:b0:3ee:be98:9fcf with SMTP id h12-20020ac8584c000000b003eebe989fcfmr138245qth.0.1686860187380;
Thu, 15 Jun 2023 13:16:27 -0700 (PDT)
X-Received: by 2002:a37:b481:0:b0:762:224a:6120 with SMTP id
d123-20020a37b481000000b00762224a6120mr223588qkf.12.1686860187161; Thu, 15
Jun 2023 13:16:27 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!feeder.erje.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.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: Thu, 15 Jun 2023 13:16:26 -0700 (PDT)
In-Reply-To: <a1fe227e-fd97-447c-b739-47cf4b0cf839n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2a01:e0a:118:ea0:e23f:49ff:fed4:3289;
posting-account=3HjpJwoAAACwXD1UyRZwC1Lkp4Lq1jcg
NNTP-Posting-Host: 2a01:e0a:118:ea0:e23f:49ff:fed4:3289
References: <ce094d5f-a29f-4a1e-ad61-7e7d156f2e35n@googlegroups.com>
<5da46cc1-5400-419b-b80d-81bbb4002917n@googlegroups.com> <a1fe227e-fd97-447c-b739-47cf4b0cf839n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <9899e0f1-2c26-49e3-b999-90b2e05bf4b4n@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: Thu, 15 Jun 2023 20:16:27 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 1818
 by: gobli...@gmail.com - Thu, 15 Jun 2023 20:16 UTC

Le jeudi 15 juin 2023 à 17:16:08 UTC+2, Brian Fox a écrit :
> On Thursday, June 15, 2023 at 4:10:30 AM UTC-4, gobli...@gmail.com wrote:
>
> I might as well chime in here too. :-)
>
> Forth has a standard word called SPACES so you can make this simpler.
> : test
> dup \ for tailing spaces count
> ." ["
> 0 DO ." #" loop
> 100 swap - SPACES
> ." ]"
> cr
> ;

you're right :)


devel / comp.lang.forth / Re: 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