X-Authentication-Warning: delorie.com: mail set sender to geda-user-bounces using -f X-Recipient: geda-user AT delorie DOT com X-Virus-Scanned: Debian amavisd-new at mail.linetec.nl Content-Type: multipart/alternative; boundary="------------n0Pv2sEUpvHw80NrDlmogd0A" Message-ID: Date: Wed, 1 May 2024 21:56:44 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [geda-user] Gschem refdes autonumber over multiple pages? To: geda-user AT delorie DOT com References: <37de350c-1e5f-422f-b13a-c5a9a1e132ac AT linetec DOT nl> <20240429130455 DOT F01EF81AB8C5 AT turkos DOT aspodata DOT se> <20240430103043 DOT 32de22ff AT queeg DOT menasians DOT com> <20240430211916 DOT A6DBC81AB8C5 AT turkos DOT aspodata DOT se> <25416a96-c328-4b7e-8fa8-091c993205bd AT linetec DOT nl> <87sez18q32 DOT fsf AT gmail DOT com> <87o79p8jcu DOT fsf AT gmail DOT com> From: "Richard Rasker (rasker AT linetec DOT nl) [via geda-user AT delorie DOT com]" Content-Language: nl-NL, en-US In-Reply-To: <87o79p8jcu.fsf@gmail.com> Reply-To: geda-user AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: geda-user AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk This is a multi-part message in MIME format. --------------n0Pv2sEUpvHw80NrDlmogd0A Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hello Vladimir, Op 01-05-2024 om 20:28 schreef Vladimir Zhbanov (vzhbanov AT gmail DOT com) [via geda-user AT delorie DOT com]: > Hi Richard, > > "Richard Rasker (rasker AT linetec DOT nl) [viageda-user AT delorie DOT com]" writes: > > ... >>> It processes components of all open pages and outputs the >>> result as is defined at the bottom of the script. You can load it from >>> GUI. >> Maybe a stupid question, but how do I do this? I use geda-gschem, >> but the only reference to executing a script that I can find in >> gschem is Tools -> Execute Guile Script, but I don't think that >> this is what you mean. And if I choose this option and select your >> script(*), nothing happens. I also have no idea what scripting >> language this is -- I'm only familiar with bash. >> >> *: Yes, I did 1) already replace 'lepton' with 'geda' throughout, >> 2) make it executable, and 3) make sure it's in $PATH. > It is not necessary to do (2) and (3). In lepton-schematic menu the > item for this is File->Execute Script (or just hit 'F T'). Select the > script in the file selection dialog and press the Run button. That's > all. Ah, so I had the right menu item all :-) > The output will go to the terminal the program is launched from. Yes, this works, great!Although right now it just outputs a list of numbers, and I haven't found out how to add something like Rfree= to the number for the R prefix. > If you want to see its output, say, in the log window (e.g. in case you > don't use any terminal for launching the GUI), you'll have to replace > the "(display ...)" commands with something like > (log! 'message "Counter for R is ~A\n" (lookup-counter-by-prefix "R")) Hm, that doesn't seem to work yet. Here's what happens in gschem's Status Dock: Executing guile script [/home/richard/scripts/refdes-counter.scm] Tracing:            6 (apply-smob/1 #)            5 (apply-smob/1 #) In ice-9/eval.scm:    202:27  4 (_ #f)    223:20  3 (proc #) In unknown file:            2 (%resolve-variable (7 . log!) #) In ice-9/boot-9.scm:    751:25  1 (dispatch-exception 0 unbound-variable (#f "Unbound …" …)) In unknown file:            0 (apply-smob/1 # # #f "Unbo…" …) ERROR: In procedure apply-smob/1: Unbound variable: log! So from the Guile Reference I assume that I need to define log!, is that correct? However, (define (log!) (log! 'message "R = ~A\n" (lookup-counter-by-prefix "R"))) doesn't throw errors any more, but it doesn't do anything either, except show the message 'executing guile script ...'. So I guess I'll need to take a closer look at Guile here. But this is already very close to what I had in mind, thanks! Richard --------------n0Pv2sEUpvHw80NrDlmogd0A Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

Hello Vladimir,

Op 01-05-2024 om 20:28 schreef Vladimir Zhbanov (vzhbanov AT gmail DOT com) [via geda-user AT delorie DOT com]:
Hi Richard,

"Richard Rasker (rasker AT linetec DOT nl) [via geda-user AT delorie DOT com]" <geda-user AT delorie DOT com> writes:

...
It processes components of all open pages and outputs the
result as is defined at the bottom of the script.  You can load it from
GUI.
Maybe a stupid question, but how do I do this? I use geda-gschem,
but the only reference to executing a script that I can find in
gschem is Tools -> Execute Guile Script, but I don't think that
this is what you mean. And if I choose this option and select your
script(*), nothing happens. I also have no idea what scripting
language this is -- I'm only familiar with bash.

*: Yes, I did 1) already replace 'lepton' with 'geda' throughout,
 2) make it executable, and 3) make sure it's in $PATH.
It is not necessary to do (2) and (3).  In lepton-schematic menu the
item for this is File->Execute Script (or just hit 'F T').  Select the
script in the file selection dialog and press the Run button.  That's
all.

Ah, so I had the right menu item all :-)

  The output will go to the terminal the program is launched from.

Yes, this works, great! Although right now it just outputs a list of numbers, and I haven't found out how to add something like Rfree= to the number for the R prefix.

If you want to see its output, say, in the log window (e.g. in case you
don't use any terminal for launching the GUI), you'll have to replace
the "(display ...)" commands with something like
  (log! 'message "Counter for R is ~A\n" (lookup-counter-by-prefix "R"))

Hm, that doesn't seem to work yet. Here's what happens in gschem's Status Dock:

Executing guile script [/home/richard/scripts/refdes-counter.scm]

Tracing:
           6 (apply-smob/1 #<catch-closure 564014dc1220>)
           5 (apply-smob/1 #<catch-closure 56401672f6a0>)
In ice-9/eval.scm:
   202:27  4 (_ #f)
   223:20  3 (proc #<directory (guile-user) 564014e55140>)
In unknown file:
           2 (%resolve-variable (7 . log!) #<directory (guile-user) …>)
In ice-9/boot-9.scm:
   751:25  1 (dispatch-exception 0 unbound-variable (#f "Unbound …" …))
In unknown file:
           0 (apply-smob/1 #<catch-closure 56401672f660> # #f "Unbo…" …)

ERROR: In procedure apply-smob/1:
Unbound variable: log!

So from the Guile Reference I assume that I need to define log!, is that correct?

However,

(define (log!)
(log! 'message "R = ~A\n" (lookup-counter-by-prefix "R")))

doesn't throw errors any more, but it doesn't do anything either, except show the message 'executing guile script ...'.

So I guess I'll need to take a closer look at Guile here.

But this is already very close to what I had in mind, thanks!

Richard

--------------n0Pv2sEUpvHw80NrDlmogd0A--