Downloaded and integrated latest wiki documentation from the geda website.
[geda-gaf/peter-b.git] / docs / wiki / geda_hse_howto.html
blob4138f617e3509a72185484b8f6cd8a242cc07870
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
4 lang="en" dir="ltr">
5 <head>
6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
7 <title>geda:hse_howto</title>
8 <meta name="generator" content="DokuWiki Release rc2007-05-24" />
9 <meta name="robots" content="index,follow" />
10 <meta name="date" content="2007-05-24T22:27:25-0400" />
11 <meta name="keywords" content="geda,hse_howto" />
12 <link rel="search" type="application/opensearchdescription+xml" href="http://geda.seul.org/wiki/lib/exe/opensearch.php" title="geda Wiki" />
13 <link rel="start" href="http://geda.seul.org/wiki/" />
14 <link rel="contents" href="http://geda.seul.org/wiki/geda:hse_howto?do=index" title="Index" />
15 <link rel="alternate" type="application/rss+xml" title="Recent Changes" href="http://geda.seul.org/wiki/feed.php" />
16 <link rel="alternate" type="application/rss+xml" title="Current Namespace" href="http://geda.seul.org/wiki/feed.php?mode=list&ns=geda" />
17 <link rel="alternate" type="text/html" title="Plain HTML" href="http://geda.seul.org/wiki/_export/xhtml/geda:hse_howto" />
18 <link rel="alternate" type="text/plain" title="Wiki Markup" href="http://geda.seul.org/wiki/_export/raw/geda:hse_howto" />
19 <link rel="stylesheet" media="all" type="text/css" href="lib/exe/css" />
20 <link rel="stylesheet" media="screen" type="text/css" href="lib/exe/001css" />
21 <link rel="stylesheet" media="print" type="text/css" href="lib/exe/002css" />
22 </head>
23 <body>
24 <div class="dokuwiki export">
28 <h1><a name="hooks_scheme_extension_howto" id="hooks_scheme_extension_howto">Hooks/Scheme Extension HOWTO</a></h1>
29 <div class="level1">
30 <pre class="code">gEDA - GPL Electronic Design Automation
32 HOOKS AND SCHEME EXTENSION IN GSCHEM
33 ====================================
35 Copyright (C) 2000 Stefan Petersen
37 This program is free software; you can redistribute it and/or modify
38 it under the terms of the GNU General Public License as published by
39 the Free Software Foundation; either version 2 of the License, or
40 (at your option) any later version.
42 This program is distributed in the hope that it will be useful,
43 but WITHOUT ANY WARRANTY; without even the implied warranty of
44 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45 GNU General Public License for more details.
47 You should have received a copy of the GNU General Public License
48 along with this program; if not, write to the Free Software
49 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
52 Introduction
53 ------------
54 gschem has a scheme interpreter (called Guile) built in. Though not
55 complete, there are extensions to this interpreter to get access to
56 different parts of the schematic.
58 There are a couple of other scheme extensions available that will not be
59 described here. They belong mainly to rc-files (resource files in
60 gEDA programs are really scheme scripts) and to the keymapping system
61 (described in separate keymapping documentation).
63 The rest I will try to describe here.
66 Scheme functions
67 ----------------
68 There are two function available for handling attributes in the schematic.
70 * get-attribute-name-value
71 Inparameter : an attribute
72 Outparameter : a pair with the name of the attribute as string in the
73 car element and the value of the attribute in the cdr
74 element.
75 Description : Simply an accessor to the information hidden in the type
76 attribute. The functionality of this is placed in libgeda
77 since the C-type ATTRIBUTE is defined there.
79 * set-attribute-value!
80 Inparameter : an attribute and a string.
81 Outparameter : undefined.
82 Description : Sets a new value to an attribute. The attribute must
83 be defined, the function can&#039;t create a new attribute.
84 Defined both in gschem and libgeda, mainly because
85 where different variables and information are available.
88 Hooks
89 -----
90 Hooks are a way to define functions that will be called during different
91 part of a programs execution. In gschem there are (currently) three
92 different hooks available:
93 * add-component-hook
94 * copy-component-hook
95 * move-component-hook
97 As their name indicate, they are called at different occasions. When
98 you add a component add-component-hook is called, etc.
100 To add a function to be called you simply use the Guile funtion add-hook!.
101 An example; to run the function auto-uref when you add a component you
102 simply add the following line, preferrably in ${HOME}/.gEDA/gschemrc:
103 (add-hook! add-component-hook auto-uref)
105 The function to be called from a hook (for example auto-uref above) has
106 to accept one parameter, a list of attributes.
108 A small example that prints all attributes on a component to be placed:
110 (define (print-all-attributes attribute-list)
111 (foreach (lambda (attribute) (display attribute)) attribute-list))
114 How to use this
115 ---------------
116 The most complete example utilizing all of the above functions are in fact
117 the auto-uref scheme script that currently is part of the gschem distribution.
118 You can find it &lt;where gschem is installed&gt;/share/gEDA/scheme/auto-uref.scm.
119 Uninstalled it&#039;s available at gschem/scheme/auto-uref.scm
121 All components have a reference designator that must be unique so
122 gnetlist can handle it properly. By automatically assigning a number
123 to each instance of a component when you place and copy it, you can
124 simplify the naming operation.
126 All components has, per default, an uref attribute, for example uref=R?.
127 The letter varies with component type. The auto-uref script enumerates
128 uref based on what prefix the component has and assigns a number.
130 For example, the first component you place has per default uref=U? gets
131 the attribute uref=U1. Next component with uref=U? gets uref=U2 and so on.
133 To be able to use the auto-uref script you simply add two lines in
134 ${HOME}/.gEDA/gschemrc. They are:
135 (load &quot;&lt;where gschem is installed&gt;/share/gEDA/scheme/auto-uref.scm&quot;)
136 (add-hook! add-component-hook auto-uref)
138 If you want auto enumeration to work when you copy the component too, you
139 simply add the following line:
140 (add-hook! copy-component-hook auto-uref)
142 Good luck!
144 </pre>
146 </div>
147 </div>
148 </body>
149 </html>