Sysop: | Amessyroom |
---|---|
Location: | Fayetteville, NC |
Users: | 28 |
Nodes: | 6 (0 / 6) |
Uptime: | 47:51:02 |
Calls: | 422 |
Files: | 1,024 |
Messages: | 90,420 |
Note: this isn't Python or PHP like "easy to use" - where the magician
hides the rabbit behind his back. The effect is perfectly predictable -
and quite intuitive (if I may say so myself).
Note in C, printf() isn't capable of redirection (unless from OS level). >fprintf() is - but how many people use it in combination with stdout
(present company excepted)?
Hans Bezemer
In article <nnd$68843db9$0f3297b6@f356aed0e515fe8b>,
The integration with the OS-es makes for useful applications. ~/PROJECT/ciforths/ciforth/TOOLS/ALLOCATE: cat printhex.frt
: doit 1 ARG[] EVALUATE HEX . ;
~/PROJECT/ciforths/ciforth/TOOLS/ALLOCATE: printhex 1024;echo
400
[lina -c printhex.frt]
SCRIPTFILE-NAME DUMP-TO-FILE
Mime-Version: 1.0
User-Agent: Rocksolid Light
Path: not-for-mail
From: mhx@iae.nl (mhx)
Newsgroups: comp.lang.forth
Organization: novaBBS
Injection-Info: i2pn2.org; logging-data="921598"; mail-complaints-to="usenet@i2pn2.org"; posting-account="J+nubxJRM7ncpF4l6KLO+OONWmFAYJHVJegfwQXJ8vc";
Subject: Re: Back & Forth - 4tH I/O and You
References: <nnd$306ecdcd$714b9ebb@8c19de68479dc08d> <b2a4690cc4cdcb9e39310166d37070ab2a16d8b2@i2pn2.org> <nnd$68843db9$0f3297b6@f356aed0e515fe8b> <nnd$0346461b$62171617@be8ddde8960df4cb>
Content-Transfer-Encoding: 8bit
X-Rslight-Site: $2y$10$OOQsNDELF5uNo3A3Uv7gJOwfOwKYrncFKKKX4OxnyyB9YDRoHEGxG >X-Rslight-Posting-User: 4e0dc1fdad1ead10b39e7eb5db19bf73d73e3ab3
Date: Sun, 18 May 2025 19:10:34 +0000
Message-Id: <fce9942b8d6e52702b330d5edcde5b4f@www.novabbs.com>
Content-Type: text/plain; charset=utf-8; format=flowed >X-Spam-Checker-Version: SpamAssassin 4.0.0
On Sun, 18 May 2025 18:55:27 +0000, albert@spenarnc.xs4all.nl wrote:
In article <nnd$68843db9$0f3297b6@f356aed0e515fe8b>,
The integration with the OS-es makes for useful applications.
~/PROJECT/ciforths/ciforth/TOOLS/ALLOCATE: cat printhex.frt
: doit 1 ARG[] EVALUATE HEX . ;
~/PROJECT/ciforths/ciforth/TOOLS/ALLOCATE: printhex 1024;echo
400
[lina -c printhex.frt]
In iForth we can redirect to a string:
: ngspice-POSTLUDE ( -- c-addr u )
DRY-RUN ( using TASK-DATA setup by SP>NGSPICE )
|head .paramdata LOCAL mem
<$$ ." * Generated by iSPICE on " .TIME$ ." -- do not edit"
CR
CR ." .control"
CR ." unset ltspice"
CR ." unset dotstep"
CR ." set numthreads=1
CR ." set ispice = " #|params 0<> 1 AND .
CR ." "
." let spiceidx = $SPICEIDX ; "
." let ntasks=" #|tasks ."#"
." let ncpus=" #|cpus ."#"
." let nparams=" #|params ."#"
." let nresults=" #|results ."#"
#|params
IF CR ." compose p values "
#|tasks 0 ?DO CR ." + "
#|params 0 ?DO mem DF@+ TO mem
F.N2+_
LOOP
LOOP
CR #|params 1 > IF ." reshape p[" #|tasks
0DEC.R ." ][" #|params
0DEC.R ." ]"
ENDIF
ENDIF
CR ." let ignore = 0"
CR ." let buf = 0"
CR ." let done = 0"
CR ." let ix = spiceidx"
CR ." compose arg values " #|tasks #|results * .
#|results 0DEC.R ." ix 0 0.0"
CR ." compose status values ncpus spiceidx"
CR ." dowhile ix < ntasks"
#|params 0 ?DO CR #|params 1 > IF ." let buf = p[ix][" I
0DEC.R ." ]"
ELSE ." let buf = p[ix]"
ENDIF
CR ." alterparam " |head .pnames I CSTR[] .$
." = $&buf"
LOOP
#|params IF CR ." mc_source" ENDIF
CR ." " $SIM @+ 1 /STRING TYPE
#|results 0 ?DO CR ." let arg[3] = " I ."#"
CR ." " I (meashead) TYPE
." arg[4] " I (measbody) TYPE
CR ." let ignore=setresult(arg) "
LOOP
CR ." let ix = ix + ncpus"
CR ." let arg[2] = ix"
CR ." write " RAWDATA-NAME
NO-EXTENSION
S" _{$spiceidx}{.raw}"
$+ TYPE
#|tasks IF CR ." set appendwrite" ENDIF
CR ." end"
CR ." let done = setfinish(status)"
CR ." quit"
CR ." .endc"
$$>
SCRIPTFILE-NAME DUMP-TO-FILE
CR ." Please manually add the following lines to `" cktfile .$ ." .sp`"
CR
CR ." .LIBRARY basic.lib basicstuff"
CR ." .OPTION savecurrents"
CR ." .INC " cktfile .$ ." .iscript"
CR ; PRIVATE
( This mixes Forth with the SPICE shell script language )
Result:
* Generated by iSPICE on 23:19:11, December 9, 2024 -- do not edit
control
unset ltspice
unset dotstep
set numthreads=1 $ make sure spinit has this too; we can't overrule
spinit!
set ispice = 0
let spiceidx = $SPICEIDX ; let ntasks=1; let ncpus=8;
let nparams=0; let nresults=2;
let ignore = 0
let buf = 0
let done = 0
let ix = spiceidx
compose arg values 2 2 ix 0 0.0
compose status values ncpus spiceidx
dowhile ix < ntasks
TRAN 30u 30ms 0 30u
let arg[3] = 0;
meas tran arg[4] AVG @i1[current]
let ignore=setresult(arg)
let arg[3] = 1;
meas tran arg[4] AVG @i2[current]
let ignore=setresult(arg)
let ix = ix + ncpus
let arg[2] = ix
write f:/2jsource_test_{$spiceidx}{.raw}
set appendwrite
end
let done = setfinish(status)
quit
endc
-marcel--
In article <fce9942b8d6e52702b330d5edcde5b4f@www.novabbs.com>,[..]
mhx <mhx@iae.nl> wrote:
That doesn't convince I could do this myself.