refdes_renum: warn of possible number clash with non-conforming values
[geda-gaf/whiteaudio.git] / docs / wiki / geda-hse_howto.html
blob2e0e0768dd4c9ecf10960991a3dd79a355dc40ef
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html>
4 <head>
5 <title></title>
6 <link rel="stylesheet" media="screen" type="text/css" href="./style.css" />
7 <link rel="stylesheet" media="screen" type="text/css" href="./design.css" />
8 <link rel="stylesheet" media="print" type="text/css" href="./print.css" />
10 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
11 </head>
12 <body>
15 <h1 class="sectionedit302"><a name="hooks_scheme_extension_howto" id="hooks_scheme_extension_howto">Hooks/Scheme Extension HOWTO</a></h1>
16 <div class="level1">
17 <pre class="code">gEDA - GPL Electronic Design Automation
19 HOOKS AND SCHEME EXTENSION IN GSCHEM
20 ====================================
22 Copyright (C) 2000 Stefan Petersen
24 This program is free software; you can redistribute it and/or modify
25 it under the terms of the GNU General Public License as published by
26 the Free Software Foundation; either version 2 of the License, or
27 (at your option) any later version.
29 This program is distributed in the hope that it will be useful,
30 but WITHOUT ANY WARRANTY; without even the implied warranty of
31 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 GNU General Public License for more details.
34 You should have received a copy of the GNU General Public License
35 along with this program; if not, write to the Free Software
36 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
39 Introduction
40 ------------
41 gschem has a scheme interpreter (called Guile) built in. Though not
42 complete, there are extensions to this interpreter to get access to
43 different parts of the schematic.
45 There are a couple of other scheme extensions available that will not be
46 described here. They belong mainly to rc-files (resource files in
47 gEDA programs are really scheme scripts) and to the keymapping system
48 (described in separate keymapping documentation).
50 The rest I will try to describe here.
53 Scheme functions
54 ----------------
55 There are two function available for handling attributes in the schematic.
57 * get-attribute-name-value
58 Inparameter : an attribute
59 Outparameter : a pair with the name of the attribute as string in the
60 car element and the value of the attribute in the cdr
61 element.
62 Description : Simply an accessor to the information hidden in the type
63 attribute. The functionality of this is placed in libgeda
64 since the C-type ATTRIBUTE is defined there.
66 * set-attribute-value!
67 Inparameter : an attribute and a string.
68 Outparameter : undefined.
69 Description : Sets a new value to an attribute. The attribute must
70 be defined, the function can&#039;t create a new attribute.
71 Defined both in gschem and libgeda, mainly because
72 where different variables and information are available.
75 Hooks
76 -----
77 Hooks are a way to define functions that will be called during different
78 part of a programs execution. In gschem there are (currently) three
79 different hooks available:
80 * add-component-hook
81 * copy-component-hook
82 * move-component-hook
84 As their name indicate, they are called at different occasions. When
85 you add a component add-component-hook is called, etc.
87 To add a function to be called you simply use the Guile funtion add-hook!.
88 An example; to run the function auto-uref when you add a component you
89 simply add the following line, preferrably in ${HOME}/.gEDA/gschemrc:
90 (add-hook! add-component-hook auto-uref)
92 The function to be called from a hook (for example auto-uref above) has
93 to accept one parameter, a list of attributes.
95 A small example that prints all attributes on a component to be placed:
97 (define (print-all-attributes attribute-list)
98 (foreach (lambda (attribute) (display attribute)) attribute-list))
101 How to use this
102 ---------------
103 The most complete example utilizing all of the above functions are in fact
104 the auto-uref scheme script that currently is part of the gschem distribution.
105 You can find it &lt;where gschem is installed&gt;/share/gEDA/scheme/auto-uref.scm.
106 Uninstalled it&#039;s available at gschem/scheme/auto-uref.scm
108 All components have a reference designator that must be unique so
109 gnetlist can handle it properly. By automatically assigning a number
110 to each instance of a component when you place and copy it, you can
111 simplify the naming operation.
113 All components has, per default, an uref attribute, for example uref=R?.
114 The letter varies with component type. The auto-uref script enumerates
115 uref based on what prefix the component has and assigns a number.
117 For example, the first component you place has per default uref=U? gets
118 the attribute uref=U1. Next component with uref=U? gets uref=U2 and so on.
120 To be able to use the auto-uref script you simply add two lines in
121 ${HOME}/.gEDA/gschemrc. They are:
122 (load &quot;&lt;where gschem is installed&gt;/share/gEDA/scheme/auto-uref.scm&quot;)
123 (add-hook! add-component-hook auto-uref)
125 If you want auto enumeration to work when you copy the component too, you
126 simply add the following line:
127 (add-hook! copy-component-hook auto-uref)
129 Good luck!
130 </pre>
132 </div>
133 </body>
134 </html>