You are on page 1of 132

EAGLE

EASILY APPLICABLE GRAPHICAL LAYOUT EDITOR

User Language
Version 5.4

Copyright 2009 CadSoft

All rights reserved

EAGLEUserLanguage

TableOfContents
UserLanguage.........................................................................................................12
WritingaULP..........................................................................................................12
ExecutingaULP.......................................................................................................13
Syntax......................................................................................................................13
Whitespace..............................................................................................................13
Comments................................................................................................................14
Directives.................................................................................................................14
#include..................................................................................................................14
Portabilitynote..................................................................................................15
#require...................................................................................................................15
#usage.....................................................................................................................15
Example.............................................................................................................16
Keywords.................................................................................................................16
Identifiers................................................................................................................16
Constants.................................................................................................................17
CharacterConstants.................................................................................................17
IntegerConstants.....................................................................................................17
Examples...........................................................................................................17
RealConstants.........................................................................................................17
Examples...........................................................................................................18
StringConstants......................................................................................................18
EscapeSequences....................................................................................................18
Examples...........................................................................................................19
Punctuators..............................................................................................................19
Brackets...................................................................................................................19
Parentheses..............................................................................................................20
Braces......................................................................................................................20
Comma....................................................................................................................20
Semicolon................................................................................................................20
Colon.......................................................................................................................21
EqualSign................................................................................................................21
DataTypes...............................................................................................................21
char..........................................................................................................................21
int............................................................................................................................21
real...........................................................................................................................22
string........................................................................................................................22
Implementationdetails......................................................................................22
TypeConversions.....................................................................................................23
Page2of132

EAGLEUserLanguage
Typecast...................................................................................................................23
ObjectTypes.............................................................................................................23
UL_ARC...................................................................................................................26
Constants...........................................................................................................26
Note...................................................................................................................26
Example.............................................................................................................26
UL_AREA.................................................................................................................26
Example.............................................................................................................27
UL_ATTRIBUTE........................................................................................................27
Constants...........................................................................................................27
Note...................................................................................................................27
Example.............................................................................................................28
UL_BOARD..............................................................................................................28
Note...................................................................................................................28
Example.............................................................................................................28
UL_BUS....................................................................................................................29
Constants...........................................................................................................29
Example.............................................................................................................29
UL_CIRCLE..............................................................................................................29
Example.............................................................................................................29
UL_CLASS................................................................................................................29
Note...................................................................................................................30
Example.............................................................................................................30
UL_CONTACT..........................................................................................................30
Constants...........................................................................................................30
Note...................................................................................................................30
Example.............................................................................................................30
UL_CONTACTREF....................................................................................................31
Example.............................................................................................................31
UL_DEVICE..............................................................................................................31
Constants...........................................................................................................31
Note...................................................................................................................32
Examples...........................................................................................................32
UL_DEVICESET........................................................................................................32
Constants...........................................................................................................33
Note...................................................................................................................33
Example.............................................................................................................33
UL_ELEMENT..........................................................................................................33
Constants...........................................................................................................34
Note...................................................................................................................34
Examples...........................................................................................................34
UL_FRAME...............................................................................................................35
Constants...........................................................................................................35
Page3of132

EAGLEUserLanguage
Note...................................................................................................................35
Example.............................................................................................................35
UL_GATE..................................................................................................................35
Constants...........................................................................................................36
Note...................................................................................................................36
Example.............................................................................................................36
UL_GRID..................................................................................................................36
Constants...........................................................................................................36
Note...................................................................................................................36
Example.............................................................................................................37
UL_HOLE.................................................................................................................37
Note...................................................................................................................37
Example.............................................................................................................37
UL_INSTANCE..........................................................................................................37
Constants...........................................................................................................38
Note...................................................................................................................38
Example.............................................................................................................38
UL_JUNCTION.........................................................................................................39
Example.............................................................................................................39
UL_LABEL................................................................................................................39
Note...................................................................................................................39
Example.............................................................................................................40
UL_LAYER................................................................................................................40
Constants...........................................................................................................40
Example.............................................................................................................41
UL_LIBRARY............................................................................................................41
Constants...........................................................................................................42
Note...................................................................................................................42
Example.............................................................................................................42
UL_NET....................................................................................................................42
Constants...........................................................................................................42
Note...................................................................................................................43
Example.............................................................................................................43
UL_PACKAGE...........................................................................................................43
Constants...........................................................................................................44
Note...................................................................................................................44
Example.............................................................................................................44
UL_PAD....................................................................................................................44
Constants...........................................................................................................45
Note...................................................................................................................45
Example.............................................................................................................46
UL_PART..................................................................................................................46
Constants...........................................................................................................46
Note...................................................................................................................46
Page4of132

EAGLEUserLanguage
Example.............................................................................................................47
UL_PIN.....................................................................................................................47
Constants...........................................................................................................47
Note...................................................................................................................48
Example.............................................................................................................48
UL_PINREF..............................................................................................................49
Example.............................................................................................................49
UL_POLYGON..........................................................................................................49
Constants...........................................................................................................50
Note...................................................................................................................50
Polygonwidth....................................................................................................50
Partialpolygons.................................................................................................50
Example.............................................................................................................51
UL_RECTANGLE......................................................................................................51
Example.............................................................................................................52
UL_SCHEMATIC.......................................................................................................52
Note...................................................................................................................52
Example.............................................................................................................52
UL_SEGMENT..........................................................................................................52
Note...................................................................................................................53
Example.............................................................................................................53
UL_SHEET...............................................................................................................53
Example.............................................................................................................54
UL_SIGNAL..............................................................................................................54
Constants...........................................................................................................54
Example.............................................................................................................54
UL_SMD...................................................................................................................54
Constants...........................................................................................................54
Note...................................................................................................................55
Example.............................................................................................................55
UL_SYMBOL............................................................................................................55
Constants...........................................................................................................56
Note...................................................................................................................56
Example.............................................................................................................56
UL_TEXT..................................................................................................................56
Constants...........................................................................................................56
Note...................................................................................................................57
Example.............................................................................................................57
UL_VIA.....................................................................................................................57
Constants...........................................................................................................57
Note...................................................................................................................57
Example.............................................................................................................58
UL_WIRE.................................................................................................................58
Constants...........................................................................................................58
Page5of132

EAGLEUserLanguage
WireStyle..........................................................................................................58
ArcsatWirelevel...............................................................................................59
Example.............................................................................................................59
Definitions...............................................................................................................59
ConstantDefinitions................................................................................................60
VariableDefinitions..................................................................................................60
Examples...........................................................................................................60
FunctionDefinitions................................................................................................61
Thespecialfunctionmain()...............................................................................61
Example.............................................................................................................61
Operators.................................................................................................................62
BitwiseOperators....................................................................................................62
LogicalOperators.....................................................................................................63
ComparisonOperators.............................................................................................63
EvaluationOperators...............................................................................................63
ArithmeticOperators...............................................................................................64
StringOperators......................................................................................................64
Expressions..............................................................................................................65
ArithmeticExpression..............................................................................................65
Examples...........................................................................................................65
AssignmentExpression............................................................................................65
Examples...........................................................................................................65
StringExpression.....................................................................................................65
Examples...........................................................................................................65
CommaExpression..................................................................................................65
Example.............................................................................................................66
ConditionalExpression............................................................................................66
Example.............................................................................................................66
FunctionCall...........................................................................................................66
Example.............................................................................................................66
Statements...............................................................................................................66
CompoundStatement..............................................................................................66
ExpressionStatement..............................................................................................67
ControlStatements..................................................................................................67
break........................................................................................................................67
continue...................................................................................................................67
do...while.................................................................................................................68
Example.............................................................................................................68
for............................................................................................................................68
Example.............................................................................................................68
if...else.....................................................................................................................69
Page6of132

EAGLEUserLanguage
return.......................................................................................................................69
switch......................................................................................................................69
Example.............................................................................................................70
while........................................................................................................................70
Example.............................................................................................................70
Builtins.....................................................................................................................71
BuiltinConstants.....................................................................................................71
BuiltinVariables.......................................................................................................72
BuiltinFunctions......................................................................................................72
CharacterFunctions.................................................................................................74
is...()........................................................................................................................74
Charactercategories..........................................................................................75
Example.............................................................................................................75
to...().......................................................................................................................75
FileHandlingFunctions...........................................................................................75
fileerror().................................................................................................................76
Example.............................................................................................................76
fileglob()..................................................................................................................76
NoteforWindowsusers.....................................................................................77
Example.............................................................................................................77
FilenameFunctions..................................................................................................77
Example.............................................................................................................77
FiledataFunctions...................................................................................................78
Example.............................................................................................................78
FileInputFunctions.................................................................................................78
fileread()..................................................................................................................78
Example.............................................................................................................79
MathematicalFunctions...........................................................................................79
ErrorMessages...................................................................................................79
Absolute,MaximumandMinimumFunctions.........................................................80
Example.............................................................................................................80
RoundingFunctions.................................................................................................80
Example.............................................................................................................80
TrigonometricFunctions..........................................................................................81
Constants...........................................................................................................81
Example.............................................................................................................81
ExponentialFunctions.............................................................................................81
Note...................................................................................................................82
Example.............................................................................................................82
MiscellaneousFunctions..........................................................................................82
exit()........................................................................................................................82
Constants...........................................................................................................82
Page7of132

EAGLEUserLanguage
language()...............................................................................................................82
Example.............................................................................................................83
lookup()...................................................................................................................84
Example.............................................................................................................85
palette()...................................................................................................................85
Constants...........................................................................................................85
sort()........................................................................................................................86
Sortingasinglearray.........................................................................................86
Sortingasetofarrays........................................................................................86
status()....................................................................................................................87
system()...................................................................................................................87
Input/Outputredirection...................................................................................87
Backgroundexecution.......................................................................................88
Example.............................................................................................................88
UnitConversions......................................................................................................88
Example.............................................................................................................89
PrintingFunctions...................................................................................................89
printf().....................................................................................................................89
Formatstring.....................................................................................................89
Formatspecifiers................................................................................................90
Conversiontypecharacters................................................................................90
Flagcharacters...................................................................................................90
Widthspecifiers.................................................................................................90
Precisionspecifiers.............................................................................................91
Defaultprecisionvalues.....................................................................................91
Howprecisionspecification(.n)affectsconversion...........................................91
Binaryzerocharacters.......................................................................................91
Example.............................................................................................................92
sprintf()...................................................................................................................92
Formatstring.....................................................................................................92
Binaryzerocharacters.......................................................................................92
Example.............................................................................................................92
StringFunctions.......................................................................................................92
strchr()....................................................................................................................93
Example.............................................................................................................93
strjoin()....................................................................................................................93
Example.............................................................................................................94
strlen().....................................................................................................................94
Example.............................................................................................................94
strlwr()....................................................................................................................94
Example.............................................................................................................94
strrchr()...................................................................................................................94
Example.............................................................................................................95
Page8of132

EAGLEUserLanguage
strrstr()....................................................................................................................95
Example.............................................................................................................95
strsplit()...................................................................................................................95
Example.............................................................................................................96
strstr().....................................................................................................................96
Example.............................................................................................................96
strsub()....................................................................................................................96
Example.............................................................................................................97
strtod()....................................................................................................................97
Example.............................................................................................................97
strtol().....................................................................................................................97
Example.............................................................................................................98
strupr()....................................................................................................................98
Example.............................................................................................................98
TimeFunctions........................................................................................................98
time()......................................................................................................................98
Example.............................................................................................................99
timems()..................................................................................................................99
Example.............................................................................................................99
TimeConversions....................................................................................................99
Example...........................................................................................................100
ObjectFunctions....................................................................................................100
ingroup()...............................................................................................................100
Example...........................................................................................................101
BuiltinStatements.................................................................................................101
board()..................................................................................................................101
Checkifthereisaboard..................................................................................102
Accessingboardfromaschematic...................................................................102
Example...........................................................................................................102
deviceset().............................................................................................................102
Checkifthereisadeviceset............................................................................103
Example...........................................................................................................103
library().................................................................................................................103
Checkifthereisalibrary.................................................................................103
Example...........................................................................................................103
output().................................................................................................................104
FileModes.......................................................................................................104
NestedOutputstatements...............................................................................104
Example...........................................................................................................104
package()...............................................................................................................105
Checkifthereisapackage..............................................................................105
Example...........................................................................................................105
Page9of132

EAGLEUserLanguage
schematic()............................................................................................................105
Checkifthereisaschematic...........................................................................106
Accessingschematicfromaboard...................................................................106
AccessthecurrentSheet..................................................................................106
Example...........................................................................................................106
sheet()...................................................................................................................106
Checkifthereisasheet...................................................................................107
Example...........................................................................................................107
symbol()................................................................................................................107
Checkifthereisasymbol................................................................................107
Example...........................................................................................................107
Dialogs...................................................................................................................108
PredefinedDialogs.................................................................................................108
dlgDirectory()........................................................................................................108
Example...........................................................................................................108
dlgFileOpen(),dlgFileSave().................................................................................109
Example...........................................................................................................109
dlgMessageBox()...................................................................................................109
Example...........................................................................................................110
DialogObjects........................................................................................................110
dlgCell...................................................................................................................111
Example...........................................................................................................111
dlgCheckBox..........................................................................................................111
Example...........................................................................................................112
dlgComboBox........................................................................................................112
Example...........................................................................................................113
dlgDialog...............................................................................................................113
Examples.........................................................................................................113
dlgGridLayout........................................................................................................114
Example...........................................................................................................114
dlgGroup................................................................................................................114
Example...........................................................................................................115
dlgHBoxLayout......................................................................................................115
Example...........................................................................................................115
dlgIntEdit...............................................................................................................115
Example...........................................................................................................115
dlgLabel.................................................................................................................116
Example...........................................................................................................116
dlgListBox..............................................................................................................116
Example...........................................................................................................117
dlgListView............................................................................................................117
Example...........................................................................................................118
Page10of132

EAGLEUserLanguage
dlgPushButton.......................................................................................................118
Example...........................................................................................................119
dlgRadioButton......................................................................................................119
Example...........................................................................................................119
dlgRealEdit............................................................................................................120
Example...........................................................................................................120
dlgSpacing.............................................................................................................120
Example...........................................................................................................120
dlgSpinBox.............................................................................................................121
Example...........................................................................................................121
dlgStretch..............................................................................................................121
Example...........................................................................................................121
dlgStringEdit..........................................................................................................121
Example...........................................................................................................122
dlgTabPage.............................................................................................................122
Example...........................................................................................................122
dlgTabWidget.........................................................................................................122
Example...........................................................................................................123
dlgTextEdit.............................................................................................................123
Example...........................................................................................................123
dlgTextView...........................................................................................................123
Example...........................................................................................................124
dlgVBoxLayout.......................................................................................................124
Example...........................................................................................................124
LayoutInformation................................................................................................124
GridLayoutContext........................................................................................124
HorizontalLayoutContext...............................................................................125
VerticalLayoutContext....................................................................................125
MixingLayoutContexts...................................................................................125
DialogFunctions....................................................................................................125
dlgAccept()............................................................................................................125
Example...........................................................................................................126
dlgRedisplay().......................................................................................................126
Example...........................................................................................................126
dlgReset()..............................................................................................................127
Example...........................................................................................................127
dlgReject().............................................................................................................127
Example...........................................................................................................128
EscapeCharacter...................................................................................................128
ACompleteExample.............................................................................................128
SupportedHTMLtags............................................................................................129

Page11of132

EAGLEUserLanguage

User Language
TheEAGLEUserLanguagecanbeusedtoaccesstheEAGLEdatastructuresandtocreatea
widevarietyofoutputfiles.
TousethisfeatureyouhavetowriteaUserLanguageProgram(ULP),andthenexecuteit.
ThefollowingsectionsdescribetheEAGLEUserLanguageindetail:
Syntax
DataTypes
ObjectTypes
Definitions
Operators
Expressions
Statements
Builtins
Dialogs

liststherulesaULPfilehastofollow
definesthebasicdatatypes
definestheEAGLEobjects
showshowtowriteadefinition
liststhevalidoperators
showshowtowriteexpressions
definesthevalidstatements
liststhebuiltinconstants,functionsetc.
showshowtoimplementagraphicalfrontenttoa
ULP

Writing a ULP
AUserLanguageProgramisaplaintextfilewhichiswritteninaClikesyntax.User
LanguageProgramsusetheextension.ulp.YoucancreateaULPfilewithanytexteditor
(provideditdoesnotinsertanyadditionalcontrolcharactersintothefile)oryoucanuse
thebuiltintexteditor.
AUserLanguageProgramconsistsoftwomajoritems,definitionsandstatements.
Definitionsareusedtodefineconstants,variablesandfunctionstobeusedbystatements.
AsimpleULPcouldlooklikethis:
#usage "Add the characters in the word 'Hello'\n"
"Usage: RUN sample.ulp"
// Definitions:
string hello = "Hello";
int count(string s)
{
int c = 0;
for (int i = 0; s[i]; ++i)
c += s[i];
return c;
}
// Statements:
output("sample") {
printf("Count is: %d\n", count(hello));
}

Ifthe#usagedirectiveispresent,itsvaluewillbeusedintheControlPaneltodisplaya
descriptionoftheprogram.
IftheresultoftheULPshallbeaspecificcommandthatshallbeexecutedintheeditor
window,theexit()functioncanbeusedtosendthatcommandtotheeditorwindow.
Page12of132

EAGLEUserLanguage

Executing a ULP
UserLanguageProgramsareexecutedbytheRUNcommandfromaneditorwindow's
commandline.
AULPcanreturninformationonwhetherithasrunsuccessfullyornot.Youcanusethe
exit()functiontoterminatetheprogramandsetthereturnvalue.
Areturnvalueof0meanstheULPhasended"normally"(i.e.successfully),whileanyother
valueisconsideredasanabnormalprogramtermination.
ThedefaultreturnvalueofanyULPis0.
WhentheRUNcommandisexecutedaspartofascriptfile,thescriptisterminatedifthe
ULPhasexitedwithareturnvalueotherthan0.
Aspecialvariantoftheexit()functioncanbeusedtosendacommandtotheeditor
windowasaresultoftheULP.

Syntax
ThebasicbuildingblocksofaUserLanguageProgramare

Whitespace
Comments
Directives
Keywords
Identifiers
Constants
Punctuators

Allofthesehavetofollowcertainsyntacticalrules,whicharedescribedintheirrespective
sections.

Whitespace
BeforeaUserLanguageProgramcanbeexecuted,ithastobereadinfromafile.During
thisreadinprocess,thefilecontentsisparsedintotokensandwhitespace.
Anyspaces(blanks),tabs,newlinecharactersandcommentsareconsideredwhitespaceand
arediscarded.
TheonlyplacewhereASCIIcharactersrepresentingwhitespacearenotdiscardediswithin
literalstrings,likein
string s = "Hello World";

wheretheblankcharacterbetween'o'and'W'remainspartofthestring.
Ifthefinalnewlinecharacterofalineisprecededbyabackslash(\),thebackslashand
newlinecharacterarebothdiscarded,andthetwolinesaretreatedasoneline:
"Hello \
World"

Page13of132

EAGLEUserLanguage
isparsedas"Hello World"

Comments
WhenwritingaUserLanguageProgramitisgoodpracticetoaddsomedescriptivetext,
givingthereaderanideaaboutwhatthisparticularULPdoes.Youmightalsowanttoadd
yourname(and,ifavailable,youremailaddress)totheULPfile,sothatotherpeoplewho
useyourprogramcouldcontactyouincasetheyhaveaproblemorwouldliketosuggest
animprovement.
Therearetwowaystodefineacomment.Thefirstoneusesthesyntax
/* some comment text */

whichmarksanycharactersbetween(andincluding)theopening/*andtheclosing*/as
comment.Suchcommentsmayexpandovermorethanonelines,asin
/* This is a
multi line comment
*/

buttheydonotnest.Thefirst*/thatfollowsany/*willendthecomment.
Thesecondwaytodefineacommentusesthesyntax
int i; // some comment text

whichmarksanycharactersafter(andincluding)the//andupto(butnotincluding)the
newlinecharacterattheendofthelineascomment.

Directives
Thefollowingdirectivesareavailable:
#include
#require
#usage

#include
AUserLanguageProgramcanreusecodeinotherULPfilesthroughthe#include
directive.Thesyntaxis
#include "filename"

Thefilefilenameisfirstlookedforinthesamedirectoryasthecurrentsourcefile(thatis
thefilethatcontainsthe#includedirective).Ifitisnotfoundthere,itissearchedforin
thedirectoriescontainedintheULPdirectorypath.
Themaximumincludedepthis10.
Each#includedirectiveisprocessedonlyonce.Thismakessurethatthereareno
multipledefinitionsofthesamevariablesorfunctions,whichwouldcauseerrors.
Page14of132

EAGLEUserLanguage

Portability note
Iffilenamecontainsadirectorypath,itisbesttoalwaysusetheforwardslashas
directoryseparator(evenunderWindows!).Windowsdrivelettersshouldbe
avoided.ThiswayaUserLanguageProgramwillrunonallplatforms.

#require
OvertimeitmayhappenthatnewerversionsofEAGLEimplementnewormodifiedUser
Languagefeatures,whichcancauseerrormessageswhensuchaULPisrunfromanolder
versionofEAGLE.InordertogivetheuseradedicatedmessagethatthisULPrequiresat
leastacertainversionofEAGLE,aULPcancontainthe#requiredirective.Thesyntaxis
#require version

Theversionmustbegivenasarealconstantoftheform
V.RRrr

whereVistheversionnumber,RRisthereleasenumberandrristhe(optional)revision
number(bothpaddedwithleadingzeroesiftheyarelessthan10).Forexample,ifaULP
requiresatleastEAGLEversion4.11r06(whichisthebetaversionthatfirstimplemented
the#requiredirective),itcoulduse
#require 4.1106

Theproperdirectiveforversion5.1.2wouldbe
#require 5.0102

#usage
EveryUserLanguageProgramshouldcontaininformationaboutitsfunction,howtouseit
andmaybewhowroteit.
Thedirective
#usage text [, text...]

implementsastandardwaytomakethisinformationavailable.
Ifthe#usagedirectiveispresent,itstext(whichhastobeastringconstant)willbeused
intheControlPaneltodisplayadescriptionoftheprogram.
IncasetheULPneedstousethisinformationin,forexample,adlgMessageBox(),thetext
isavailabletotheprogramthroughthebuiltinconstantusage.
Onlythe#usagedirectiveofthemainprogramfile(thatistheonestartedwiththeRUN
command)willtakeeffect.Thereforepureincludefilescan(andshould!)alsohave
#usagedirectivesoftheirown.
Itisbesttohavethe#usagedirectiveatthebeginningofthefile,sothattheControlPanel
doesn'thavetoparsealltherestofthetextwhenlookingfortheinformationtodisplay.

Page15of132

EAGLEUserLanguage
Iftheusageinformationshallbemadeavailableinseverallangauges,thetextsofthe
individuallanguageshavetobeseparatedbycommas.Eachofthesetextshastostartwith
thetwolettercodeoftherespectivelanguage(asdeliveredbythelanguage()function),
followedbyacolonandanynumberofblanks.Ifnosuitabletextisfoundforthelanguage
usedontheactualsystem,thefirstgiventextwillbeused(thisoneshouldgenerallybe
Englishinordertomaketheprogramaccessibletothelargestnumberofusers).

Example
#usage "en: A sample ULP\n"
"Implements an example that shows how to use the EAGLE User Language\
n"
"Usage: RUN sample.ulp\n"
"Author: john@home.org",
"de: Beispiel eines ULPs\n"
"Implementiert ein Beispiel das zeigt, wie man die EAGLE User
Language benutzt\n"
"Aufruf: RUN sample.ulp\n"
"Author: john@home.org"

Keywords
Thefollowingkeywordsarereservedforspecialpurposesandmustnotbeusedasnormal
identifiernames:
break
case
char
continue
default
do
else
enum
for
if
int
numeric
real
return
string
switch
void
while

Inaddition,thenamesofbuiltinsandobjecttypesarealsoreservedandmustnotbeused
asidentifiernames.

Identifiers
Anidentifierisanamethatisusedtointroduceauserdefinedconstant,variableor
function.
Identifiersconsistofasequenceofletters(a b c...,A B C...),digits(1 2 3...)and
underscores(_).Thefirstcharacterofanidentifiermustbealetteroranunderscore.
Page16of132

EAGLEUserLanguage
Identifiersarecasesensitive,whichmeansthat
int Number, number;

woulddefinetwodifferentintegervariables.
Themaximumlengthofanidentifieris100characters,andallofthesearesignificant.

Constants
ConstantsareliteraldataitemswrittenintoaUserLanguageProgram.Accordingtothe
differentdatatypes,therearealsodifferenttypesofconstants.

Characterconstants
Integerconstants
Realconstants
Stringconstants

Character Constants
Acharacterconstantconsistsofasinglecharacteroranescapesequenceenclosedinsingle
quotes,like
'a'
'='
'\n'

Thetypeofacharacterconstantischar.

Integer Constants
Dependingonthefirst(andpossiblythesecond)character,anintegerconstantisassumed
tobeexpressedindifferentbasevalues:
constantinterpreted
as
0
1-7
octal(base8)
0
x,X
hexadecimal(base16)
1-9
decimal(base10)
Thetypeofanintegerconstantisint.
first

second

Examples
16
020
0x10

decimal
octal
hexadecimal

Real Constants
Arealconstantfollowsthegeneralpattern
[-]int.frac[e|E[]exp]

Page17of132

EAGLEUserLanguage
whichstandsfor

optionalsign
decimalinteger
decimalpoint
decimalfraction
eorEandasignedintegerexponent

Youcanomiteitherthedecimalintegerorthedecimalfraction(butnotboth).Youcanomit
eitherthedecimalpointorthelettereorEandthesignedintegerexponent(butnotboth).
Thetypeofanrealconstantisreal.

Examples
Constant
23.45e6
.0
0.
1.
-1.23
2e-5
3E+10
.09E34

Value
23.45x10^6
0.0
0.0
1.0
1.23
2.0x10^5
3.0x10^10
0.09x10^34

String Constants
Astringconstantconsistsofasequenceofcharactersorescapesequencesenclosedin
doublequotes,like
"Hello world\n"

Thetypeofastringconstantisstring.
Stringconstantscanbeofanylength(providedthereisenoughfreememoryavailable).
Stringconstantscanbeconcatenatedbysimplywritingthemnexttoeachothertoform
largerstrings:
string s = "Hello" " world\n";

Itisalsopossibletoextendastringconstantovermorethanonelinebyescapingthe
newlinecharacterwithabackslash(\):
string s = "Hello \
world\n";

Escape Sequences
Anescapesequenceconsistsofabackslash(\),followedbyoneormorespecialcharacters:
Sequence

Value
Page18of132

EAGLEUserLanguage
audiblebell
backspace
formfeed
newline
carriagereturn
horizontaltab
verticaltab
backslash
singlequote
doublequote
O=upto3octal
\O
digits
\xH
H=upto2hexdigits
Anycharacterfollowingtheinitialbackslashthatisnotmentionedinthislistwillbetreated
asthatcharacter(withoutthebackslash).
\a
\b
\f
\n
\r
\t
\v
\\
\'
\"

Escapesequencescanbeusedincharacterconstantsandstringconstants.

Examples
'\n'
"A tab\tinside a text\n"
"Ring the bell\a\n"

Punctuators
ThepunctuatorsusedinaUserLanguageProgramare
[] Brackets
() Parentheses
{} Braces
,
Comma
;
Semicolon
:
Colon
=
Equalsign
OtherspecialcharactersareusedasoperatorsinaULP.

Brackets
Bracketsareusedinarraydefinitions
int ai[];

inarraysubscripts
n = ai[2];

andinstringsubscriptstoaccesstheindividualcharactersofastring
string s = "Hello world";

Page19of132

EAGLEUserLanguage
char c = s[2];

Parentheses
Parenthesesgroupexpressions(possiblyalteringnormaloperatorprecedence),isolate
conditionalexpressions,andindicatefunctioncallsandfunctionparameters:
d = c * (a + b);
if (d == z) ++x;
func();
void func2(int n) { ... }

Braces
Bracesindicatethestartandendofacompoundstatement:
if (d == z) {
++x;
func();
}

andarealsousedtogroupthevaluesofanarrayinitializer:
int ai[] = { 1, 2, 3 };

Comma
Thecommaseparatestheelementsofafunctionargumentlistortheparametersofa
functioncall:
int func(int n, real r, string s) { ... }
int i = func(1, 3.14, "abc");

Italsodelimitsthevaluesofanarrayinitializer:
int ai[] = { 1, 2, 3 };

anditseparatestheelementsofavariabledefinition:
int i, j, k;

Semicolon
Thesemicolonterminatesastatement,asin
i = a + b;

anditalsodelimitstheinit,testandincrementexpressionsofaforstatement:
for (int n = 0; n < 3; ++n) {
func(n);
}

Page20of132

EAGLEUserLanguage

Colon
Thecolonindicatestheendofalabelinaswitchstatement:
switch (c) {
case 'a': printf("It was an 'a'\n"); break;
case 'b': printf("It was a 'b'\n"); break;
default: printf("none of them\n");
}

Equal Sign
Theequalsignseparatesvariabledefinitionsfrominitializationlists:
int i = 10;
char c[] = { 'a', 'b', 'c' };

Itisalsousedasanassignmentoperator.

Data Types
AUserLanguageProgramcandefinevariablesofdifferenttypes,representingthedifferent
kindsofinformationavailableintheEAGLEdatastructures.
Thefourbasicdatatypesare
forsinglecharacters
forintegralvalues
forfloatingpoint
real
values
string fortextualinformation
BesidesthesebasicdatatypestherearealsohighlevelObjectTypes,whichrepresentthe
datastructuresstoredintheEAGLEdatafiles.
char
int

Thespecialdatatypevoidisusedonlyasareturntypeofafunction,indicatingthatthis
functiondoesnotreturnanyvalue.

char
Thedatatypecharisusedtostoresinglecharacters,likethelettersofthealphabet,or
smallunsignednumbers.
Avariableoftypecharhasasizeof8bit(onebyte),andcanstoreanyvalueintherange
0..255.
SeealsoOperators,CharacterConstants

int
Thedatatypeintisusedtostoresignedintegralvalues,likethecoordinatesofanobject.
Avariableoftypeinthasasizeof32bit(fourbyte),andcanstoreanyvalueintherange
-2147483648..2147483647.
Page21of132

EAGLEUserLanguage
SeealsoIntegerConstants

real
Thedatatyperealisusedtostoresignedfloatingpointvalues,likethegriddistance.
Avariableoftyperealhasasizeof64bit(eightbyte),andcanstoreanyvalueinthe
range2.2e-308..1.7e+308withaprecisionof15digits.
SeealsoRealConstants

string
Thedatatypestringisusedtostoretextualinformation,likethenameofapartornet.
Avariableoftypestringisnotlimitedinit'ssize(providedthereisenoughmemory
available).
Variablesoftypestringaredefinedwithoutanexplicitsize.Theygrowautomaticallyas
necessaryduringprogramexecution.
Theelementsofastringvariableareoftypecharandcanbeaccessedindividuallyby
using[index].Thefirstcharacterofastringhastheindex0:
string s = "Layout";
printf("Third char is: %c\n", s[2]);

Thiswouldprintthecharacter'y'.Notethats[2]returnsthethirdcharacterofs!
SeealsoOperators,BuiltinFunctions,StringConstants

Implementation details
ThedatatypestringisactuallyimplementedlikenativeCtypezeroterminatedstrings
(i.e.char[]).Lookingatthefollowingvariabledefinition
string s = "abcde";

s[4]isthecharacter'e',ands[5]isthecharacter'\0',ortheintegervalue0x00.This
factmaybeusedtodeterminetheendofastringwithoutusingthestrlen()function,as
in
for (int i = 0; s[i]; ++i) {
// do something with s[i]
}

Itisalsoperfectlyokto"cutoff"partofastringby"punching"azerocharacterintoit:
string s = "abcde";
s[3] = 0;

Thiswillresultinshavingthevalue"abc".Notethateverythingfollowingthezero
characterwillactuallybegone,anditwon'tcomebackbyrestoringtheoriginalcharacter.
Thesameappliestoanyotheroperationthatsetsacharacterto0,forinstances[3].
Page22of132

EAGLEUserLanguage

Type Conversions
Theresulttypeofanarithmeticexpression,suchasa + b,whereaandbaredifferent
arithmetictypes,isequaltothe"larger"ofthetwooperandtypes.
Arithmetictypesarechar,intandreal(inthatorder).Soif,e.g.aisoftypeintandb
isoftypereal,theresultoftheexpressiona + bwouldbereal.
SeealsoTypecast

Typecast
Theresulttypeofanarithmeticexpressioncanbeexplicitlyconvertedtoadifferent
arithmetictypebyapplyingatypecasttoit.
Thegeneralsyntaxofatypecastis
type(expression)

wheretypeisoneofchar,intorreal,andexpressionisanyarithmeticexpression.
Whentypecastingarealexpressiontoint,thefractionalpartofthevalueistruncated!
SeealsoTypeConversions

Object Types
TheEAGLEdatastructuresarestoredinthreebinaryfiletypes:

Library(*.lbr)
Schematic(*.sch)
Board(*.brd)

Thesedatafilescontainahierarchyofobjects.InaUserLanguageProgramyoucanaccess
thesehierarchiesthroughtheirrespectivebuiltinaccessstatements:
library(L) { ... }
schematic(S) { ... }
board(B) { ... }

Theseaccessstatementssetupacontextwithinwhichyoucanaccessalloftheobjects
containedinthelibrary,schematicorboard.
Thepropertiesoftheseobjectscanbeaccessedthroughmembers.
Therearetwokindsofmembers:

Datamembers
Loopmembers

Datamembersimmediatelyreturntherequesteddatafromanobject.Forexample,in
board(B) {
printf("%s\n", B.name);
}

Page23of132

EAGLEUserLanguage
thedatamembernameoftheboardobjectBreturnstheboard'sname.
Datamemberscanalsoreturnotherobjects,asin
board(B) {
printf("%f\n", B.grid.size);
}

wheretheboard'sgriddatamemberreturnsagridobject,ofwhichthesizedatamember
thenreturnsthegrid'ssize.
Loopmembersareusedtoaccessmultipleobjectsofthesamekind,whicharecontained
inahigherlevelobject:
board(B) {
B.elements(E) {
printf("%-8s %-8s\n", E.name, E.value);
}
}

Thisexampleusestheboard'selements()loopmemberfunctiontosetupaloopthroughall
oftheboard'selements.TheblockfollowingtheB.elements(E)statementisexecutedin
turnforeachelement,andthecurrentelementcanbereferencedinsidetheblockthrough
thenameE.
Loopmembersprocessobjectsinalphanumericalorder,providedtheyhaveaname.
Aloopmemberfunctioncreatesavariableofthetypenecessarytoholdtherequested
objects.Youarefreetouseanyvalidnameforsuchavariable,sotheaboveexamplemight
alsobewrittenas
board(MyBoard) {
B.elements(TheCurrentElement) {
printf("%-8s %-8s\n", TheCurrentElement.name, TheCurrentElement.value);
}
}

andwoulddotheexactsamething.Thescopeofthevariablecreatedbyaloopmember
functionislimitedtothestatement(orblock)immediatelyfollowingtheloopfunctioncall.
ObjecthierarchyofaLibrary:
LIBRARY
GRID
LAYER
DEVICESET
DEVICE
GATE
PACKAGE
CONTACT
PAD
SMD
CIRCLE
HOLE
RECTANGLE
FRAME
TEXT
WIRE

Page24of132

EAGLEUserLanguage
POLYGON
WIRE
SYMBOL
PIN
CIRCLE
RECTANGLE
FRAME
TEXT
WIRE
POLYGON
WIRE

ObjecthierarchyofaSchematic:
SCHEMATIC
GRID
LAYER
LIBRARY
SHEET
CIRCLE
RECTANGLE
FRAME
TEXT
WIRE
POLYGON
WIRE
PART
INSTANCE
ATTRIBUTE
BUS
SEGMENT
LABEL
TEXT
WIRE
WIRE
NET
SEGMENT
JUNCTION
PINREF
TEXT
WIRE

ObjecthierarchyofaBoard:
BOARD
GRID
LAYER
LIBRARY
CIRCLE
HOLE
RECTANGLE
FRAME
TEXT
WIRE
POLYGON
WIRE
ELEMENT
ATTRIBUTE
SIGNAL

Page25of132

EAGLEUserLanguage
CONTACTREF
POLYGON
WIRE
VIA
WIRE

UL_ARC
Datamembers
angle1 real(startangle,0.0...359.9)
angle2 real(endangle,0.0...719.9)
cap
int(CAP_...)
layer
int
radius int
width
int
x1, y1 int(startingpoint)
x2, y2 int(endpoint)
xc, yc int(centerpoint)
SeealsoUL_WIRE

Constants
CAP_FLAT
CAP_ROUND

flatarcends
roundarc
ends

Note
Startandendanglesaredefinedmathematicallypositive(i.e.counterclockwise),with
angle1<angle2.Inordertoassurethiscondition,thestartandendpointofanUL_ARC
maybeexchangedwithrespecttotheUL_WIREthearchasbeenderivedfrom.

Example
board(B) {
B.wires(W) {
if (W.arc)
printf("Arc: (%d %d), (%d %d), (%d %d)\n",
W.arc.x1, W.arc.y1, W.arc.x2, W.arc.y2, W.arc.xc, W.arc.yc);
}
}

UL_AREA
Datamembers
x1, y1 int(lowerleftcorner)
int(upperright
x2, y2
corner)
SeealsoUL_BOARD,UL_DEVICE,UL_PACKAGE,UL_SHEET,UL_SYMBOL
Page26of132

EAGLEUserLanguage
AUL_AREAisanabstractobjectwhichgivesinformationabouttheareacoveredbyan
object.ForaUL_DEVICE,UL_PACKAGEandUL_SYMBOLtheareaisdefinedasthe
surroundingrectangleoftheobjectdefinitioninthelibrary,soevenife.g.aUL_PACKAGE
isderivedfromaUL_ELEMENT,thepackage'sareawillnotreflecttheelementsoffset
withintheboard.

Example
board(B) {
printf("Area: (%d %d), (%d %d)\n",
B.area.x1, B.area.y1, B.area.x2, B.area.y2);
}

UL_ATTRIBUTE
Datamembers
int(0=variable,i.e.allowsoverwriting,1=constantsee
note)
defaultvalue string(seenote)
display
int(ATTRIBUTE_DISPLAY_FLAG_...)
name
string
text
UL_TEXT(seenote)
value
string
SeealsoUL_DEVICE,UL_PART,UL_INSTANCE,UL_ELEMENT
constant

Constants
nothingis
displayed
ATTRIBUTE_DISPLAY_FLAG_VALUE valueisdisplayed
ATTRIBUTE_DISPLAY_FLAG_NAME
nameisdisplayed
AUL_ATTRIBUTEcanbeusedtoaccesstheattributesthathavebeendefinedinthelibrary
foradevice,orassignedtoapartintheschematicorboard.
ATTRIBUTE_DISPLAY_FLAG_OFF

Note
displaycontainsabitwiseor'edvalueconsistingofATTRIBUTE_DISPLAY_FLAG_...
anddefineswhichpartsoftheattributeareactuallydrawn.
InaUL_ELEMENTcontextconstantonlyreturnsanactualvalueiff/bannotationis
active,otherwiseitreturns0.
Thedefaultvaluememberreturnsthevalueasdefinedinthelibrary(ifdifferentfrom
theactualvalue,otherwisethesameasvalue).InaUL_ELEMENTcontext
defaultvalueonlyreturnsanactualvalueiff/bannotationisactive,otherwiseanempty
stringisreturned.
ThetextmemberisonlyavailableinaUL_INSTANCEorUL_ELEMENTcontextand
returnsaUL_TEXTobjectthatcontainsallthetextparameters.Thevalueofthistextobject
Page27of132

EAGLEUserLanguage
isthestringasitwillbedisplayedaccordingtotheUL_ATTRIBUTE's'display'parameter.If
calledfromadifferentcontext,thedataofthereturnedUL_TEXTobjectisundefined.
Forglobalattributesonlynameandvaluearedefined.

Example
schematic(SCH) {
SCH.parts(P) {
P.attributes(A) {
printf("%s = %s\n", A.name, A.value);
}
}
}
schematic(SCH) {
SCH.attributes(A) { // global attributes
printf("%s = %s\n", A.name, A.value);
}
}

UL_BOARD
Datamembers
area UL_AREA
grid UL_GRID
name string
Loopmembers
attributes() UL_ATTRIBUTE(seenote)
circles()
UL_CIRCLE
classes()
UL_CLASS
elements()
UL_ELEMENT
frames()
UL_FRAME
holes()
UL_HOLE
layers()
UL_LAYER
libraries()
UL_LIBRARY
polygons()
UL_POLYGON
rectangles() UL_RECTANGLE
signals()
UL_SIGNAL
texts()
UL_TEXT
wires()
UL_WIRE
SeealsoUL_LIBRARY,UL_SCHEMATIC

Note
Theattributes()loopmemberloopsthroughtheglobalattributes.

Example
board(B) {
B.elements(E) printf("Element: %s\n", E.name);

Page28of132

EAGLEUserLanguage
B.signals(S)
}

printf("Signal: %s\n", S.name);

UL_BUS
Datamembers
name string(BUS_NAME_LENGTH)
Loopmembers
segments() UL_SEGMENT
SeealsoUL_SHEET

Constants
BUS_NAME_LENG
TH

max.lengthofabusname(obsoleteasfromversion4busnames
canhaveanylength)

Example
schematic(SCH) {
SCH.sheets(SH) {
SH.busses(B) printf("Bus: %s\n", B.name);
}
}

UL_CIRCLE
Datamembers
layer
int
radius int
width
int
x, y
int(centerpoint)
SeealsoUL_BOARD,UL_PACKAGE,UL_SHEET,UL_SYMBOL

Example
board(B) {
B.circles(C) {
printf("Circle: (%d %d), r=%d, w=%d\n",
C.x, C.y, C.radius, C.width);
}
}

UL_CLASS
Datamembers
clearance[number]
drill
name
number

int(seenote)
int
string(seenote)
int
Page29of132

EAGLEUserLanguage
width
int
SeealsoDesignRules,UL_NET,UL_SIGNAL,UL_SCHEMATIC,UL_BOARD

Note
Theclearancememberreturnstheclearancevaluebetweenthisnetclassandthenet
classwiththegivennumber.Ifthenumber(andthesquarebrackets)isommitted,thenet
class'sownclearancevalueisreturned.Ifanumberisgiven,itmustbebetween0andthe
numberofthisnetclass.
Ifthenamememberreturnsanemptystring,thenetclassisnotdefinedandthereforenot
inusebyanysignalornet.

Example
board(B) {
B.signals(S) {
printf("%-10s %d %s\n", S.name, S.class.number, S.class.name);
}
}

UL_CONTACT
Datamembers
name
string(CONTACT_NAME_LENGTH)
pad
UL_PAD
signal string
smd
UL_SMD
x, y
int(centerpoint,seenote)
SeealsoUL_PACKAGE,UL_PAD,UL_SMD,UL_CONTACTREF,UL_PINREF

Constants
CONTACT_NAME_LENG
TH

max.recommendedlengthofacontactname(usedinformatted
outputonly)

Note
Thesignaldatamemberreturnsthesignalthiscontactisconnectedto(onlyavailablein
aboardcontext).
Thecoordinates(x, y)ofthecontactdependonthecontextinwhichitiscalled:

ifthecontactisderivedfromaUL_LIBRARYcontext,thecoordinatesofthecontact
willbethesameasdefinedinthepackagedrawing
inallothercases,theywillhavetheactualvaluesfromtheboard

Example
library(L) {
L.packages(PAC) {

Page30of132

EAGLEUserLanguage

PAC.contacts(C) {
printf("Contact: '%s', (%d %d)\n",
C.name, C.x, C.y);
}
}

UL_CONTACTREF
Datamembers
contact UL_CONTACT
element UL_ELEMENT
SeealsoUL_SIGNAL,UL_PINREF

Example
board(B) {
B.signals(S) {
printf("Signal '%s'\n", S.name);
S.contactrefs(C) {
printf("\t%s, %s\n", C.element.name, C.contact.name);
}
}
}

UL_DEVICE
Datamembers
area
UL_AREA
description
string
headline
string
library
string
name
string(DEVICE_NAME_LENGTH)
package
UL_PACKAGE
prefix
string(DEVICE_PREFIX_LENGTH)
technologies string(seenote)
value
string("On"or"Off")
Loopmembers
attributes() UL_ATTRIBUTE(seenote)
gates()
UL_GATE
SeealsoUL_DEVICESET,UL_LIBRARY,UL_PART

Constants
max.recommendedlengthofadevicename(usedinformatted
outputonly)
DEVICE_PREFIX_LENG max.recommendedlengthofadeviceprefix(usedinformatted
TH
outputonly)
AllmembersofUL_DEVICE,exceptfornameandtechnologies,returnthesamevalues
DEVICE_NAME_LENGTH

Page31of132

EAGLEUserLanguage
astherespectivemembersoftheUL_DEVICESETinwhichtheUL_DEVICEhasbeen
defined.Whenusingthedescriptiontextkeepinmindthatitmaycontainnewline
characters('\n').

Note
Thevaluereturnedbythetechnologiesmemberdependsonthecontextinwhichitis
called:

ifthedeviceisderivedfromaUL_DEVICESET,technologieswillreturnastring
containingallofthedevice'stechnologies,separatedbyblanks
ifthedeviceisderivedfromaUL_PART,onlytheactualtechnologyusedbythepart
willbereturned.

Theattributes()loopmembertakesanadditionalparameterthatspecifiesforwhich
technologytheattributesshallbedelivered(seethesecondexamplebelow).

Examples
library(L) {
L.devicesets(S) {
S.devices(D) {
printf("Device: %s, Package: %s\n", D.name, D.package.name);
D.gates(G) {
printf("\t%s\n", G.name);
}
}
}
}
library(L) {
L.devicesets(DS) {
DS.devices(D) {
string t[];
int n = strsplit(t, D.technologies, ' ');
for (int i = 0; i < n; i++) {
D.attributes(A, t[i]) {
printf("%s = %s\n", A.name, A.value);
}
}
}
}
}

UL_DEVICESET
Datamembers
area
description
headline
library
name

UL_AREA
string
string(seenote)
string
string(DEVICE_NAME_LENGTH)
Page32of132

EAGLEUserLanguage
prefix
string(DEVICE_PREFIX_LENGTH)
value
string("On"or"Off")
Loopmembers
devices() UL_DEVICE
gates()
UL_GATE
SeealsoUL_DEVICE,UL_LIBRARY,UL_PART

Constants
DEVICE_NAME_LENGTH
DEVICE_PREFIX_LENG
TH

max.recommendedlengthofadevicename(usedinformatted
outputonly)
max.recommendedlengthofadeviceprefix(usedinformatted
outputonly)

Note
Thedescriptionmemberreturnsthecompletedescriptivetextasdefinedwiththe
DESCRIPTIONcommand,whiletheheadlinememberreturnsonlythefirstlineofthe
description,withoutanyHTMLtags.Whenusingthedescriptiontextkeepinmindthat
itmaycontainnewlinecharacters('\n').

Example
library(L) {
L.devicesets(D) {
printf("Device set: %s, Description: %s\n", D.name, D.description);
D.gates(G) {
printf("\t%s\n", G.name);
}
}
}

UL_ELEMENT
Datamembers
angle
attribute[]
column
locked
mirror
name
package
row
smashed
spin
value
x, y
Loopmembers

real(0.0...359.9)
string(seenote)
string(seenote)
int
int
string(ELEMENT_NAME_LENGTH)
UL_PACKAGE
string(seenote)
int(seenote)
int
string(ELEMENT_VALUE_LENGTH)
int(originpoint)

Page33of132

EAGLEUserLanguage
attributes() UL_ATTRIBUTE
texts()
UL_TEXT(seenote)
SeealsoUL_BOARD,UL_CONTACTREF

Constants
ELEMENT_NAME_LENGT
H
ELEMENT_VALUE_LENG
TH

max.recommendedlengthofanelementname(usedin
formattedoutputonly)
max.recommendedlengthofanelementvalue(usedin
formattedoutputonly)

Note
Theattribute[]membercanbeusedtoqueryaUL_ELEMENTforthevalueofagiven
attribute(seethesecondexamplebelow).Thereturnedstringisemptyifthereisno
attributebythegivenname,orifthisattributeisexplicitlyempty.
Thetexts()memberonlyloopsthroughthosetextsoftheelementthathavebeen
detachedusingSMASH,andthroughthevisibletextsofanyattributesassignedtothis
element.Toprocessalltextsofanelement(e.g.whendrawingit),youhavetoloop
throughtheelement'sowntexts()memberaswellasthetexts()memberofthe
element'spackage.
angledefineshowmanydegreestheelementisrotatedcounterclockwisearoundits
origin.
Thecolumn()androw()membersreturnthecolumnandrowlocationwithintheframe
intheboarddrawing.Ifthereisnoframeinthedrawing,ortheelementisplacedoutside
theframe,a'?'(questionmark)isreturned.
Thesmashedmembertellswhethertheelementissmashed.Thisfunctioncanalsobeused
tofindoutwhetherthereisadetachedtextparameterbygivingthenameofthat
parameterinsquarebrackets,asinsmashed["VALUE"].Thisisusefulincaseyouwantto
selectsuchatextwiththeMOVEcommandbydoingMOVE R5>VALUE.Validparameter
namesare"NAME"and"VALUE",aswellasthenamesofanyuserdefinedattributes.They
aretreatedcaseinsensitive,andtheymaybeprecededbya'>'character.

Examples
board(B) {
B.elements(E) {
printf("Element: %s, (%d %d), Package=%s\n",
E.name, E.x, E.y, E.package.name);
}
}
board(B) {
B.elements(E) {
if (E.attribute["REMARK"])
printf("%s: %s\n", E.name, E.attribute("REMARK"));
}
}

Page34of132

EAGLEUserLanguage

UL_FRAME
Datamembers
columns int(-127...127)
rows
int(-26...26)
border
int(FRAME_BORDER_...)
layer
int
x1, y1
int(lowerleftcorner)
x2, y2
int(upperrightcorner)
Loopmembers
texts() UL_TEXT
wires() UL_WIRE
SeealsoUL_BOARD,UL_PACKAGE,UL_SHEET,UL_SYMBOL

Constants
FRAME_BORDER_BOTTOM
FRAME_BORDER_RIGHT
FRAME_BORDER_TOP
FRAME_BORDER_LEFT

bottomborderis
drawn
rightborderisdrawn
topborderisdrawn
leftborderisdrawn

Note
bordercontainsabitwiseor'edvalueconsistingofFRAME_BORDER_...anddefines
whichofthefourbordersareactuallydrawn.
Thetexts()andwires()loopmembersloopthroughallthetextsandwirestheframe
consistsof.

Example
board(B) {
B.frames(F) {
printf("Frame: (%d %d), (%d %d)\n",
F.x1, F.y1, F.x2, F.y2);
}
}

UL_GATE
Datamembers
addlevel
int(GATE_ADDLEVEL_...)
name
string(GATE_NAME_LENGTH)
swaplevel int
symbol
UL_SYMBOL
x, y
int(originpoint,seenote)
SeealsoUL_DEVICE

Page35of132

EAGLEUserLanguage

Constants
GATE_ADDLEVEL_MUST
must
GATE_ADDLEVEL_CAN
can
GATE_ADDLEVEL_NEXT
next
GATE_ADDLEVEL_REQUEST request
GATE_ADDLEVEL_ALWAYS
always
GATE_NAME_LENGT
max.recommendedlengthofagatename(usedinformatted
H
outputonly)

Note
Thecoordinatesoftheoriginpoint(x,y)arealwaysthoseofthegate'spositionwithinthe
device,eveniftheUL_GATEhasbeenderivedfromaUL_INSTANCE.

Example
library(L) {
L.devices(D) {
printf("Device: %s, Package: %s\n", D.name, D.package.name);
D.gates(G) {
printf("\t%s, swaplevel=%d, symbol=%s\n",
G.name, G.swaplevel, G.symbol.name);
}
}
}

UL_GRID
Datamembers
distance real
dots
int(0=lines,1=dots)
multiple int
on
int(0=off,1=on)
unit
int(GRID_UNIT_...)
unitdist int(GRID_UNIT_...)
SeealsoUL_BOARD,UL_LIBRARY,UL_SCHEMATIC,UnitConversions

Constants
GRID_UNIT_MIC
GRID_UNIT_MM
GRID_UNIT_MIL
GRID_UNIT_INCH

microns
millimeter
mil
inch

Note
unitdistreturnsthegridunitthatwassettodefinetheactualgridsize(returnedby
distance),whileunitreturnsthegridunitthatisusedtodisplayvaluesorinterpret
userinput.
Page36of132

EAGLEUserLanguage

Example
board(B) {
printf("Gridsize=%f\n", B.grid.distance);
}

UL_HOLE
Datamembers
diameter[layer] int(seenote)
drill
int
drillsymbol
int
x, y
int(centerpoint)
SeealsoUL_BOARD,UL_PACKAGE

Note
diameter[]isonlydefinedvorlayersLAYER_TSTOPandLAYER_BSTOPandreturnsthe
diameterofthesolderstopmaskinthegivenlayer.
drillsymbolreturnsthenumberofthedrillsymbolthathasbeenassignedtothisdrill
diameter(seethemanualforalistofdefineddrillsymbols).Avalueof0meansthatno
symbolhasbeenassignedtothisdrilldiameter.

Example
board(B) {
B.holes(H) {
printf("Hole: (%d %d), drill=%d\n",
H.x, H.y, H.drill);
}
}

UL_INSTANCE
Datamembers
angle
real(0,90,180and270)
column
string(seenote)
gate
UL_GATE
mirror
int
name
string(INSTANCE_NAME_LENGTH)
row
string(seenote)
sheet
int(0=unused,>0=sheetnumber)
smashed int(seenote)
value
string(PART_VALUE_LENGTH)
x, y
int(originpoint)
Loopmembers
attributes() UL_ATTRIBUTE(seenote)
Page37of132

EAGLEUserLanguage
texts()
UL_TEXT(seenote)
xrefs()
UL_GATE(seenote)
SeealsoUL_PART,UL_PINREF

Constants
INSTANCE_NAME_LEN
GTH
PART_VALUE_LENGTH

max.recommendedlengthofaninstancename(usedin
formattedoutputonly)
max.recommendedlengthofapartvalue(instancesdonothave
avalueoftheirown!)

Note
Theattributes()memberonlyloopsthroughthoseattributesthathavebeenexplicitly
assignedtothisinstance(includingsmashedattributes).
Thetexts()memberonlyloopsthroughthosetextsoftheinstancethathavebeen
detachedusingSMASH,andthroughthevisibletextsofanyattributesassignedtothis
instance.Toprocessalltextsofaninstance,youhavetoloopthroughtheinstance'sown
texts()memberaswellasthetexts()memberoftheinstance'sgate'ssymbol.If
attributeshavebeenassignedtoaninstance,texts()deliverstheirtextsintheformas
theyarecurrentlyvisible.
Thecolumn()androw()membersreturnthecolumnandrowlocationwithintheframe
onthesheetonwhichthisinstanceisinvoked.Ifthereisnoframeonthatsheet,orthe
instanceisplacedoutsidetheframe,a'?'(questionmark)isreturned.Thesemembers
canonlybeusedinasheetcontext.
Thesmashedmembertellswhethertheinstanceissmashed.Thisfunctioncanalsobe
usedtofindoutwhetherthereisadetachedtextparameterbygivingthenameofthat
parameterinsquarebrackets,asinsmashed["VALUE"].Thisisusefulincaseyouwantto
selectsuchatextwiththeMOVEcommandbydoingMOVE R5>VALUE.Validparameter
namesare"NAME","VALUE","PART"and"GATE",aswellasthenamesofanyuserdefined
attributes.Theyaretreatedcaseinsensitive,andtheymaybeprecededbya'>'character.
Thexrefs()memberloopsthroughthecontactcrossreferencegatesofthisinstance.
TheseareonlyofimportanceiftheULPisgoingtocreateadrawingofsomesort(for
instanceaDXFfile).

Example
schematic(S) {
S.parts(P) {
printf("Part: %s\n", P.name);
P.instances(I) {
if (I.sheet != 0)
printf("\t%s used on sheet %d\n", I.name, I.sheet);
}
}
}

Page38of132

EAGLEUserLanguage

UL_JUNCTION
Datamembers
diameter int
x, y
int(centerpoint)
SeealsoUL_SEGMENT

Example
schematic(SCH) {
SCH.sheets(SH) {
SH.nets(N) {
N.segments(SEG) {
SEG.junctions(J) {
printf("Junction: (%d %d)\n", J.x, J.y);
}
}
}
}
}

UL_LABEL
Datamembers
angle
layer
mirror
spin
text
x, y
xref

real(0.0...359.9)
int
int
int
UL_TEXT
int(originpoint)
int(0=plain,1=cross
reference)

Loopmembers
wires() UL_WIRE(seenote)
SeealsoUL_SEGMENT

Note
Ifxrefreturnsanonzerovalue,thewires()loopmemberloopsthroughthewiresthat
formtheflagofacrossreferencelabel.Otherwiseitisanemptyloop.
Theangle,layer,mirrorandspinmembersalwaysreturnthesamevaluesasthoseof
theUL_TEXTobjectreturnedbythetextmember.Thexandymembersofthetextreturn
slightlyoffsetvaluesforcrossreferencelabels(nonzeroxref),otherwisetheyalsoreturn
thesamevaluesastheUL_LABEL.
xrefisonlymeaningfulfornetlabels.Forbuslabelsitalwaysreturns0.

Page39of132

EAGLEUserLanguage

Example
sheet(SH) {
SH.nets(N) {
N.segments(S) {
S.labels(L) {
printf("Label: %d %d '%s'\n", L.x, L.y, L.text.value);
}
}
}
}

UL_LAYER
Datamembers
color
int
fill
int
name
string(LAYER_NAME_LENGTH)
number
int
used
int(0=unused,1=used)
visible int(0=off,1=on)
SeealsoUL_BOARD,UL_LIBRARY,UL_SCHEMATIC

Constants
LAYER_NAME_LENGT
H
LAYER_TOP
LAYER_BOTTOM
LAYER_PADS
LAYER_VIAS
LAYER_UNROUTED
LAYER_DIMENSION
LAYER_TPLACE
LAYER_BPLACE
LAYER_TORIGINS
LAYER_BORIGINS
LAYER_TNAMES
LAYER_BNAMES
LAYER_TVALUES
LAYER_BVALUES
LAYER_TSTOP
LAYER_BSTOP
LAYER_TCREAM
LAYER_BCREAM
LAYER_TFINISH
LAYER_BFINISH

max.recommendedlengthofalayername(usedinformatted
outputonly)
layernumbers

Page40of132

EAGLEUserLanguage
LAYER_TGLUE
LAYER_BGLUE
LAYER_TTEST
LAYER_BTEST
LAYER_TKEEPOUT
LAYER_BKEEPOUT
LAYER_TRESTRICT
LAYER_BRESTRICT
LAYER_VRESTRICT
LAYER_DRILLS
LAYER_HOLES
LAYER_MILLING
LAYER_MEASURES
LAYER_DOCUMENT
LAYER_REFERENCE
LAYER_TDOCU
LAYER_BDOCU
LAYER_NETS
LAYER_BUSSES
LAYER_PINS
LAYER_SYMBOLS
LAYER_NAMES
LAYER_VALUES
LAYER_USER

lowestnumberforuserdefinedlayers(100)

Example
board(B) {
B.layers(L) printf("Layer %3d %s\n", L.number, L.name);
}

UL_LIBRARY
Datamembers
description string(seenote)
grid
UL_GRID
headline
string
name
string(LIBRARY_NAME_LENGTH,seenote)
Loopmembers
devices()
UL_DEVICE
devicesets() UL_DEVICESET
layers()
UL_LAYER
packages()
UL_PACKAGE
symbols()
UL_SYMBOL
SeealsoUL_BOARD,UL_SCHEMATIC

Page41of132

EAGLEUserLanguage

Constants
LIBRARY_NAME_LENG max.recommendedlengthofalibraryname(usedinformatted
TH
outputonly)
Thedevices()memberloopsthroughallthepackagevariantsandtechnologiesofall
UL_DEVICESETsinthelibrary,thusresultinginalltheactualdevicevariationsavailable.
Thedevicesets()memberonlyloopsthroughtheUL_DEVICESETs,whichinturncan
bequeriedfortheirUL_DEVICEmembers.

Note
Thedescriptionmemberreturnsthecompletedescriptivetextasdefinedwiththe
DESCRIPTIONcommand,whiletheheadlinememberreturnsonlythefirstlineofthe
description,withoutanyHTMLtags.Whenusingthedescriptiontextkeepinmindthat
itmaycontainnewlinecharacters('\n').Thedescriptionandheadlineinformation
isonlyavailablewithinalibrarydrawing,notifthelibraryisderivedformaUL_BOARDor
UL_SCHEMATICcontext.
IfthelibraryisderivedformaUL_BOARDorUL_SCHEMATICcontext,namereturnsthe
purelibraryname(withoutpathorextension).Otherwiseitreturnsthefulllibraryfile
name.

Example
library(L) {
L.devices(D)
printf("Dev: %s\n", D.name);
L.devicesets(D) printf("Dev: %s\n", D.name);
L.packages(P)
printf("Pac: %s\n", P.name);
L.symbols(S)
printf("Sym: %s\n", S.name);
}
schematic(S) {
S.libraries(L) printf("Library: %s\n", L.name);
}

UL_NET
Datamembers
class
UL_CLASS
column string(seenote)
name
string(NET_NAME_LENGTH)
row
string(seenote)
Loopmembers
pinrefs()
UL_PINREF(seenote)
segments() UL_SEGMENT(seenote)
SeealsoUL_SHEET,UL_SCHEMATIC

Constants
NET_NAME_LENGTH

max.recommendedlengthofanetname(usedinformattedoutput
Page42of132

EAGLEUserLanguage
only)

Note
Thepinrefs()loopmembercanonlybeusedifthenetisinaschematiccontext.
Thesegments()loopmembercanonlybeusedifthenetisinasheetcontext.
Thecolumn()androw()membersreturnthecolumnandrowlocationswithintheframe
onthesheetonwhichthisnetisdrawn.Sinceanetcanextendoveracertainarea,eachof
thesefunctionsreturnstwovalues,separatedbyablank.Incaseofcolumn()theseare
theleftandrightmostcolumnstouchedbythenet,andincaseofrow()it'sthetopand
bottommostrow.Ifthereisnoframeonthatsheet,"? ?"(twoquestionmarks)is
returned.Ifanypartofthenetisplacedoutsidetheframe,eitherofthevaluesmaybe'?'
(questionmark).Thesememberscanonlybeusedinasheetcontext.

Example
schematic(S) {
S.nets(N) {
printf("Net: %s\n", N.name);
// N.segments(SEG) will NOT work here!
}
}
schematic(S) {
S.sheets(SH) {
SH.nets(N) {
printf("Net: %s\n", N.name);
N.segments(SEG) {
SEG.wires(W) {
printf("\tWire: (%d %d) (%d %d)\n",
W.x1, W.y1, W.x2, W.y2);
}
}
}
}
}

UL_PACKAGE
Datamembers
area
description
headline
library
name
Loopmembers
circles()
contacts()
frames()
holes()
polygons()

UL_AREA
string
string
string
string(PACKAGE_NAME_LENGTH)
UL_CIRCLE
UL_CONTACT
UL_FRAME
UL_HOLE
UL_POLYGON
Page43of132

EAGLEUserLanguage
rectangles() UL_RECTANGLE
texts()
UL_TEXT(seenote)
wires()
UL_WIRE
SeealsoUL_DEVICE,UL_ELEMENT,UL_LIBRARY

Constants
PACKAGE_NAME_LENG
TH

max.recommendedlengthofapackagename(usedinformatted
outputonly)

Note
Thedescriptionmemberreturnsthecompletedescriptivetextasdefinedwiththe
DESCRIPTIONcommand,whiletheheadlinememberreturnsonlythefirstlineofthe
description,withoutanyHTMLtags.Whenusingthedescriptiontextkeepinmindthat
itmaycontainnewlinecharacters('\n').
IftheUL_PACKAGEisderivedfromaUL_ELEMENT,thetexts()memberonlyloops
throughthenondetachedtextsofthatelement.

Example
library(L) {
L.packages(PAC) {
printf("Package: %s\n", PAC.name);
PAC.contacts(C) {
if (C.pad)
printf("\tPad: %s, (%d %d)\n",
C.name, C.pad.x, C.pad.y);
else if (C.smd)
printf("\tSmd: %s, (%d %d)\n",
C.name, C.smd.x, C.smd.y);
}
}
}
board(B) {
B.elements(E) {
printf("Element: %s, Package: %s\n", E.name, E.package.name);
}
}

UL_PAD
Datamembers
angle
diameter[layer]
drill
drillsymbol
elongation
flags
name

real(0.0...359.9)
int
int
int
int
int(PAD_FLAG_...)
string(PAD_NAME_LENGTH)
Page44of132

EAGLEUserLanguage
shape[layer]
int(PAD_SHAPE_...)
signal
string
x, y
int(centerpoint,seenote)
SeealsoUL_PACKAGE,UL_CONTACT,UL_SMD

Constants
generatestopmask
generatethermals
usespecial"firstpad"
PAD_FLAG_FIRST
shape
PAD_SHAPE_SQUARE
square
PAD_SHAPE_ROUND
round
PAD_SHAPE_OCTAGON octagon
PAD_SHAPE_LONG
long
PAD_SHAPE_OFFSET
offset
annulus(onlyifsupplylayersare
PAD_SHAPE_ANNULUS
used)
thermal(onlyifsupplylayersare
PAD_SHAPE_THERMAL
used)
PAD_NAME_LENGT max.recommendedlengthofapadname(sameas
H
CONTACT_NAME_LENGTH)
PAD_FLAG_STOP
PAD_FLAG_THERMALS

Note
Theparametersofthepaddependonthecontextinwhichitisaccessed:

ifthepadisderivedfromaUL_LIBRARYcontext,thecoordinates(x, y)andangle
willbethesameasdefinedinthepackagedrawing
inallothercases,theywillhavetheactualvaluesfromtheboard

Thediameterandshapeofthepaddependonthelayerforwhichtheyshallberetrieved,
becausetheymaybedifferentineachlayerdependingontheDesignRules.Ifoneofthe
layersLAYER_TOP...LAYER_BOTTOM,LAYER_TSTOPorLAYER_BSTOPisgivenasthe
indextothediameterorshapedatamember,theresultingvaluewillbecalculated
accordingtotheDesignRules.IfLAYER_PADSisgiven,therawvalueasdefinedinthe
librarywillbereturned.
drillsymbolreturnsthenumberofthedrillsymbolthathasbeenassignedtothisdrill
diameter(seethemanualforalistofdefineddrillsymbols).Avalueof0meansthatno
symbolhasbeenassignedtothisdrilldiameter.
angledefineshowmanydegreesthepadisrotatedcounterclockwisearounditscenter.
elongationisonlyvalidforshapesPAD_SHAPE_LONGandPAD_SHAPE_OFFSETand
defineshowmanypercentthelongsideofsuchapadislongerthanitssmallside.This
memberreturns0foranyotherpadshapes.
ThevaluereturnedbyflagsmustbemaskedwiththePAD_FLAG_...constantsto
determinetheindividualflagsettings,asin
Page45of132

EAGLEUserLanguage
if (pad.flags & PAD_FLAG_STOP) {
...
}

NotethatifyourULPjustwantstodrawtheobjects,youdon'tneedtochecktheseflags
explicitly.Thediameter[]andshape[]memberswillreturntheproperdata;for
instance,ifPAD_FLAG_STOPisset,diameter[LAYER_TSTOP]willreturn0,which
shouldresultinnothingbeingdrawninthatlayer.TheflagsmemberismainlyforULPs
thatwanttocreatescriptfilesthatcreatelibraryobjects.

Example
library(L) {
L.packages(PAC) {
PAC.contacts(C) {
if (C.pad)
printf("Pad: '%s', (%d %d), d=%d\n",
C.name, C.pad.x, C.pad.y, C.pad.diameter[LAYER_BOTTOM]);
}
}
}

UL_PART
Datamembers
attribute[] string(seenote)
device
UL_DEVICE
deviceset
UL_DEVICESET
name
string(PART_NAME_LENGTH)
value
string(PART_VALUE_LENGTH)
Loopmembers
attributes() UL_ATTRIBUTE(seenote)
instances()
UL_INSTANCE(seenote)
SeealsoUL_SCHEMATIC,UL_SHEET

Constants
PART_NAME_LENGTH
PART_VALUE_LENGT
H

max.recommendedlengthofapartname(usedinformatted
outputonly)
max.recommendedlengthofapartvalue(usedinformatted
outputonly)

Note
Theattribute[]membercanbeusedtoqueryaUL_PARTforthevalueofagiven
attribute(seethesecondexamplebelow).Thereturnedstringisemptyifthereisno
attributebythegivenname,orifthisattributeisexplicitlyempty.
Whenloopingthroughtheattributes()ofaUL_PART,onlythename,value,
defaultvalueandconstantmembersoftheresultingUL_ATTRIBUTEobjectsare
Page46of132

EAGLEUserLanguage
valid.
Ifthepartisinasheetcontext,theinstances()loopmemberloopsonlythroughthose
instancesthatareactuallyusedonthatsheet.Ifthepartisinaschematiccontext,all
instancesareloopedthrough.

Example
schematic(S) {
S.parts(P) printf("Part: %s\n", P.name);
}
schematic(SCH) {
SCH.parts(P) {
if (P.attribute["REMARK"])
printf("%s: %s\n", P.name, P.attribute["REMARK"]);
}
}

UL_PIN
Datamembers
angle
real(0,90,180and270)
contact
UL_CONTACT(seenote)
direction int(PIN_DIRECTION_...)
function
int(PIN_FUNCTION_FLAG_...)
length
int(PIN_LENGTH_...)
name
string(PIN_NAME_LENGTH)
net
string(seenote)
swaplevel int
visible
int(PIN_VISIBLE_FLAG_...)
x, y
int(connectionpoint)
Loopmembers
circles() UL_CIRCLE
texts()
UL_TEXT
wires()
UL_WIRE
SeealsoUL_SYMBOL,UL_PINREF,UL_CONTACTREF

Constants
PIN_DIRECTION_NC
PIN_DIRECTION_IN
PIN_DIRECTION_OUT
PIN_DIRECTION_IO
PIN_DIRECTION_OC
PIN_DIRECTION_PWR
PIN_DIRECTION_PAS
PIN_DIRECTION_HIZ

notconnected
input
output(totempole)
in/output(bidirectional)
opencollector
powerinputpin
passive
highimpedanceoutput
Page47of132

EAGLEUserLanguage
PIN_DIRECTION_SUP supplypin
PIN_FUNCTION_FLAG_NONE nosymbol
PIN_FUNCTION_FLAG_DOT
invertersymbol
PIN_FUNCTION_FLAG_CLK
clocksymbol
PIN_LENGTH_POINT
nowire
PIN_LENGTH_SHORT
0.1inchwire
PIN_LENGTH_MIDDLE 0.2inchwire
PIN_LENGTH_LONG
0.3inchwire
max.recommendedlengthofapinname(usedinformattedoutput
PIN_NAME_LENGTH
only)
PIN_VISIBLE_FLAG_OFF nonamedrawn
PIN_VISIBLE_FLAG_PAD padnamedrawn
PIN_VISIBLE_FLAG_PIN pinnamedrawn

Note
Thecontactdatamemberreturnsthecontactthathasbeenassignedtothepinthrougha
CONNECTcommand.Itcanbeusedasabooleanfunctiontocheckwhetheracontacthas
beenassignedtoapin(seeexamplebelow).
Thecoordinates(andlayer,incaseofanSMD)ofthecontactreturnedbythecontact
datamemberdependonthecontextinwhichitiscalled:

ifthepinisderivedfromaUL_PARTthatisusedonasheet,andifthereisa
correspondingelementontheboard,theresultingcontactwillhavethecoordinates
asusedontheboard
inallothercases,thecoordinatesofthecontactwillbethesameasdefinedinthe
packagedrawing

Thenamedatamemberalwaysreturnsthenameofthepinasitwasdefinedinthelibrary,
withany'@'characterforpinswiththesamenameleftintact(seethePINcommandfor
details).
Thetextsloopmember,ontheotherhand,returnsthepinname(ifitisvisible)inthe
samewayasitisdisplayedinthecurrentdrawingtype.
Thenetdatamemberreturnsthenameofthenettowhichthispinisconnected(only
availableinaschematiccontext).

Example
library(L) {
L.symbols(S) {
printf("Symbol: %s\n", S.name);
S.pins(P) {
printf("\tPin: %s, (%d %d)", P.name, P.x, P.y);
if (P.direction == PIN_DIRECTION_IN)
printf(" input");
if ((P.function & PIN_FUNCTION_FLAG_DOT) != 0)
printf(" inverted");
printf("\n");
}

Page48of132

EAGLEUserLanguage
}
L.devices(D) {
D.gates(G) {
G.symbol.pins(P) {
if (!P.contact)
printf("Unconnected pin: %s/%s/%s\n", D.name, G.name, P.name);
}
}
}
}

UL_PINREF
Datamembers
instance UL_INSTANCE
part
UL_PART
pin
UL_PIN
SeealsoUL_SEGMENT,UL_CONTACTREF

Example
schematic(SCH) {
SCH.sheets(SH) {
printf("Sheet: %d\n", SH.number);
SH.nets(N) {
printf("\tNet: %s\n", N.name);
N.segments(SEG) {
SEG.pinrefs(P) {
printf("connected to: %s, %s, %s\n",
P.part.name, P.instance.name, P.pin.name);
}
}
}
}
}

UL_POLYGON
Datamembers
isolate
int
layer
int
orphans
int(0=off,1=on)
pour
int(POLYGON_POUR_...)
rank
int
spacing
int
thermals int(0=off,1=on)
width
int
Loopmembers
contours() UL_WIRE(seenote)
fillings() UL_WIRE
Page49of132

EAGLEUserLanguage
wires()
UL_WIRE
SeealsoUL_BOARD,UL_PACKAGE,UL_SHEET,UL_SIGNAL,UL_SYMBOL

Constants
POLYGON_POUR_SOLID
POLYGON_POUR_HATCH

solid
hatch

Note
Thecontours()andfillings()loopmembersloopthroughthewiresthatareusedto
drawthecalculatedpolygonifitispartofasignalandthepolygonhasbeencalculatedby
theRATSNESTcommand.Thewires()loopmemberalwaysloopsthroughthepolygon
wiresastheyweredrawnbytheuser.Foranuncalculatedsignalpolygoncontours()
doesthesameaswires(),andfillings()doesnothing.
Ifthecontours()loopmemberiscalledwithoutasecondparameter,itloopsthroughall
ofthecontourwires,regardlesswhethertheybelongtoapositiveoranegativepolygon.If
youareinterestedingettingthepositiveandnegativecontourwiresseparately,youcancall
contours()withanadditionalintegerparameter(seethesecondexamplebelow).The
signofthatparameterdetermineswhetherapositiveoranegativepolygonwillbehandled,
andthevalueindicatestheindexofthatpolygon.Ifthereisnopolygonwiththegiven
index,thestatementwillnotbeexecuted.Anotheradvantageofthismethodisthatyou
don'tneedtodeterminethebeginningandendofaparticularpolygonyourself(by
comparingcoordinates).Foranygivenindex,thestatementwillbeexecutedforallthe
wiresofthatpolygon.Withthesecondparameter0thebehavioristhesameaswithouta
secondparameter.

Polygon width
Whenusingthefillings()loopmembertogetthefillwiresofasolidpolygon,make
surethewidthofthepolygonisnotzero(actuallyitshouldbequiteabitlargerthanzero,
forexampleatleastthehardwareresolutionoftheoutputdeviceyouaregoingtodraw
on).Fillingapolygonwithzerowidthmayresultinenormousamountsofdata,since
itwillbecalculatedwiththesmallesteditorresolutionof1/10000mm!

Partial polygons
Acalculatedsignalpolygonmayconsistofseveraldistinctparts(calledpositivepolygons),
eachofwhichcancontainextrusions(negativepolygons)resultingfromotherobjectsbeing
subtractedfromthepolygon.Negativepolygonscanagaincontainotherpositivepolygons
andsoon.
Thewiresloopedthroughbycontours()alwaysstartwithapositivepolygon.Tofindout
whereonepartialpolygonendsandthenextonebegins,simplystorethe(x1,y1)
coordinatesofthefirstwireandcheckthemagainst(x2,y2)ofeveryfollowingwire.As
soonastheseareequal,thelastwireofapartialpolygonhasbeenfound.Itisalso
guaranteedthatthesecondpoint(x2,y2)ofonewireisidenticaltothefirstpoint(x1,y1)of
thenextwireinthatpartialpolygon.
Page50of132

EAGLEUserLanguage
Tofindoutwherethe"inside"andthe"outside"ofthepolygonlays,takeanycontourwire
andimaginelookingfromitspoint(x1,y1)to(x2,y2).The"inside"ofthepolygonisalways
ontherightsideofthewire.Notethatifyousimplywanttodrawthepolygonyouwon't
needallthesedetails.

Example
board(B) {
B.signals(S) {
S.polygons(P) {
int x0, y0, first = 1;
P.contours(W) {
if (first) {
// a new partial polygon is starting
x0 = W.x1;
y0 = W.y1;
}
// ...
// do something with the wire
// ...
if (first)
first = 0;
else if (W.x2 == x0 && W.y2 == y0) {
// this was the last wire of the partial polygon,
// so the next wire (if any) will be the first wire
// of the next partial polygon
first = 1;
}
}
}
}
}
board(B) {
B.signals(S) {
S.polygons(P) {
// handle only the "positive" polygons:
int i = 1;
int active;
do {
active = 0;
P.contours(W, i) {
active = 1;
// do something with the wire
}
i++;
} while (active);
}
}
}

UL_RECTANGLE
Datamembers
angle
real(0.0...359.9)
Page51of132

EAGLEUserLanguage
int
int(lowerleftcorner)
int(upperright
x2, y2
corner)
SeealsoUL_BOARD,UL_PACKAGE,UL_SHEET,UL_SYMBOL
layer
x1, y1

angledefineshowmanydegreestherectangleisrotatedcounterclockwisearoundits
center.Thecentercoordinatesaregivenby(x1+x2)/2and(y1+y2)/2.

Example
board(B) {
B.rectangles(R) {
printf("Rectangle: (%d %d), (%d %d)\n",
R.x1, R.y1, R.x2, R.y2);
}
}

UL_SCHEMATIC
Datamembers
grid
UL_GRID
name
string
xreflabel string
Loopmembers
attributes() UL_ATTRIBUTE(seenote)
classes()
UL_CLASS
layers()
UL_LAYER
libraries()
UL_LIBRARY
nets()
UL_NET
parts()
UL_PART
sheets()
UL_SHEET
SeealsoUL_BOARD,UL_LIBRARY

Note
Thexreflabelmemberreturnstheformatstringusedtodisplaycrossreferencelabels.
Theattributes()loopmemberloopsthroughtheglobalattributes.

Example
schematic(S) {
S.parts(P) printf("Part: %s\n", P.name);
}

UL_SEGMENT
Loopmembers
Page52of132

EAGLEUserLanguage
junctions() UL_JUNCTION(seenote)
labels()
UL_LABEL
pinrefs()
UL_PINREF(seenote)
texts()
UL_TEXT(deprecated,seenote)
wires()
UL_WIRE
SeealsoUL_BUS,UL_NET

Note
Thejunctions()andpinrefs()loopmembersareonlyavailablefornetsegments.
Thetexts()loopmemberwasusedinolderEAGLEversionstoloopthroughthelabelsof
asegment,andisonlypresentforcompatibility.Itwillnotdeliverthetextofcross
referencelabelsatthecorrectposition.Usethelabels()loopmembertoaccessa
segment'slabels.

Example
schematic(SCH) {
SCH.sheets(SH) {
printf("Sheet: %d\n", SH.number);
SH.nets(N) {
printf("\tNet: %s\n", N.name);
N.segments(SEG) {
SEG.pinrefs(P) {
printf("connected to: %s, %s, %s\n",
P.part.name, P.instance.name, P.pin.name);
}
}
}
}
}

UL_SHEET
Datamembers
area
UL_AREA
number int
Loopmembers
busses()
UL_BUS
circles()
UL_CIRCLE
frames()
UL_FRAME
nets()
UL_NET
parts()
UL_PART
polygons()
UL_POLYGON
rectangles() UL_RECTANGLE
texts()
UL_TEXT
wires()
UL_WIRE
SeealsoUL_SCHEMATIC
Page53of132

EAGLEUserLanguage

Example
schematic(SCH) {
SCH.sheets(S) {
printf("Sheet: %d\n", S.number);
}
}

UL_SIGNAL
Datamembers
airwireshidden
class
name
Loopmembers
contactrefs()
polygons()
vias()
wires()
SeealsoUL_BOARD

int
UL_CLASS
string(SIGNAL_NAME_LENGTH)
UL_CONTACTREF
UL_POLYGON
UL_VIA
UL_WIRE

Constants
SIGNAL_NAME_LENG
TH

max.recommendedlengthofasignalname(usedinformatted
outputonly)

Example
board(B) {
B.signals(S) printf("Signal: %s\n", S.name);
}

UL_SMD
Datamembers
angle
real(0.0...359.9)
dx[layer], dy[layer]
int(size)
flags
int(SMD_FLAG_...)
layer
int(seenote)
name
string(SMD_NAME_LENGTH)
roundness
int(seenote)
signal
string
x, y
int(centerpoint,seenote)
SeealsoUL_PACKAGE,UL_CONTACT,UL_PAD

Constants
SMD_FLAG_STOP
SMD_FLAG_THERMALS

generatestopmask
generatethermals
Page54of132

EAGLEUserLanguage
SMD_FLAG_CREAM
SMD_NAME_LENGT
H

generatecream
mask
max.recommendedlengthofansmdname(sameas
CONTACT_NAME_LENGTH)

Note
Theparametersofthesmddependonthecontextinwhichitisaccessed:

ifthesmdisderivedfromaUL_LIBRARYcontext,thecoordinates(x, y),angle,
layerandroundnessofthesmdwillbethesameasdefinedinthepackage
drawing
inallothercases,theywillhavetheactualvaluesfromtheboard

Ifthedxanddydatamembersarecalledwithanoptionallayerindex,thedataforthat
layerisreturnedaccordingtotheDesignRules.ValidlayersareLAYER_TOP,LAYER_TSTOP
andLAYER_TCREAMforaviaintheToplayer,andLAYER_BOTTOM,LAYER_BSTOPand
LAYER_BCREAMforaviaintheBottomlayer,respectively.
angledefineshowmanydegreesthesmdisrotatedcounterclockwisearounditscenter.
ThevaluereturnedbyflagsmustbemaskedwiththeSMD_FLAG_...constantsto
determinetheindividualflagsettings,asin
if (smd.flags & SMD_FLAG_STOP) {
...
}

NotethatifyourULPjustwantstodrawtheobjects,youdon'tneedtochecktheseflags
explicitly.Thedx[]anddy[]memberswillreturntheproperdata;forinstance,if
SMD_FLAG_STOPisset,dx[LAYER_TSTOP]willreturn0,whichshouldresultinnothing
beingdrawninthatlayer.TheflagsmemberismainlyforULPsthatwanttocreatescript
filesthatcreatelibraryobjects.

Example
library(L) {
L.packages(PAC) {
PAC.contacts(C) {
if (C.smd)
printf("Smd: '%s', (%d %d), dx=%d, dy=%d\n",
C.name, C.smd.x, C.smd.y, C.smd.dx, C.smd.dy);
}
}
}

UL_SYMBOL
Datamembers
area
library
name

UL_AREA
string
string(SYMBOL_NAME_LENGTH)
Page55of132

EAGLEUserLanguage
Loopmembers
circles()
UL_CIRCLE
frames()
UL_FRAME
rectangles() UL_RECTANGLE
pins()
UL_PIN
polygons()
UL_POLYGON
texts()
UL_TEXT(seenote)
wires()
UL_WIRE
SeealsoUL_GATE,UL_LIBRARY

Constants
SYMBOL_NAME_LENG
TH

max.recommendedlengthofasymbolname(usedinformatted
outputonly)

Note
IftheUL_SYMBOLisderivedfromaUL_INSTANCE,thetexts()memberonlyloops
throughthenondetachedtextsofthatinstance.

Example
library(L) {
L.symbols(S) printf("Sym: %s\n", S.name);
}

UL_TEXT
Datamembers
angle
real(0.0...359.9)
font
int(FONT_...)
layer
int
mirror int
ratio
int
size
int
spin
int
value
string
x, y
int(originpoint)
Loopmembers
wires() UL_WIRE(seenote)
SeealsoUL_BOARD,UL_PACKAGE,UL_SHEET,UL_SYMBOL

Constants
FONT_VECTOR
FONT_PROPORTIONAL
FONT_FIXED

vectorfont
proportionalfont
fixedfont
Page56of132

EAGLEUserLanguage

Note
Thewires()loopmemberalwaysaccessestheindividualwiresthetextiscomposedof
whenusingthevectorfont,eveniftheactualfontisnotFONT_VECTOR.
IftheUL_TEXTisderivedfromaUL_ELEMENTorUL_INSTANCEcontext,themember
valueswillbethoseoftheactualtextaslocatedintheboardorsheetdrawing.

Example
board(B) {
B.texts(T) {
printf("Text: %s\n", T.value);
}
}

UL_VIA
Datamembers
diameter[layer]
drill
drillsymbol
end
flags
shape[layer]
start
x, y
SeealsoUL_SIGNAL

int
int
int
int
int(VIA_FLAG_...)
int(VIA_SHAPE_...)
int
int(centerpoint)

Constants
alwaysgeneratestop
mask
VIA_SHAPE_SQUARE
square
VIA_SHAPE_ROUND
round
VIA_SHAPE_OCTAGON octagon
VIA_SHAPE_ANNULUS annulus
VIA_SHAPE_THERMAL thermal
VIA_FLAG_STOP

Note
Thediameterandshapeoftheviadependonthelayerforwhichtheyshallberetrieved,
becausetheymaybedifferentineachlayerdependingontheDesignRules.Ifoneofthe
layersLAYER_TOP...LAYER_BOTTOM,LAYER_TSTOPorLAYER_BSTOPisgivenasthe
indextothediameterorshapedatamember,theresultingvaluewillbecalculated
accordingtotheDesignRules.IfLAYER_VIASisgiven,therawvalueasdefinedinthevia
willbereturned.
Notethatdiameterandshapewillalwaysreturnthediameterorshapethataviawould
Page57of132

EAGLEUserLanguage
haveinthegivenlayer,evenifthatparticularviadoesn'tcoverthatlayer(orifthatlayer
isn'tusedinthelayersetupatall).
startandendreturnthelayernumbersinwhichthatviastartsandends.Thevalueof
startwillalwaysbelessthanthatofend.
drillsymbolreturnsthenumberofthedrillsymbolthathasbeenassignedtothisdrill
diameter(seethemanualforalistofdefineddrillsymbols).Avalueof0meansthatno
symbolhasbeenassignedtothisdrilldiameter.

Example
board(B) {
B.signals(S) {
S.vias(V) {
printf("Via: (%d %d)\n", V.x, V.y);
}
}
}

UL_WIRE
Datamembers
arc
UL_ARC
cap
int(CAP_...)
curve
real
layer
int
style
int(WIRE_STYLE_...)
width
int
x1, y1 int(startingpoint)
x2, y2 int(endpoint)
Loopmembers
pieces() UL_WIRE(seenote)
SeealsoUL_BOARD,UL_PACKAGE,UL_SEGMENT,UL_SHEET,UL_SIGNAL,UL_SYMBOL,
UL_ARC

Constants
CAP_FLAT
CAP_ROUND
WIRE_STYLE_CONTINUOUS
WIRE_STYLE_LONGDASH
WIRE_STYLE_SHORTDASH
WIRE_STYLE_DASHDOT

flatarcends
roundarc
ends
continuous
longdash
shortdash
dashdot

Wire Style
AUL_WIREthathasastyleotherthanWIRE_STYLE_CONTINUOUScanusethepieces()
Page58of132

EAGLEUserLanguage
loopmembertoaccesstheindividualsegmentsthatconstituteforexampleadashedwire.
Ifpieces()iscalledforaUL_WIREwithWIRE_STYLE_CONTINUOUS,asinglesegment
willbeaccessiblewhichisjustthesameastheoriginalUL_WIRE.Thepieces()loop
membercan'tbecalledfromaUL_WIREthatitselfhasbeenreturnedbyacallto
pieces()(thiswouldcauseaninfiniterecursion).

Arcs at Wire level


Arcsarebasicallywires,withafewadditionalproperties.Atthefirstlevelarcsaretreated
exactlythesameaswires,meaningtheyhaveastartandanendpoint,awidth,layerand
wirestyle.Inadditiontotheseanarc,atthewirelevel,hasacapandacurveparameter.
capdefineswhetherthearcendingsareroundorflat,andcurvedefinesthe"curvature"of
thearc.Thevalidrangeforcurveis-360..+360,anditsvaluemeanswhatpartofafull
circlethearcconsistsof.Avalueof90,forinstance,wouldresultina90arc,while180
wouldgiveyouasemicircle.Themaximumvalueof360canonlybereachedtheoretically,
sincethiswouldmeanthatthearcconsistsofafullcircle,which,becausethestartandend
pointshavetolieonthecircle,wouldhavetohaveaninfinitelylargediameter.Positive
valuesforcurvemeanthatthearcisdrawninamathematicallypositivesense(i.e.
counterclockwise).Ifcurveis0,thearcisastraightline("nocurvature"),whichisactually
awire.
Thecapparameteronlyhasameaningforactualarcs,andwillalwaysreturnCAP_ROUND
forastraightwire.
WhetherornotanUL_WIREisanarccanbedeterminedbycheckingthebooleanreturn
valueofthearcdatamember.Ifitreturns0,wehaveastraightwire,otherwiseanarc.If
arcreturnsanonzerovalueitmaybefurtherdereferencedtoaccesstheUL_ARCspecific
parametersstartandendangle,radiusandcenterpoint.Notethatyoumayonlyneedthese
additionalparametersifyouaregoingtodrawthearcorprocessitinotherwayswherethe
actualshapeisimportant.

Example
board(B) {
B.wires(W) {
printf("Wire: (%d %d) (%d %d)\n",
W.x1, W.y1, W.x2, W.y2);
}
}

Definitions
ThedataitemstobeusedinaUserLanguageProgrammustbedefinedbeforetheycanbe
used.
Therearethreekindsofdefinitions:

ConstantDefinitions
VariableDefinitions
FunctionDefinitions
Page59of132

EAGLEUserLanguage
Thescopeofaconstantorvariabledefinitiongoesfromthelineinwhichithasbeen
definedtotheendofthecurrentblock,ortotheendoftheUserLanguageProgram,ifthe
definitionappearedoutsideanyblock.
Thescopeofafunctiondefinitiongoesfromtheclosingbrace(})ofthefunctionbodyto
theendoftheUserLanguageProgram.

Constant Definitions
Constantsaredefinedusingthekeywordenum,asin
enum { a, b, c };

whichwoulddefinethethreeconstantsa,bandc,givingthemthevalues0,1and2,
respectively.
Constantsmayalsobeinitializedtospecificvalues,like
enum { a, b = 5, c };

whereawouldbe0,bwouldbe5andcwouldbe6.

Variable Definitions
Thegeneralsyntaxofavariabledefinitionis
[numeric] type identifier [= initializer][, ...];

wheretypeisoneofthedataorobjecttypes,identifieristhenameofthevariable,
andinitializerisaoptionalinitialvalue.
Multiplevariabledefinitionsofthesametypeareseparatedbycommas(,).
Ifidentifierisfollowedbyapairofbrackets([]),thisdefinesanarrayofvariablesof
thegiventype.Thesizeofanarrayisautomaticallyadjustedatruntime.
Theoptionalkeywordnumericcanbeusedwithstringarraystohavethemsorted
alphanumericallybythesort()function.
Bydefault(ifnoinitializerispresent),datavariablesaresetto0(or"",incaseofa
string),andobjectvariablesare"invalid".

Examples
int i;
string s = "Hello";
real a, b = 1.0, c;
int n[] = { 1, 2,
3 };
numeric string

definesanintvariablenamedi
definesastringvariablenamedsandinitializesitto
"Hello"
definesthreerealvariablesnameda,bandc,initializingbto
thevalue1.0
definesanarrayofint,initializingthefirstthreeelementsto
1,2and3
definesastringarraythatcanbesortedalphanumerically
Page60of132

EAGLEUserLanguage
names[];
UL_WIRE w;
definesaUL_WIREobjectnamedw
Themembersofarrayelementsofobjekttypescan'tbeaccesseddirectly:
UL_SIGNAL signals[];
...
UL_SIGNAL s = signals[0];
printf("%s", s.name);

Function Definitions
YoucanwriteyourownUserLanguagefunctionsandcallthemjustliketheBuiltin
Functions.
Thegeneralsyntaxofafunctiondefinitionis
type identifier(parameters)
{
statements
}

wheretypeisoneofthedataorobjecttypes,identifieristhenameofthefunction,
parametersisalistofcommaseparatedparameterdefinitions,andstatementsisa
sequenceofstatements.
Functionsthatdonotreturnavaluehavethetypevoid.
Afunctionmustbedefinedbeforeitcanbecalled,andfunctioncallscannotberecursive
(afunctioncannotcallitself).
Thestatementsinthefunctionbodymaymodifythevaluesoftheparameters,butthiswill
nothaveanyeffectontheargumentsofthefunctioncall.
Executionofafunctioncanbeterminatedbythereturnstatement.Withoutanyreturn
statementthefunctionbodyisexecuteduntilit'sclosingbrace(}).
Acalltotheexit()functionwillterminatetheentireUserLanguageProgram.

The special function main()


IfyourUserLanguageProgramcontainsafunctioncalledmain(),thatfunctionwillbe
explicitlycalledasthemainfunction,andit'sreturnvaluewillbethereturnvalueofthe
program.
CommandlineargumentsareavailabletotheprogramthroughtheglobalBuiltinVariables
argcandargv.

Example
int CountDots(string s)
{
int dots = 0;
for (int i = 0; s[i]; ++i)
if (s[i] == '.')

Page61of132

EAGLEUserLanguage
++dots;
return dots;
}
string dotted = "This.has.dots...";
output("test") {
printf("Number of dots: %d\n",
CountDots(dotted));
}

Operators
ThefollowingtablelistsalloftheUserLanguageoperators,inorderoftheirprecedence
(Unaryhavingthehighestprecedence,Commathelowest):
! ~ + - ++ -Unary
Multiplicative * / %
+ Additive
<< >>
Shift
< <= > >=
Relational
== !=
Equality
&
BitwiseAND
^
BitwiseXOR
|
BitwiseOR
&&
LogicalAND
||
LogicalOR
?:
Conditional
= *= /= %= += -= &= ^= |= <<= >>=
Assignment
,
Comma
Associativityislefttorightforalloperators,exceptforUnary,ConditionalandAssignment,
whicharerighttoleftassociative.
Thenormaloperatorprecedencecanbealteredbytheuseofparentheses.

Bitwise Operators
Bitwiseoperatorsworkonlywithdatatypescharandint.
Unary
~
Binary
<<
>>
&
^
|
Assignment
&=
^=
|=

Bitwise(1's)complement
Shiftleft
Shiftright
BitwiseAND
BitwiseXOR
BitwiseOR
AssignbitwiseAND
AssignbitwiseXOR
AssignbitwiseOR
Page62of132

EAGLEUserLanguage
<<=
>>=

Assignleftshift
Assignrightshift

Logical Operators
Logicaloperatorsworkwithexpressionsofanydatatype.
Unary
!
LogicalNOT
Binary
&&
LogicalAND
||
LogicalOR
Usingastringexpressionwithalogicaloperatorcheckswhetherthestringisempty.
UsinganObjectTypewithalogicaloperatorcheckswhetherthatobjectcontainsvaliddata.

Comparison Operators
Comparisonoperatorsworkwithexpressionsofanydatatype,exceptObjectTypes.
<
<=
>
>=
==
!=

Lessthan
Lessthanorequalto
Greaterthan
Greaterthanorequal
to
Equalto
Notequalto

Evaluation Operators
Evaluationoperatorsareusedtoevaluateexpressionsbasedonacondition,ortogroupa
sequenceofexpressionsandhavethemevaluatedasoneexpression.
?: Conditional
,
Comma
TheConditionaloperatorisusedtomakeadecisionwithinanexpression,asin
int a;
// ...code that calculates 'a'
string s = a ? "True" : "False";

whichisbasicallythesameas
int a;
string s;
// ...code that calculates 'a'
if (a)
s = "True";
else
s = "False";

buttheadvantageoftheconditionaloperatoristhatitcanbeusedinanexpression.

Page63of132

EAGLEUserLanguage
TheCommaoperatorisusedtoevaluateasequenceofexpressionsfromlefttoright,using
thetypeandvalueoftherightoperandastheresult.
Notethatargumentsinafunctioncallaswellasmultiplevariabledeclarationsalsouse
commasasdelimiters,butinthatcasethisisnotacommaoperator!

Arithmetic Operators
Arithmeticoperatorsworkwithdatatypeschar,intandreal(exceptfor++,--,%and
%=).
Unary
+
Unaryplus
-
Unaryminus
++
Preorpostincrement
--
Preorpostdecrement
Binary
*
Multiply
/
Divide
%
Remainder(modulus)
+
Binaryplus
-
Binaryminus
Assignment
=
Simpleassignment
*=
Assignproduct
/=
Assignquotient
%=
Assignremainder(modulus)
+=
Assignsum
-=
Assigndifference
SeealsoStringOperators

String Operators
Stringoperatorsworkwithdatatypeschar,intandstring.Theleftoperandmust
alwaysbeoftypestring.
Binary
+
Concatenation
Assignment
=
Simpleassignment
+=
Appendtostring
The+operatorconcatenatestwostrings,oraddsacharactertotheendofastringand
returnstheresultingstring.
The+=operatorappendsastringoracharactertotheendofagivenstring.
SeealsoArithmeticOperators

Page64of132

EAGLEUserLanguage

Expressions
Anexpressioncanbeoneofthefollowing:

ArithmeticExpression
AssignmentExpression
StringExpression
CommaExpression
ConditionalExpression
FunctionCall

Expressionscanbegroupedusingparentheses,andmayberecursive,meaningthatan
expressioncanconsistofsubexpressions.

Arithmetic Expression
Anarithmeticexpressionisanycombinationofnumericoperandsandanarithmetic
operatororabitwiseoperator.

Examples
a + b
c++
m << 1

Assignment Expression
Anassignmentexpressionconsistsofavariableontheleftsideofanassignmentoperator,
andanexpressionontherightside.

Examples
a = x + 42
b += c
s = "Hello"

String Expression
Astringexpressionisanycombinationofstringandcharoperandsandastringoperator.

Examples
s + ".brd"
t + 'x'

Comma Expression
Acommaexpressionisasequenceofexpressions,delimitedbythecommaoperator
Commaexpressionsareevaluatedlefttoright,andtheresultofacommaexpressionisthe
Page65of132

EAGLEUserLanguage
typeandvalueoftherightmostexpression.

Example
i++, j++, k++

Conditional Expression
Aconditionalexpressionusestheconditionaloperatortomakeadecisionwithinan
expression.

Example
int a;
// ...code that calculates 'a'
string s = a ? "True" : "False";

Function Call
Afunctioncalltransferstheprogramflowtoauserdefinedfunctionorabuiltinfunction.
Theformalparametersdefinedinthefunctiondefinitionarereplacedwiththevaluesofthe
expressionsusedastheactualargumentsofthefunctioncall.

Example
int p = strchr(s, 'b');

Statements
Astatementcanbeoneofthefollowing:

CompoundStatement
ControlStatement
ExpressionStatement
BuiltinStatement
ConstantDefinition
VariableDefinition

StatementsspecifytheflowofcontrolasaUserLanguageProgramexecutes.Inabsenceof
specificcontrolstatements,statementsareexecutedsequentiallyintheorderofappearance
intheULPfile.

Compound Statement
Acompoundstatement(alsoknownasblock)isalist(possiblyempty)ofstatements
enclosedinmatchingbraces({}).Syntactically,ablockcanbeconsideredtobeasingle
statement,butitalsocontrolsthescopingofidentifiers.Anidentifierdeclaredwithina
blockhasascopestartingatthepointofdeclarationandendingattheclosingbrace.
Compoundstatementscanbenestedtoanydepth.
Page66of132

EAGLEUserLanguage

Expression Statement
Anexpressionstatementisanyexpressionfollowedbyasemicolon.
Anexpressionstatementisexecutedbyevaluatingtheexpression.Allsideeffectsofthis
evaluationarecompletedbeforethenextstatementisexecuted.Mostexpression
statementsareassignmentsorfunctioncalls.
Aspecialcaseistheemptystatement,consistingofonlyasemicolon.Anemptystatement
doesnothing,butitmaybeusefulinsituationswheretheULPsyntaxexpectsastatement
butyourprogramdoesnotneedone.

Control Statements
Controlstatementsareusedtocontroltheprogramflow.
Iterationstatementsare
do...while
for
while

Selectionstatementsare
if...else
switch

Jumpstatementsare
break
continue
return

break
Thebreakstatementhasthegeneralsyntax
break;

andimmediatelyterminatesthenearestenclosingdo...while,for,switchorwhile
statement.Thisalsoappliestoloopmembersofobjecttypes.
Sinceallofthesestatementscanbeintermixedandnestedtoanydepth,takecaretoensure
thatyourbreakexitsfromthecorrectstatement.

continue
Thecontinuestatementhasthegeneralsyntax
continue;

andimmediatelytransferscontroltothetestconditionofthenearestenclosingdo...while,
while,orforstatement,ortotheincrementexpressionofthenearestenclosingfor
statement.
Page67of132

EAGLEUserLanguage
Sinceallofthesestatementscanbeintermixedandnestedtoanydepth,takecaretoensure
thatyourcontinueaffectsthecorrectstatement.

do...while
Thedo...whilestatementhasthegeneralsyntax
do statement while (condition);

andexecutesthestatementuntiltheconditionexpressionbecomeszero.
Theconditionistestedafterthefirstexecutionofstatement,whichmeansthatthe
statementisalwaysexecutedatleastonetime.
Ifthereisnobreakorreturninsidethestatement,thestatementmustaffectthe
valueofthecondition,orconditionitselfmustchangeduringevaluationinorderto
avoidanendlessloop.

Example
string s = "Trust no one!";
int i = -1;
do {
++i;
} while (s[i]);

for
Theforstatementhasthegeneralsyntax
for ([init]; [test]; [inc]) statement

andperformsthefollowingsteps:
1. Ifaninitializingexpressioninitispresent,itisexecuted.
2. Ifatestexpressionispresent,itisexecuted.Iftheresultisnonzero(orifthereis
notestexpressionatall),thestatementisexecuted.
3. Ifanincexpressionispresent,itisexecuted.
4. Finallycontrolreturnstostep2.
Ifthereisnobreakorreturninsidethestatement,theincexpression(orthe
statement)mustaffectthevalueofthetestexpression,ortestitselfmustchange
duringevaluationinordertoavoidanendlessloop.
Theinitializingexpressioninitnormallyinitializesoneormoreloopcounters.Itmayalso
defineanewvariableasaloopcounter.Thescopeofsuchavariableisvaliduntiltheend
oftheactiveblock.

Example
string s = "Trust no one!";
int sum = 0;
for (int i = 0; s[i]; ++i)

Page68of132

EAGLEUserLanguage
sum += s[i]; // sums up the characters in s

if...else
Theif...elsestatementhasthegeneralsyntax
if (expression)
t_statement
[else
f_statement]

Theconditionalexpressionisevaluated,andifitsvalueisnonzerothet_statementis
executed.Otherwisethef_statementisexecutedincasethereisanelseclause.
Anelseclauseisalwaysmatchedtothelastencounteredifwithoutanelse.Ifthisis
notwhatyouwant,youneedtousebracestogroupthestatements,asin
if (a == 1) {
if (b == 1)
printf("a == 1 and b == 1\n");
}
else
printf("a != 1\n");

return
Afunctionwithareturntypeotherthanvoidmustcontainatleastonereturnstatement
withthesyntax
return expression;

whereexpressionmustevaluatetoatypethatiscompatiblewiththefunction'sreturn
type.Thevalueofexpressionisthevaluereturnedbythefunction.
Ifthefunctionisoftypevoid,areturnstatementwithoutanexpressioncanbeused
toreturnfromthefunctioncall.

switch
Theswitchstatementhasthegeneralsyntax
switch (sw_exp) {
case case_exp: case_statement
...
[default: def_statement]
}

andallowsforthetransferofcontroltooneofseveralcaselabeledstatements,depending
onthevalueofsw_exp(whichmustbeofintegraltype).
Anycase_statementcanbelabeledbyoneormorecaselabels.Thecase_expofeach
caselabelmustevaluatetoaconstantintegerwhichisuniquewithinit'senclosing
switchstatement.
Page69of132

EAGLEUserLanguage
Therecanalsobeatmostonedefaultlabel.
Afterevaluatingsw_exp,thecase_exparecheckedforamatch.Ifamatchisfound,
controlpassestothecase_statementwiththematchingcaselabel.
Ifnomatchisfoundandthereisadefaultlabel,controlpassestodef_statement.
Otherwisenoneofthestatementsintheswitchisexecuted.
Programexecutionisnotaffectedwhencaseanddefaultlabelsareencountered.
Controlsimplypassesthroughthelabelstothefollowingstatement.
Tostopexecutionattheendofagroupofstatementsforaparticularcase,usethebreak
statement.

Example
string s =
int vowels
for (int i
switch
case
case
case
case
case

"Hello World";
= 0, others = 0;
= 0; s[i]; ++i)
(toupper(s[i])) {
'A':
'E':
'I':
'O':
'U': ++vowels;
break;
default: ++others;
}
printf("There are %d vowels in '%s'\n", vowels, s);

while
Thewhilestatementhasthegeneralsyntax
while (condition) statement

andexecutesthestatementaslongastheconditionexpressionisnotzero.
Theconditionistestedbeforethefirstpossibleexecutionofstatement,whichmeans
thatthestatementmayneverbeexecutedifconditionisinitiallyzero.
Ifthereisnobreakorreturninsidethestatement,thestatementmustaffectthe
valueofthecondition,orconditionitselfmustchangeduringevaluationinorderto
avoidanendlessloop.

Example
string s = "Trust no one!";
int i = 0;
while (s[i])
++i;

Page70of132

EAGLEUserLanguage

Builtins
BuiltinsareConstants,Variables,FunctionsandStatementsthatprovideadditional
informationandallowfordatamanipulations.

BuiltinConstants
BuiltinVariables
BuiltinFunctions
BuiltinStatements

Builtin Constants
Builtinconstantsareusedtoprovideinformationaboutobjectparameters,suchas
maximumrecommendednamelength,flagsetc.
ManyoftheobjecttypeshavetheirownConstantssectionwhichliststhebuiltinconstants
forthatparticularobject(seee.g.UL_PIN).
Thefollowingbuiltinconstantsaredefinedinadditiontotheoneslistedforthevarious
objecttypes:
EAGLEprogramversionnumber(int)
EAGLEprogramreleasenumber(int)
astringcontainingEAGLEprogramname,versionandcopyright
information
theminimumpositiverealnumbersuchthat1.0 +
REAL_EPSILON
REAL_EPSILON != 1.0
REAL_MAX
thelargestpossiblerealvalue
thesmallestpossible(positive!)realvalue
REAL_MIN
thesmallestrepresentablenumberis-REAL_MAX
INT_MAX
thelargestpossibleintvalue
INT_MIN
thesmallestpossibleintvalue
PI
thevalueof"pi"(3.14...,real)
usage
astringcontainingthetextfromthe#usagedirective
Thesebuiltinconstantscontainthedirectorypathsdefinedinthedirectoriesdialog,with
anyofthespecialvariables($HOMEand$EAGLEDIR)replacedbytheiractualvalues.Since
eachpathcanconsistofseveraldirectories,theseconstantsarestringarrayswithan
individualdirectoryineachmember.Thefirstemptymembermarkstheendofthepath:
EAGLE_VERSION
EAGLE_RELEASE
EAGLE_SIGNATUR
E

Libraries
DesignRules
UserLanguage
path_ulp[]
Programs
path_scr[] Scripts
path_cam[] CAMJobs
path_epf[] Projects
Whenusingtheseconstantstobuildafullfilename,youneedtouseadirectoryseparator,
asin
path_lbr[]
path_dru[]

string s = path_lbr[0] + '/' + "mylib.lbr";

Page71of132

EAGLEUserLanguage
ThelibrariesthatarecurrentlyinusethroughtheUSEcommand:
used_libraries[]

Builtin Variables
Builtinvariablesareusedtoprovideinformationatruntime.
int argc
string argv[]

numberofargumentsgiventotheRUNcommand
argumentsgiventotheRUNcommand(argv[0]isthefullULPfile
name)

Builtin Functions
Builtinfunctionsareusedtoperformspecifictasks,likeprintingformattedstrings,sorting
dataarraysorthelike.
YoumayalsowriteyourownfunctionsandusethemtostructureyourUserLanguage
Program.
Thebuiltinfunctionsaregroupedintothefollowingcategories:

CharacterFunctions
FileHandlingFunctions
MathematicalFunctions
MiscellaneousFunctions
PrintingFunctions
StringFunctions
TimeFunctions
ObjectFunctions

Alphabeticalreferenceofallbuiltinfunctions:

abs()
acos()
asin()
atan()
ceil()
cos()
exit()
exp()
filedir()
fileerror()
fileext()
fileglob()
filename()
fileread()
filesetext()
filesize()
filetime()
floor()
Page72of132

EAGLEUserLanguage

frac()
ingroup()
isalnum()
isalpha()
iscntrl()
isdigit()
isgraph()
islower()
isprint()
ispunct()
isspace()
isupper()
isxdigit()
language()
log()
log10()
lookup()
max()
min()
palette()
pow()
printf()
round()
sin()
sort()
sprintf()
sqrt()
status()
strchr()
strjoin()
strlen()
strlwr()
strrchr()
strrstr()
strsplit()
strstr()
strsub()
strtod()
strtol()
strupr()
system()
t2day()
t2dayofweek()
t2hour()
t2minute()
t2month()
Page73of132

EAGLEUserLanguage

t2second()
t2string()
t2year()
tan()
time()
tolower()
toupper()
trunc()
u2inch()
u2mic()
u2mil()
u2mm()

Character Functions
Characterfunctionsareusedtomanipulatesinglecharacters.
Thefollowingcharacterfunctionsareavailable:

isalnum()
isalpha()
iscntrl()
isdigit()
isgraph()
islower()
isprint()
ispunct()
isspace()
isupper()
isxdigit()
tolower()
toupper()

is...()
Function
Checkwhetheracharacterfallsintoagivencategory.
Syntax
int isalnum(char c);
int isalpha(char c);
int iscntrl(char c);
int isdigit(char c);
int isgraph(char c);
int islower(char c);
int isprint(char c);
int ispunct(char c);
int isspace(char c);
int isupper(char c);
Page74of132

EAGLEUserLanguage
int isxdigit(char c);
Returns
Theis...functionsreturnnonzeroifthegivencharacterfallsintothecategory,zero
otherwise.

Character categories
isalnum
isalpha
iscntrl
isdigit
isgraph
islower
isprint
ispunct
isspace
isupper
isxdigit

letters(AtoZoratoz)ordigits(0to9)
letters(AtoZoratoz)
deletecharactersorordinarycontrolcharacters(0x7For0x00to0x1F)
digits(0to9)
printingcharacters(exceptspace)
lowercaseletters(atoz)
printingcharacters(0x20to0x7E)
punctuationcharacters(iscntrlorisspace)
space,tab,carriagereturn,newline,verticaltab,orformfeed(0x09to
0x0D,0x20)
uppercaseletters(AtoZ)
hexdigits(0to9,AtoF,atof)

Example
char c = 'A';
if (isxdigit(c))
printf("%c is hex\n", c);
else
printf("%c is not hex\n", c);

to...()
Function
Convertacharactertoupperorlowercase.
Syntax
char tolower(char c);
char toupper(char c);
Returns
Thetolowerfunctionreturnstheconvertedcharacterifcisuppercase.Allother
charactersarereturnedunchanged.
Thetoupperfunctionreturnstheconvertedcharacterifcislowercase.Allother
charactersarereturnedunchanged.
Seealsostrupr,strlwr

File Handling Functions


Filenamehandlingfunctionsareusedtoworkwithfilenames,sizesandtimestamps.
Thefollowingfilehandlingfunctionsareavailable:
Page75of132

EAGLEUserLanguage

fileerror()
fileglob()
filedir()
fileext()
filename()
fileread()
filesetext()
filesize()
filetime()

Seeoutput()forinformationabouthowtowriteintoafile.

fileerror()
Function
ReturnsthestatusofI/Ooperations.
Syntax
int fileerror();
Returns
Thefileerrorfunctionreturns0ifeverythingisok.
Seealsooutput,printf,fileread
fileerrorchecksthestatusofanyI/Ooperationsthathavebeenperformedsincethe
lastcalltothisfunctionandreturns0ifeverythingwasok.IfanyoftheI/Ooperationshas
causedanerror,avalueotherthan0willbereturned.
YoushouldcallfileerrorbeforeanyI/Ooperationstoresetanypreviouserrorstate,
andcallitagainaftertheI/Ooperationstoseeiftheyweresuccessful.
Whenfileerrorreturnsavalueotherthan0(thusindicatinganerror)apropererror
messagehasalreadybeengiventotheuser.

Example
fileerror();
output("file.txt", "wt") {
printf("Test\n");
}
if (fileerror())
exit(1);

fileglob()
Function
Performadirectorysearch.
Syntax
int fileglob(string &array[], string pattern);
Returns
Thefileglobfunctionreturnsthenumberofentriescopiedintoarray.
Page76of132

EAGLEUserLanguage
SeealsodlgFileOpen(),dlgFileSave()
fileglobperformsadirectorysearchusingpattern.
patternmaycontain'*'and'?'aswildcardcharacters.Ifpatternendswitha'/',
thecontentsofthegivendirectorywillbereturned.
Namesintheresultingarraythatendwitha'/'aredirectorynames.
Thearrayissortedalphabetically,withthedirectoriescomingfirst.
Thespecialentries'.'and'..'(forthecurrentandparentdirectories)arenever
returnedinthearray.
Ifpatterndoesn'tmatch,orifyoudon'thavepermissiontosearchthegivendirectory,the
resultingarraywillbeempty.

Note for Windows users


Thedirectorydelimiterinthearrayisalwaysaforwardslash.Thismakessure
UserLanguageProgramswillworkplatformindependently.Inthepatternthe
backslash('\')isalsotreatedasadirectorydelimiter.
SortingfilenamesunderWindowsisdonecaseinsensitively.

Example
string a[];
int n = fileglob(a, "*.brd");

Filename Functions
Function
Splitafilenameintoitsseparateparts.
Syntax
string filedir(string file);
string fileext(string file);
string filename(string file);
string filesetext(string file, string newext);
Returns
filedir returnsthedirectoryoffile(includingthedriveletterunderWindows).
fileext returnstheextensionoffile.
filename returnsthefilenameoffile(includingtheextension).
filesetextreturnsfilewiththeextensionsettonewext.
SeealsoFiledataFunctions

Example
if (board) board(B) {
output(filesetext(B.name, ".out")) {

Page77of132

EAGLEUserLanguage
...
}
}

Filedata Functions
Function
Getsthetimestampandsizeofafile.
Syntax
int filesize(string filename);
int filetime(string filename);
Returns
filesizereturnsthesize(inbyte)ofthegivenfile.
filetimereturnsthetimestampofthegivenfileinaformattobeusedwiththe
timefunctions.
Seealsotime,FilenameFunctions

Example
board(B)
printf("Board: %s\nSize: %d\nTime: %s\n",
B.name, filesize(B.name),
t2string(filetime(B.name)));

File Input Functions


Fileinputfunctionsareusedtoreaddatafromfiles.
Thefollowingfileinputisavailable:

fileread()

Seeoutput()forinformationabouthowtowriteintoafile.

fileread()
Function
Readsdatafromafile.
Syntax
int fileread(dest, string file);
Returns
filereadreturnsthenumberofobjectsreadfromthefile.
Theactualmeaningofthereturnvaluedependsonthetypeofdest.
Seealsolookup,strsplit,fileerror
Ifdestisacharacterarray,thefilewillbereadasrawbinarydataandthereturnvalue
reflectsthenumberofbytesreadintothecharacterarray(whichisequaltothefilesize).

Page78of132

EAGLEUserLanguage
Ifdestisastringarray,thefilewillbereadasatextfile(onelineperarraymember)and
thereturnvaluewillbethenumberoflinesreadintothestringarray.Newlinecharacters
willbestripped.
Ifdestisastring,theentirefilewillbereadintothatstringandthereturnvaluewillbe
thelengthofthatstring(whichisnotnecessarilyequaltothefilesize,iftheoperating
systemstorestextfileswith"cr/lf"insteadofa"newline"character).

Example
char b[];
int nBytes = fileread(b, "data.bin");
string lines[];
int nLines = fileread(lines, "data.txt");
string text;
int nChars = fileread(text, "data.txt");

Mathematical Functions
Mathematicalfunctionsareusedtoperformmathematicaloperations.
Thefollowingmathematicalfunctionsareavailable:

abs()
acos()
asin()
atan()
ceil()
cos()
exp()
floor()
frac()
log()
log10()
max()
min()
pow()
round()
sin()
sqrt()
trunc()
tan()

Error Messages
Iftheargumentsofamathematicalfunctioncallleadtoanerror,theerrormessagewill
showtheactualvaluesofthearguments.Thusthestatements
real x = -1.0;
real r = sqrt(2 * x);

Page79of132

EAGLEUserLanguage
willleadtotheerrormessage
Invalid argument in call to 'sqrt(-2)'

Absolute, Maximum and Minimum Functions


Function
Absolute,maximumandminimumfunctions.
Syntax
type abs(type x);
type max(type x, type y);
type min(type x, type y);
Returns
absreturnstheabsolutevalueofx.
maxreturnsthemaximumofxandy.
minreturnstheminimumofxandy.
Thereturntypeofthesefunctionsisthesameasthe(larger)typeofthearguments.
typemustbeoneofchar,intorreal.

Example
real x = 2.567, y = 3.14;
printf("The maximum is %f\n", max(x, y));

Rounding Functions
Function
Roundingfunctions.
Syntax
real ceil(real x);
real floor(real x);
real frac(real x);
real round(real x);
real trunc(real x);
Returns
ceil returnsthesmallestintegernotlessthanx.
floorreturnsthelargestintegernotgreaterthanx.
frac returnsthefractionalpartofx.
roundreturnsxroundedtothenearestinteger.
truncreturnstheintegerpartofx.

Example
real x = 2.567;
printf("The rounded value of %f is %f\n", x, round(x));

Page80of132

EAGLEUserLanguage

Trigonometric Functions
Function
Trigonometricfunctions.
Syntax
real acos(real x);
real asin(real x);
real atan(real x);
real cos(real x);
real sin(real x);
real tan(real x);
Returns
acosreturnsthearccosineofx.
asinreturnsthearcsineofx.
atanreturnsthearctangentofx.
cos returnsthecosineofx.
sin returnsthesineofx.
tan returnsthetangentofx.

Constants
PI

thevalueof"pi"
(3.14...)

Example
real x = PI / 2;
printf("The sine of %f is %f\n", x, sin(x));

Exponential Functions
Function
ExponentialFunctions.
Syntax
real exp(real x);
real log(real x);
real log10(real x);
real pow(real x, real y);
real sqrt(real x);
Returns
exp returnstheexponentialetothepowerofx.
log returnsthenaturallogarithmofx.
log10returnsthebase10logarithmofx.
pow returnsthevalueofxtothepowerofy.
sqrt returnsthesquarerootofx.

Page81of132

EAGLEUserLanguage

Note
The"nth"rootcanbecalculatedusingthepowfunctionwithanegativeexponent.

Example
real x = 2.1;
printf("The square root of %f is %f\n", x, sqrt(x));

Miscellaneous Functions
Miscellaneousfunctionsareusedtoperformvarioustasks.
Thefollowingmiscellaneousfunctionsareavailable:

exit()
language()
lookup()
palette()
sort()
status()
system()
UnitConversions

exit()
Function
ExitsfromaUserLanguageProgram.
Syntax
void exit(int result);
void exit(string command);
SeealsoRUN
TheexitfunctionterminatesexecutionofaUserLanguageProgram.
Ifanintegerresultisgivenitwillbeusedasthereturnvalueoftheprogram.
Ifastringcommandisgiven,thatcommandwillbeexecutedasifitwereenteredintothe
commandlineimmediatelyaftertheRUNcommand.Inthatcasethereturnvalueofthe
ULPissettoEXIT_SUCCESS.

Constants
EXIT_SUCCESS
EXIT_FAILURE

returnvalueforsuccessfulprogramexecution(value
0)
returnvalueforfailedprogramexecution(value-1)

language()
Function
Returnsthelanguagecodeofthesysteminuse.
Page82of132

EAGLEUserLanguage
Syntax
string language();
Returns
languagereturnsastringconsistingoftwolowercasecharactersthatidentifiesthe
languageusedonthecurrentsystem.Ifnosuchlanguagesettingcanbedetermined,
anemptystringwillbereturned.
ThelanguagefunctioncanbeusedtomakeaULPusedifferentmessagestring,
dependingonwhichlanguagethecurrentsystemisusing.
IntheexamplebelowallthestringsusedintheULParelistedinthestringarrayI18N[],
preceededbyastringcontainingthevariouslanguagecodessupportedbythisULP.Note
thevtabcharactersusedtoseparatetheindividualpartsofeachstring(theyareimportant
forthelookupfunction)andtheuseofthecommastoseparatethestrings.Theactual
workisdoneinthefunctiontr(),whichreturnsthetranslatedversionofthegivenstring.
Iftheoriginalstringcan'tbefoundintheI18Narray,orthereisnotranslationforthe
currentlanguage,theoriginalstringwillbeuseduntranslated.
ThefirstlanguagedefinedintheI18Narraymustbetheoneinwhichthestringsused
throughouttheULParewritten,andshouldgenerallybeEnglishinordertomakethe
programaccessibletothelargestnumberofusers.

Example
string I18N[] = {
"en\v"
"de\v"
"it\v"
,
"I18N Demo\v"
"Beispiel fr Internationalisierung\v"
"Esempio per internazionalizzazione\v"
,
"Hello world!\v"
"Hallo Welt!\v"
"Ciao mondo!\v"
,
"+Ok\v"
"+Ok\v"
"+Approvazione\v"
,
"-Cancel\v"
"-Abbrechen\v"
"-Annullamento\v"
};
int Language = strstr(I18N[0], language()) / 3;
string tr(string s)
{
string t = lookup(I18N, s, Language, '\v');
return t ? t : s;
}
dlgDialog(tr("I18N Demo")) {
dlgHBoxLayout dlgSpacing(350);
dlgLabel(tr("Hello world!"));

Page83of132

EAGLEUserLanguage
dlgHBoxLayout {
dlgPushButton(tr("+Ok")) dlgAccept();
dlgPushButton(tr("-Cancel")) dlgReject();
}
};

lookup()
Function
Looksupdatainastringarray.
Syntax
string lookup(string array[], string key, int field_index[,
char separator]);
string lookup(string array[], string key, string field_name[,
char separator]);
Returns
lookupreturnsthevalueofthefieldidentifiedbyfield_indexorfield_name.
Ifthefielddoesn'texist,ornostringmatchingkeyisfound,anemptystringis
returned.
Seealsofileread,strsplit
Anarraythatcanbeusedwithlookup()consistsofstringsoftext,eachstring
representingonedatarecord.
Eachdatarecordcontainsanarbitrarynumberoffields,whichareseparatedbythe
characterseparator(defaultis'\t',thetabulator).Thefirstfieldinarecordisusedas
thekeyandisnumbered0.
Allrecordsmusthaveuniquekeyfieldsandnoneofthekeyfieldsmaybeempty
otherwiseitisundefinedwhichrecordwillbefound.
Ifthefirststringinthearraycontainsa"Header"record(i.e.arecordwhereeachfield
describesitscontents),usinglookupwithafield_namestringautomaticallydetermines
theindexofthatfield.Thisallowsusingthelookupfunctionwithoutexactlyknowing
whichfieldindexcontainsthedesireddata.
Itisuptotheusertomakesurethatthefirstrecordactuallycontainsheaderinformation.
Ifthekeyparameterinthecalltolookup()isanemptystring,thefirststringofthe
arraywillbeused.Thisallowsaprogramtodeterminewhetherthereisaheaderrecord
withtherequiredfieldnames.
Ifafieldcontainstheseparatorcharacter,thatfieldmustbeenclosedindoublequotes
(asin"abc;def",assumingthesemicolon(';')isusedasseparator).Thesameapplies
ifthefieldcontainsdoublequotes("),inwhichcasethedoublequotesinsidethefieldhave
tobedoubled(asin"abc;""def"";ghi",whichwouldbeabc;"def";ghi).
Itisbesttousethedefault"tab"separator,whichdoesn'thavetheseproblems(no
fieldcancontainatabulator).
Here'sanexampledatafile(';'hasbeenusedasseparatorforbetterreadability):
Page84of132

EAGLEUserLanguage
Name;Manufacturer;Code;Price
7400;Intel;I-01-234-97;$0.10
68HC12;Motorola;M68HC1201234;$3.50

Example
string OrderCodes[];
if (fileread(OrderCodes, "ordercodes") > 0) {
if (lookup(OrderCodes, "", "Code", ';')) {
schematic(SCH) {
SCH.parts(P) {
string OrderCode;
// both following statements do exactly the same:
OrderCode = lookup(OrderCodes, P.device.name, "Code", ';');
OrderCode = lookup(OrderCodes, P.device.name, 2, ';');
}
}
}
else
dlgMessageBox("Missing 'Code' field in file 'ordercodes');
}

palette()
Function
Returnscolorpaletteinformation.
Syntax
int palette(int index[, int type]);
Returns
ThepalettefunctionreturnsanintegerARGBvalueintheform0xaarrggbb,orthe
typeofthecurrentlyusedpalette(dependingonthevalueofindex).
ThepalettefunctionreturnstheARGBvalueofthecolorwiththegivenindex(which
maybeintherange0..PALETTE_ENTRIES1).Iftypeisnotgiven(oris-1)thepalette
assignedtothecurrenteditorwindowwillbeused.Otherwisetypespecifieswhichcolor
palettetouse(PALETTE_BLACK,PALETTE_WHITEorPALETTE_COLORED).
Thespecialvalue-1forindexmakesthefunctionreturnthetypeofthepalettethatis
currentlyinusebytheeditorwindow.
Ifeitherindexortypeisoutofrange,anerrormessagewillbegivenandtheULPwillbe
terminated.

Constants
PALETTE_TYPES
PALETTE_BLACK
PALETTE_WHITE
PALETTE_COLORED
PALETTE_ENTRIES

thenumberofpalettetypes(3)
theblackbackgroundpalette(0)
thewhitebackgroundpalette(1)
thecoloredbackgroundpalette(2)
thenumberofcolorsperpalette
(64)
Page85of132

EAGLEUserLanguage

sort()
Function
Sortsanarrayorasetofarrays.
Syntax
void sort(int number, array1[, array2,...]);
Thesortfunctioneitherdirectlysortsagivenarray1,oritsortsasetofarrays(starting
witharray2),inwhichcasearray1issupposedtobeanarrayofint,whichwillbeused
asapointerarray.
Inanycase,thenumberargumentdefinesthenumberofitemsinthearray(s).

Sorting a single array


Ifthesortfunctioniscalledwithonesinglearray,thatarraywillbesorteddirectly,asin
thefollowingexample:
string A[];
int n = 0;
A[n++] = "World";
A[n++] = "Hello";
A[n++] = "The truth is out there...";
sort(n, A);
for (int i = 0; i < n; ++i)
printf(A[i]);

Sorting a set of arrays


Ifthesortfunctioniscalledwithmorethanonearray,thefirstarraymustbeanarrayof
int,whilealloftheotherarraysmaybeofanyarraytypeandholdthedatatobesorted.
Thefollowingexampleillustrateshowthefirstarraywillbeusedasapointer:
numeric string Nets[], Parts[], Instances[], Pins[];
int n = 0;
int index[];
schematic(S) {
S.nets(N) N.pinrefs(P) {
Nets[n] = N.name;
Parts[n] = P.part.name;
Instances[n] = P.instance.name;
Pins[n] = P.pin.name;
++n;
}
sort(n, index, Nets, Parts, Instances, Pins);
for (int i = 0; i < n; ++i)
printf("%-8s %-8s %-8s %-8s\n",
Nets[index[i]], Parts[index[i]],
Instances[index[i]], Pins[index[i]]);
}

Theideabehindthisisthatonenetcanhaveseveralpinsconnectedtoit,andinanetlist
youmightwanttohavethenetnamessorted,andwithinonenetyoualsowantthepart
Page86of132

EAGLEUserLanguage
namessortedandsoon.
Notetheuseofthekeywordnumericinthestringarrays.Thiscausesthestringstobe
sortedinawaythattakesintoaccountanumericpartattheendofthestrings,whichleads
toIC1,IC2,...IC9,IC10insteadofthealphabeticalorderIC1,IC10,IC2,...IC9.
Whensortingasetofarrays,thefirst(index)arraymustbeoftypeintandneednotbe
initialized.Anycontentstheindexarraymighthavebeforecallingthesortfunctionwill
beoverwrittenbytheresultingindexvalues.

status()
Function
Displaysastatusmessageinthestatusbar.
Syntax
void status(string message);
SeealsodlgMessageBox()
Thestatusfunctiondisplaysthegivenmessageinthestatusbaroftheeditorwindowin
whichtheULPisrunning.

system()
Function
Executesanexternalprogram.
Syntax
int system(string command);
Returns
Thesystemfunctionreturnstheexitstatusofthecommand.Thisistypically0if
everythingwasok,andnonzeroincaseofanerror.
Thesystemfunctionexecutestheexternalprogramgivenbythecommandstring,and
waitsuntiltheprogramends.
Asasecurityprecaution,youwillbepromptedwiththecommandstringbeforethe
commandisexecuted,inordertomakesurethereisno"evil"ULPthatexecutesunwanted
externalcommands.Ifthisdialogiscanceled,thesystem()callwillreturn-1.Ifthe
dialogisconfirmed,anyfuturesystem()callsinthecurrentEAGLEsessionwithexactly
thesamecommandstringwillbeexecutedwithoutanyfurtherconfirmationdialog.

Input/Output redirection
Iftheexternalprogramshallreaditsstandardinputfrom(orwriteitsstandardoutputto)a
particularfile,input/outputneedstoberedirected.
OnLinuxandMacOSXthisisdonebysimplyaddinga'<'or'>'tothe
commandline,followedbythedesiredfilename,asin

Page87of132

EAGLEUserLanguage
system("program < infile > outfile");

whichrunsprogramandmakesitreadfrominfileandwritetooutfile.
OnWindowsyouhavetoexplicitlyrunacommandprocessortodothis,asin
system("cmd.exe /c program < infile > outfile");

(onDOSbasedWindowssystemsusecommand.cominsteadofcmd.exe).

Background execution
Thesystemfunctionwaitsuntilthegivenprogramhasended.Thisisusefulforprograms
thatonlyrunforafewseconds,orcompletelytakeovertheuser'sattention.
Ifanexternalprogramrunsforalongertime,andyouwantthesystemcalltoreturn
immediately,withoutwaitingfortheprogramtoend,youcansimplyaddan'&'to
thecommandstringunderLinuxandMacOSX,asin
system("program &");

UnderWindowsyouneedtoexplicitlyrunacommandprocessortodothis,asin
system("cmd.exe /c start program");

(onDOSbasedWindowssystemsusecommand.cominsteadofcmd.exe).

Example
int result = system("simulate -f filename");

Thiswouldcallasimulationprogram,givingitafilewhichtheULPhasjustcreated.Note
thatsimulatehereisjustanexample,itisnotpartoftheEAGLEpackage!

Unit Conversions
Function
Convertsinternalunits.
Syntax
real u2inch(int n);
real u2mic(int n);
real u2mil(int n);
real u2mm(int n);
Returns
u2inchreturnsthevalueofnininch.
u2mic returnsthevalueofninmicrons(1/1000mm).
u2mil returnsthevalueofninmil(1/1000inch).
u2mm returnsthevalueofninmillimeters.
SeealsoUL_GRID
Page88of132

EAGLEUserLanguage
EAGLEstoresallcoordinateandsizevaluesasintvalueswitharesolutionof1/10000mm
(0.1).Theaboveunitconversionfunctionscanbeusedtoconverttheseinternalunitsto
thedesiredmeasurementunits.

Example
board(B) {
B.elements(E) {
printf("%s at (%f, %f)\n", E.name,
u2mm(E.x), u2mm(E.y));
}
}

Printing Functions
Printingfunctionsareusedtoprintformattedstrings.
Thefollowingprintingfunctionsareavailable:

printf()
sprintf()

printf()
Function
Writesformattedoutputtoafile.
Syntax
int printf(string format[, argument, ...]);
Returns
Theprintffunctionreturnsthenumberofcharacterswrittentothefilethathas
beenopenedbythemostrecentoutputstatement.
Incaseofanerror,printfreturns-1.
Seealsosprintf,output,fileerror

Format string
Theformatstringcontrolshowtheargumentswillbeconverted,formattedandprinted.
Theremustbeexactlyasmanyargumentsasnecessaryfortheformat.Thenumberand
typeofargumentswillbecheckedagainsttheformat,andanymismatchwillleadtoan
errormessage.
Theformatstringcontainstwotypesofobjectsplaincharactersandformatspecifiers:

Plaincharactersaresimplycopiedverbatimtotheoutput
Formatspecifiersfetchargumentsfromtheargumentlistandapplyformattingto
them

Page89of132

EAGLEUserLanguage

Format specifiers
Aformatspecifierhasthefollowingform:
% [flags] [width] [.prec] type
Eachformatspecificationbeginswiththepercentcharacter(%).Afterthe%comesthe
following,inthisorder:

anoptionalsequenceofflagcharacters,[flags]
anoptionalwidthspecifier,[width]
anoptionalprecisionspecifier,[.prec]
theconversiontypecharacter,type

Conversion type characters


d
o
u
x
X
f
e
E
g
G
c
s
%

signeddecimalint
unsignedoctalint
unsigneddecimalint
unsignedhexadecimalint(witha,b,...)
unsignedhexadecimalint(withA,B,...)
signedrealvalueoftheform[-]dddd.dddd
signedrealvalueoftheform[-]d.dddde[]ddd
samease,butwithEforexponent
signedrealvalueineithereorfform,basedongivenvalueand
precision
sameasg,butwithEforexponentifeformatused
singlecharacter
characterstring
the%characterisprinted

Flag characters
Thefollowingflagcharacterscanappearinanyorderandcombination.
""
"+
"
"
"

theformatteditemisleftjustifiedwithinthefield;normally,itemsarerightjustified
asigned,positiveitemwillalwaysstartwithapluscharacter(+);normally,only
negativeitemsbeginwithasign
asigned,positiveitemwillalwaysstartwithaspacecharacter;ifboth"+"and" "
arespecified,"+"overrides" "

Width specifiers
Thewidthspecifiersetstheminimumfieldwidthforanoutputvalue.
Widthisspecifiedeitherdirectly,throughadecimaldigitstring,orindirectly,throughan
asterisk(*).Ifyouuseanasteriskforthewidthspecifier,thenextargumentinthecall
(whichmustbeanint)specifiestheminimumoutputfieldwidth.
Innocasedoesanonexistentorsmallfieldwidthcausetruncationofafield.Iftheresultof
Page90of132

EAGLEUserLanguage
aconversioniswiderthanthefieldwidth,thefieldissimplyexpandedtocontainthe
conversionresult.
Atleastncharactersareprinted.Iftheoutputvaluehaslessthanncharacters,the
outputispaddedwithblanks(rightpaddedif"-"flaggiven,leftpaddedotherwise).
Atleastncharactersareprinted.Iftheoutputvaluehaslessthanncharacters,itis
0n
filledontheleftwithzeroes.
Theargumentlistsuppliesthewidthspecifier,whichmustprecedetheactual
*
argumentbeingformatted.
n

Precision specifiers
Aprecisionspecifieralwaysbeginswithaperiod(.)toseparateitfromanypreceding
widthspecifier.Then,likewidth,precisionisspecifiedeitherdirectlythroughadecimal
digitstring,orindirectly,throughanasterisk(*).Ifyouuseanasteriskfortheprecision
specifier,thenextargumentinthecall(whichmustbeanint)specifiestheprecision.
none Precisionsettodefault.
.0
Forinttypes,precisionissettodefault;forrealtypes,nodecimalpointisprinted.
ncharactersorndecimalplacesareprinted.Iftheoutputvaluehasmorethann
.n
characterstheoutputmightbetruncatedorrounded(dependingonthetype
character).
Theargumentlistsuppliestheprecisionspecifier,whichmustprecedetheactual
*
argumentbeingformatted.

Default precision values


douxX
eEf
gG
c
s

1
6
allsignificantdigits
noeffect
printentirestring

How precision specification (.n) affects conversion


.nspecifiesthatatleastncharactersareprinted.Iftheinputargumenthasless
douxX thanndigits,theoutputvalueisleftpaddedwithzeros.Iftheinputargumenthas
morethanndigits,theoutputvalueisnottruncated.
.nspecifiesthatncharactersareprintedafterthedecimalpoint,andthelastdigit
eEf
printedisrounded.
gG
.nspecifiesthatatmostnsignificantdigitsareprinted.
c
.nhasnoeffectontheoutput.
s
.nspecifiesthatnomorethanncharactersareprinted.

Binary zero characters


Unlikesprintf,theprintffunctioncanprintbinaryzerocharacters(0x00).
char c = 0x00;
printf("%c", c);

Page91of132

EAGLEUserLanguage

Example
int i = 42;
real r = 3.14;
char c = 'A';
string s = "Hello";
printf("Integer: %8d\n", i);
printf("Hex:
%8X\n", i);
printf("Real:
%8f\n", r);
printf("Char:
%-8c\n", c);
printf("String: %-8s\n", s);

sprintf()
Function
Writesformattedoutputintoastring.
Syntax
int sprintf(string result, string format[, argument, ...]);
Returns
Thesprintffunctionreturnsthenumberofcharacterswrittenintotheresult
string.
Incaseofanerror,sprintfreturns-1.
Seealsoprintf

Format string
Seeprintf.

Binary zero characters


Notethatsprintfcannotreturnstringswithembeddedbinaryzerocharacters(0x00).If
theresultingstringcontainsabinaryzerocharacter,anycharactersfollowingthatzero
characterwillbedropped.Useprintfifyouneedtooutputbinarydata.

Example
string result;
int number = 42;
sprintf(result, "The number is %d", number);

String Functions
Stringfunctionsareusedtomanipulatecharacterstrings.
Thefollowingstringfunctionsareavailable:

strchr()
strjoin()
strlen()
Page92of132

EAGLEUserLanguage

strlwr()
strrchr()
strrstr()
strsplit()
strstr()
strsub()
strtod()
strtol()
strupr()

strchr()
Function
Scansastringforthefirstoccurrenceofagivencharacter.
Syntax
int strchr(string s, char c[, int index]);
Returns
Thestrchrfunctionreturnstheintegeroffsetofthecharacterinthestring,or-1if
thecharacterdoesnotoccurinthestring.
Seealsostrrchr,strstr
Ifindexisgiven,thesearchstartsatthatposition.Negativevaluesarecountedfromthe
endofthestring.

Example
string s = "This is a string";
char c = 'a';
int pos = strchr(s, c);
if (pos >= 0)
printf("The character %c is at position %d\n", c, pos);
else
printf("The character was not found\n");

strjoin()
Function
Joinsastringarraytoformasinglestring.
Syntax
string strjoin(string array[], char separator);
Returns
Thestrjoinfunctionreturnsthecombinedentriesofarray.
Seealsostrsplit,lookup,fileread
strjoinjoinsallentriesinarray,delimitedbythegivenseparatorandreturnsthe
resultingstring.

Page93of132

EAGLEUserLanguage
Ifseparatoristhenewlinecharacter("\n")theresultingstringwillbeterminatedwith
anewlinecharacter.ThisisdonetohaveatextfilethatconsistsofNlines(eachofwhichis
terminatedwithanewline)andisreadinwiththefileread()functionandsplitintoan
arrayofNstringstobejoinedtotheoriginalstringasreadfromthefile.

Example
string a[] = { "Field 1", "Field 2", "Field 3" };
string s = strjoin(a, ':');

strlen()
Function
Calculatesthelengthofastring.
Syntax
int strlen(string s);
Returns
Thestrlenfunctionreturnsthenumberofcharactersinthestring.

Example
string s = "This is a string";
int l = strlen(s);
printf("The string is %d characters long\n", l);

strlwr()
Function
Convertsuppercaselettersinastringtolowercase.
Syntax
string strlwr(string s);
Returns
Thestrlwrfunctionreturnsthemodifiedstring.Theoriginalstring(givenas
parameter)isnotchanged.
Seealsostrupr,tolower

Example
string s = "This Is A String";
string r = strlwr(s);
printf("Prior to strlwr: %s - after strlwr: %s\n", s, r);

strrchr()
Function
Scansastringforthelastoccurrenceofagivencharacter.
Page94of132

EAGLEUserLanguage
Syntax
int strrchr(string s, char c[, int index]);
Returns
Thestrrchrfunctionreturnstheintegeroffsetofthecharacterinthestring,or-1if
thecharacterdoesnotoccurinthestring.
Seealsostrchr,strrstr
Ifindexisgiven,thesearchstartsatthatposition.Negativevaluesarecountedfromthe
endofthestring.

Example
string s = "This is a string";
char c = 'a';
int pos = strrchr(s, c);
if (pos >= 0)
printf("The character %c is at position %d\n", c, pos);
else
printf("The character was not found\n");

strrstr()
Function
Scansastringforthelastoccurrenceofagivensubstring.
Syntax
int strrstr(string s1, string s2[, int index]);
Returns
Thestrrstrfunctionreturnstheintegeroffsetofthefirstcharacterofs2ins1,or1ifthesubstringdoesnotoccurinthestring.
Seealsostrstr,strrchr
Ifindexisgiven,thesearchstartsatthatposition.Negativevaluesarecountedfromthe
endofthestring.

Example
string s1 = "This is a string", s2 = "is a";
int pos = strrstr(s1, s2);
if (pos >= 0)
printf("The substring starts at %d\n", pos);
else
printf("The substring was not found\n");

strsplit()
Function
Splitsastringintoseparatefields.
Syntax
Page95of132

EAGLEUserLanguage
int strsplit(string &array[], string s, char separator);
Returns
Thestrsplitfunctionreturnsthenumberofentriescopiedintoarray.
Seealsostrjoin,lookup,fileread
strsplitsplitsthestringsatthegivenseparatorandstorestheresultingfieldsinthe
array.
Ifseparatoristhenewlinecharacter("\n")thelastfieldwillbesilentlydroppedifitis
empty.ThisisdonetohaveatextfilethatconsistsofNlines(eachofwhichisterminated
withanewline)andisreadinwiththefileread()functiontobesplitintoanarrayofN
strings.Withanyotherseparatoranemptyfieldattheendofthestringwillcount,so
"a:b:c:"willresultin4fields,thelastofwhichisempty.

Example
string a[];
int n = strsplit(a, "Field 1:Field 2:Field 3", ':');

strstr()
Function
Scansastringforthefirstoccurrenceofagivensubstring.
Syntax
int strstr(string s1, string s2[, int index]);
Returns
Thestrstrfunctionreturnstheintegeroffsetofthefirstcharacterofs2ins1,or-1
ifthesubstringdoesnotoccurinthestring.
Seealsostrrstr,strchr
Ifindexisgiven,thesearchstartsatthatposition.Negativevaluesarecountedfromthe
endofthestring.

Example
string s1 = "This is a string", s2 = "is a";
int pos = strstr(s1, s2);
if (pos >= 0)
printf("The substring starts at %d\n", pos);
else
printf("The substring was not found\n");

strsub()
Function
Extractsasubstringfromastring.
Syntax
Page96of132

EAGLEUserLanguage
string strsub(string s, int start[, int length]);
Returns
Thestrsubfunctionreturnsthesubstringindicatedbythestartandlength
value.
Thevalueforlengthmustbepositive,otherwiseanemptystringwillbereturned.If
lengthisommitted,therestofthestring(beginningatstart)isreturned.
Ifstartpointstoapositionoutsidethestring,anemptystringisreturned.

Example
string s = "This is a string";
string t = strsub(s, 4, 7);
printf("The extracted substring is: %s\n", t);

strtod()
Function
Convertsastringtoarealvalue.
Syntax
real strtod(string s);
Returns
Thestrtodfunctionreturnsthenumericalrepresentationofthegivenstringasa
realvalue.Conversionendsatthefirstcharacterthatdoesnotfitintotheformatof
arealconstant.Ifanerroroccursduringconversionofthestring0.0willbe
returned.
Seealsostrtol

Example
string s = "3.1415";
real r = strtod(s);
printf("The value is %f\n", r);

strtol()
Function
Convertsastringtoanintegervalue.
Syntax
int strtol(string s);
Returns
Thestrtolfunctionreturnsthenumericalrepresentationofthegivenstringasan
intvalue.Conversionendsatthefirstcharacterthatdoesnotfitintotheformatof
anintegerconstant.Ifanerroroccursduringconversionofthestring0willbe
returned.
Page97of132

EAGLEUserLanguage
Seealsostrtod

Example
string s = "1234";
int i = strtol(s);
printf("The value is %d\n", i);

strupr()
Function
Convertslowercaselettersinastringtouppercase.
Syntax
string strupr(string s);
Returns
Thestruprfunctionreturnsthemodifiedstring.Theoriginalstring(givenas
parameter)isnotchanged.
Seealsostrlwr,toupper

Example
string s = "This Is A String";
string r = strupr(s);
printf("Prior to strupr: %s - after strupr: %s\n", s, r);

Time Functions
Timefunctionsareusedtogetandprocesstimeanddateinformation.
Thefollowingtimefunctionsareavailable:

t2day()
t2dayofweek()
t2hour()
t2minute()
t2month()
t2second()
t2string()
t2year()
time()
timems()

time()
Function
Getsthecurrentsystemtime.
Syntax
int time(void);
Page98of132

EAGLEUserLanguage
Returns
Thetimefunctionreturnsthecurrentsystemtimeasthenumberofsecondselapsed
sinceasystemdependentreferencedate.
SeealsoTimeConversions,filetime,timems()

Example
int CurrentTime = time();

timems()
Function
GetsthenumberofmillisecondssincethestartoftheULP.
Syntax
int timems(void);
Returns
ThetimemsfunctionreturnsthenumberofmillisecondssincethestartoftheULP.
After86400000milliseconds(i.e.every24hours),thevaluestartsat0again.
Seealsotime

Example
int elapsed = timems();

Time Conversions
Function
Convertatimevaluetoday,month,yearetc.
Syntax
int t2day(int t);
int t2dayofweek(int t);
int t2hour(int t);
int t2minute(int t);
int t2month(int t);
int t2second(int t);
int t2year(int t);
string t2string(int t);
Returns
t2day returnsthedayofthemonth(1..31)
t2dayofweekreturnsthedayoftheweek(0=sunday..6)
t2hour returnsthehour(0..23)
t2minute returnstheminute(0..59)
t2month returnsthemonth(0..11)
Page99of132

EAGLEUserLanguage
t2second returnsthesecond(0..59)
t2year returnstheyear(includingcentury!)
t2string returnsaformattedstringcontainingdateandtime
Seealsotime

Example
int t = time();
printf("It is now %02d:%02d:%02d\n",
t2hour(t), t2minute(t), t2second(t));

Object Functions
Objectfunctionsareusedtoaccesscommoninformationaboutobjects.
Thefollowingobjectfunctionsareavailable:

ingroup()

ingroup()
Function
Checkswhetheranobjectisinthegroup.
Syntax
int ingroup(object);
Returns
Theingroupfunctionreturnsanonzerovalueifthegivenobjectisinthegroup.
SeealsoGROUPcommand
Ifagrouphasbeendefinedintheeditor,theingroup()functioncanbeusedtocheck
whetheraparticularobjectispartofthegroup.
Objectswithasinglecoordinatethatareindividuallyselectableinthecurrentdrawing(like
UL_TEXT,UL_VIA,UL_CIRCLEetc.)returnanonzerovalueinacalltoingroup()ifthat
coordinateiswithinthedefinedgroup.
AUL_WIREreturns0,1,2or3,dependingonwhethernone,thefirst,thesecondorboth
ofitsendpointsareinthegroup.
AUL_RECTANGLEandUL_FRAMEreturnsanonzerovalueifoneormoreofitscorners
areinthegroup.
Objectsthathavenocoordinates(likeUL_NET,UL_SEGMENT,UL_SIGNALetc.)returna
nonzerovalueifoneormoreoftheobjectswithinthemareinthegroup.
UL_CONTACTREFandUL_PINREF,thoughnothavingcoordinatesoftheirown,returna
nonzerovalueifthereferencedUL_CONTACTorUL_PIN,respectively,iswithinthegroup.

Page100of132

EAGLEUserLanguage

Example
output("group.txt") {
board(B) {
B.elements(E) {
if (ingroup(E))
printf("Element %s is in the group\n", E.name);
}
}
}

Builtin Statements
Builtinstatementsaregenerallyusedtoopenacertaincontextinwhichdatastructuresof
filescanbeaccessed.
Thegeneralsyntaxofabuiltinstatementis
name(parameters) statement

wherenameisthenameofthebuiltinstatement,parametersstandsforoneormore
parameters,andstatementisthecodethatwillbeexecutedinsidethecontextopenedby
thebuiltinstatement.
Notethatstatementcanbeacompoundstatement,asin
board(B) {
B.elements(E) printf("Element: %s\n", E.name);
B.Signals(S) printf("Signal: %s\n", S.name);
}

Thefollowingbuiltinstatementsareavailable:

board()
deviceset()
library()
output()
package()
schematic()
sheet()
symbol()

board()
Function
Opensaboardcontext.
Syntax
board(identifier) statement
Seealsoschematic,library
Theboardstatementopensaboardcontextifthecurrenteditorwindowcontainsaboard
drawing.AvariableoftypeUL_BOARDiscreatedandisgiventhenameindicatedby
Page101of132

EAGLEUserLanguage
identifier.
Oncetheboardcontextissuccessfullyopenedandaboardvariablehasbeencreated,the
statementisexecuted.Withinthescopeofthestatementtheboardvariablecanbe
accessedtoretrievefurtherdatafromtheboard.
Ifthecurrenteditorwindowdoesnotcontainaboarddrawing,anerrormessageisgiven
andtheULPisterminated.

Check if there is a board


Byusingtheboardstatementwithoutanargumentyoucancheckifthecurrenteditor
windowcontainsaboarddrawing.Inthatcase,boardbehaveslikeanintegerconstant,
returning1ifthereisaboarddrawinginthecurrenteditorwindow,and0otherwise.

Accessing board from a schematic


Ifthecurrenteditorwindowcontainsaschematicdrawing,youcanstillaccessthat
schematic'sboardbyprecedingtheboardstatementwiththeprefixproject,asin
project.board(B) { ... }

Thiswillopenaboardcontextregardlesswhetherthecurrenteditorwindowcontainsa
boardoraschematicdrawing.However,theremustbeaneditorwindowcontainingthat
boardsomewhereonthedesktop!

Example
if (board)
board(B) {
B.elements(E)
printf("Element: %s\n", E.name);
}

deviceset()
Function
Opensadevicesetcontext.
Syntax
deviceset(identifier) statement
Seealsopackage,symbol,library
Thedevicesetstatementopensadevicesetcontextifthecurrenteditorwindowcontains
adevicedrawing.AvariableoftypeUL_DEVICESETiscreatedandisgiventhename
indicatedbyidentifier.
Oncethedevicesetcontextissuccessfullyopenedandadevicesetvariablehasbeen
created,thestatementisexecuted.Withinthescopeofthestatementthedeviceset
variablecanbeaccessedtoretrievefurtherdatafromthedeviceset.

Page102of132

EAGLEUserLanguage
Ifthecurrenteditorwindowdoesnotcontainadevicedrawing,anerrormessageisgiven
andtheULPisterminated.

Check if there is a device set


Byusingthedevicesetstatementwithoutanargumentyoucancheckifthecurrent
editorwindowcontainsadevicedrawing.Inthatcase,devicesetbehaveslikeaninteger
constant,returning1ifthereisadevicedrawinginthecurrenteditorwindow,and0
otherwise.

Example
if (deviceset)
deviceset(D) {
D.gates(G)
printf("Gate: %s\n", G.name);
}

library()
Function
Opensalibrarycontext.
Syntax
library(identifier) statement
Seealsoboard,schematic,deviceset,package,symbol
Thelibrarystatementopensalibrarycontextifthecurrenteditorwindowcontainsa
librarydrawing.AvariableoftypeUL_LIBRARYiscreatedandisgiventhenameindicated
byidentifier.
Oncethelibrarycontextissuccessfullyopenedandalibraryvariablehasbeencreated,the
statementisexecuted.Withinthescopeofthestatementthelibraryvariablecanbe
accessedtoretrievefurtherdatafromthelibrary.
Ifthecurrenteditorwindowdoesnotcontainalibrarydrawing,anerrormessageisgiven
andtheULPisterminated.

Check if there is a library


Byusingthelibrarystatementwithoutanargumentyoucancheckifthecurrenteditor
windowcontainsalibrarydrawing.Inthatcase,librarybehaveslikeanintegerconstant,
returning1ifthereisalibrarydrawinginthecurrenteditorwindow,and0otherwise.

Example
if (library)
library(L) {
L.devices(D)
printf("Device: %s\n", D.name);
}

Page103of132

EAGLEUserLanguage

output()
Function
Opensanoutputfileforsubsequentprintf()calls.
Syntax
output(string filename[, string mode]) statement
Seealsoprintf,fileerror
Theoutputstatementopensafilewiththegivenfilenameandmodeforoutputthrough
subsequentprintf()calls.Ifthefilehasbeensuccessfullyopened,thestatementis
executed,andafterthatthefileisclosed.
Ifthefilecannotbeopened,anerrormessageisgivenandexecutionoftheULPis
terminated.
BydefaulttheoutputfileiswrittenintotheProjectdirectory.

File Modes
Themodeparameterdefineshowtheoutputfileistobeopened.Ifnomodeparameteris
given,thedefaultis"wt".
appendtoanexistingfile,orcreateanewfileifitdoesnotexist
createanewfile(overwritinganexistingfile)
openfileintextmode
openfileinbinarymode
deletethisfilewhenendingtheEAGLEsession(onlyworkstogetherwith
D
w)
F forceusingthisfilename(normally*.brd,*.schand*.lbrarerejected)
Modecharactersmayappearinanyorderandcombination.However,onlythelastoneofa
andwortandb,respectively,issignificant.Forexampleamodeof"abtw"wouldopena
filefortextualwrite,whichwouldbethesameas"wt".
a
w
t
b

Nested Output statements


outputstatementscanbenested,aslongasthereareenoughfilehandlesavailable,and
providedthatnotwoactiveoutputstatementsaccessthesamefile.

Example
void PrintText(string s)
{
printf("This also goes into the file: %s\n", s);
}
output("file.txt", "wt") {
printf("Directly printed\n");
PrintText("via function call");
}

Page104of132

EAGLEUserLanguage

package()
Function
Opensapackagecontext.
Syntax
package(identifier) statement
Seealsolibrary,deviceset,symbol
Thepackagestatementopensapackagecontextifthecurrenteditorwindowcontainsa
packagedrawing.AvariableoftypeUL_PACKAGEiscreatedandisgiventhename
indicatedbyidentifier.
Oncethepackagecontextissuccessfullyopenedandapackagevariablehasbeencreated,
thestatementisexecuted.Withinthescopeofthestatementthepackagevariablecan
beaccessedtoretrievefurtherdatafromthepackage.
Ifthecurrenteditorwindowdoesnotcontainapackagedrawing,anerrormessageisgiven
andtheULPisterminated.

Check if there is a package


Byusingthepackagestatementwithoutanargumentyoucancheckifthecurrenteditor
windowcontainsapackagedrawing.Inthatcase,packagebehaveslikeaninteger
constant,returning1ifthereisapackagedrawinginthecurrenteditorwindow,and0
otherwise.

Example
if (package)
package(P) {
P.contacts(C)
printf("Contact: %s\n", C.name);
}

schematic()
Function
Opensaschematiccontext.
Syntax
schematic(identifier) statement
Seealsoboard,library,sheet
Theschematicstatementopensaschematiccontextifthecurrenteditorwindowcontains
aschematicdrawing.AvariableoftypeUL_SCHEMATICiscreatedandisgiventhename
indicatedbyidentifier.
Oncetheschematiccontextissuccessfullyopenedandaschematicvariablehasbeen
created,thestatementisexecuted.Withinthescopeofthestatementtheschematic
Page105of132

EAGLEUserLanguage
variablecanbeaccessedtoretrievefurtherdatafromtheschematic.
Ifthecurrenteditorwindowdoesnotcontainaschematicdrawing,anerrormessageis
givenandtheULPisterminated.

Check if there is a schematic


Byusingtheschematicstatementwithoutanargumentyoucancheckifthecurrent
editorwindowcontainsaschematicdrawing.Inthatcase,schematicbehaveslikean
integerconstant,returning1ifthereisaschematicdrawinginthecurrenteditorwindow,
and0otherwise.

Accessing schematic from a board


Ifthecurrenteditorwindowcontainsaboarddrawing,youcanstillaccessthatboard's
schematicbyprecedingtheschematicstatementwiththeprefixproject,asin
project.schematic(S) { ... }

Thiswillopenaschematiccontextregardlesswhetherthecurrenteditorwindowcontainsa
schematicoraboarddrawing.However,theremustbeaneditorwindowcontainingthat
schematicsomewhereonthedesktop!

Access the current Sheet


Usethesheetstatementtodirectlyaccessthecurrentlyloadedsheet.

Example
if (schematic)
schematic(S) {
S.parts(P)
printf("Part: %s\n", P.name);
}

sheet()
Function
Opensasheetcontext.
Syntax
sheet(identifier) statement
Seealsoschematic
Thesheetstatementopensasheetcontextifthecurrenteditorwindowcontainsasheet
drawing.AvariableoftypeUL_SHEETiscreatedandisgiventhenameindicatedby
identifier.
Oncethesheetcontextissuccessfullyopenedandasheetvariablehasbeencreated,the
statementisexecuted.Withinthescopeofthestatementthesheetvariablecanbe
accessedtoretrievefurtherdatafromthesheet.
Page106of132

EAGLEUserLanguage
Ifthecurrenteditorwindowdoesnotcontainasheetdrawing,anerrormessageisgiven
andtheULPisterminated.

Check if there is a sheet


Byusingthesheetstatementwithoutanargumentyoucancheckifthecurrenteditor
windowcontainsasheetdrawing.Inthatcase,sheetbehaveslikeanintegerconstant,
returning1ifthereisasheetdrawinginthecurrenteditorwindow,and0otherwise.

Example
if (sheet)
sheet(S) {
S.parts(P)
printf("Part: %s\n", P.name);
}

symbol()
Function
Opensasymbolcontext.
Syntax
symbol(identifier) statement
Seealsolibrary,deviceset,package
Thesymbolstatementopensasymbolcontextifthecurrenteditorwindowcontainsa
symboldrawing.AvariableoftypeUL_SYMBOLiscreatedandisgiventhenameindicated
byidentifier.
Oncethesymbolcontextissuccessfullyopenedandasymbolvariablehasbeencreated,the
statementisexecuted.Withinthescopeofthestatementthesymbolvariablecanbe
accessedtoretrievefurtherdatafromthesymbol.
Ifthecurrenteditorwindowdoesnotcontainasymboldrawing,anerrormessageisgiven
andtheULPisterminated.

Check if there is a symbol


Byusingthesymbolstatementwithoutanargumentyoucancheckifthecurrenteditor
windowcontainsasymboldrawing.Inthatcase,symbolbehaveslikeanintegerconstant,
returning1ifthereisasymboldrawinginthecurrenteditorwindow,and0otherwise.

Example
if (symbol)
symbol(S) {
S.pins(P)
printf("Pin: %s\n", P.name);
}

Page107of132

EAGLEUserLanguage

Dialogs
UserLanguageDialogsallowyoutodefineyourownfrontendtoaUserLanguageProgram.
ThefollowingsectionsdescribeUserLanguageDialogsindetail:
PredefinedDialogs
DialogObjects
LayoutInformation
DialogFunctions
ACompleteExample

describesthereadytousestandarddialogs
definestheobjectsthatcanbeusedinadialog
explainshowtodefinethelocationofobjectswithina
dialog
describesspecialfunctionsforusewithdialogs
showsacompleteULPwithadataentrydialog

Predefined Dialogs
PredefinedDialogsimplementthetypicalstandarddialogsthatarefrequentlyusedfor
selectingfilenamesorissuingerrormessages.
Thefollowingpredefineddialogsareavailable:

dlgDirectory()
dlgFileOpen()
dlgFileSave()
dlgMessageBox()

SeeDialogObjectsforinformationonhowtodefineyourowncomplexuserdialogs.

dlgDirectory()
Function
Displaysadirectorydialog.
Syntax
string dlgDirectory(string Title[, string Start])
Returns
ThedlgDirectoryfunctionreturnsthefullpathnameoftheselecteddirectory.
Iftheuserhascanceledthedialog,theresultwillbeanemptystring.
SeealsodlgFileOpen
ThedlgDirectoryfunctiondisplaysadirectorydialogfromwhichtheusercanselecta
directory.
Titlewillbeusedasthedialog'stitle.
IfStartisnotempty,itwillbeusedasthestartingpointforthedlgDirectory.

Example
string dirName;
dirName = dlgDirectory("Select a directory", "");

Page108of132

EAGLEUserLanguage

dlgFileOpen(), dlgFileSave()
Function
Displaysafiledialog.
Syntax
string dlgFileOpen(string Title[, string Start[, string
Filter]])
string dlgFileSave(string Title[, string Start[, string
Filter]])
Returns
ThedlgFileOpenanddlgFileSavefunctionsreturnthefullpathnameofthe
selectedfile.
Iftheuserhascanceledthedialog,theresultwillbeanemptystring.
SeealsodlgDirectory
ThedlgFileOpenanddlgFileSavefunctionsdisplayafiledialogfromwhichtheuser
canselectafile.
Titlewillbeusedasthedialog'stitle.
IfStartisnotempty,itwillbeusedasthestartingpointforthefiledialog.Otherwisethe
currentdirectorywillbeused.
OnlyfilesmatchingFilterwillbedisplayed.IfFilterisempty,allfileswillbe
displayed.
Filtercanbeeitherasimplewildcard(asin"*.brd"),alistofwildcards(asin
"*.bmp *.jpg")ormayevencontaindescriptivetext,asin
"Bitmap files (*.bmp)".Ifthe"Filetype"comboboxofthefiledialogshallcontain
severalentries,theyhavetobeseparatedbydoublesemicolons,asin
"Bitmap files (*.bmp);;Other images (*.jpg *.png)".

Example
string fileName;
fileName = dlgFileOpen("Select a file", "", "*.brd");

dlgMessageBox()
Function
Displaysamessagebox.
Syntax
int dlgMessageBox(string Message[, button_list])
Returns
ThedlgMessageBoxfunctionreturnstheindexofthebuttontheuserhasselected.
Thefirstbuttoninbutton_listhasindex0.
Seealsostatus()
Page109of132

EAGLEUserLanguage
ThedlgMessageBoxfunctiondisplaysthegivenMessageinamodaldialogandwaits
untiltheuserselectsoneofthebuttonsdefinedinbutton_list.
IfMessagecontainsanyHTMLtags,thecharacters'<','>'and'&'mustbegivenas"&lt;",
"&gt;"and"&amp;",respectively,iftheyshallbedisplayedassuch.
button_listisanoptionallistofcommaseparatedstrings,whichdefinesthesetof
buttonsthatwillbedisplayedatthebottomofthemessagebox.
Amaximumofthreebuttonscanbedefined.Ifnobutton_listisgiven,itdefaultsto
"OK".
Thefirstbuttoninbutton_listwillbecomethedefaultbutton(whichwillbeselectedif
theuserhitsENTER),andthelastbuttoninthelistwillbecomethe"cancelbutton",which
isselectediftheuserhitsESCapeorclosesthemessagebox.Youcanmakeadifferent
buttonthedefaultbuttonbystartingitsnamewitha'+',andyoucanmakeadifferent
buttonthecancelbuttonbystartingitsnamewitha'-'.Tostartabuttontextwithan
actual'+'or'-'ithastobeescaped.
Ifabuttontextcontainsan'&',thecharacterfollowingtheampersandwillbecomea
hotkey,andwhentheuserhitsthecorrespondingkey,thatbuttonwillbeselected.Tohave
anactual'&'characterinthetextithastobeescaped.
ThemessageboxcanbegivenaniconbysettingthefirstcharacterofMessageto
';'foranInformation
'!'foraWarning
':'foranError
If,however,theMessageshallbeginwithoneofthesecharacters,ithastobeescaped.
OnMacOSXonlythecharacter':'willactuallyresultinshowinganicon.All
othersareignored.

Example
if (dlgMessageBox("!Are you sure?", "&Yes", "&No") == 0) {
// let's do it!
}

Dialog Objects
AUserLanguageDialogisbuiltfromthefollowingDialogObjects:
dlgCell
dlgCheckBox
dlgComboBox
dlgDialog
dlgGridLayout
dlgGroup
dlgHBoxLayout
dlgIntEdit

agridcellcontext
acheckbox
acomboboxselectionfield
thebasiccontainerofany
dialog
agridbasedlayoutcontext
agroupfield
ahorizontalboxlayoutcontext
anintegerentryfield
Page110of132

EAGLEUserLanguage
dlgLabel
dlgListBox
dlgListView
dlgPushButton
dlgRadioButton
dlgRealEdit
dlgSpacing
dlgSpinBox
dlgStretch
dlgStringEdit
dlgTabPage
dlgTabWidget
dlgTextEdit
dlgTextView
dlgVBoxLayout

atextlabel
alistbox
alistview
apushbutton
aradiobutton
arealentryfield
alayoutspacingobject
aspinboxselectionfield
alayoutstretchobject
astringentryfield
atabpage
atabpagecontainer
atextentryfield
atextviewerfield
averticalboxlayoutcontext

dlgCell
Function
Definesacelllocationwithinagridlayoutcontext.
Syntax
dlgCell(int row, int column[, int row2, int column2])
statement
SeealsodlgGridLayout,dlgHBoxLayout,dlgVBoxLayout,LayoutInformation,AComplete
Example
ThedlgCellstatementdefinesthelocationofacellwithinagridlayoutcontext.
Therowandcolumnindexesstartat0,sotheupperleftcellhastheindex(0,0).
Withtwoparametersthedialogobjectdefinedbystatementwillbeplacedinthesingle
celladdressesbyrowandcolumn.Withfourparametersthedialogobjectwillspanover
allcellsfromrow/columntorow2/column2.
BydefaultadlgCellcontainsadlgHBoxLayout,soifthecellcontainsmorethanone
dialogobject,theywillbeplacednexttoeachotherhorizontally.

Example
string Text;
dlgGridLayout {
dlgCell(0, 0) dlgLabel("Cell 0,0");
dlgCell(1, 2, 4, 7) dlgTextEdit(Text);
}

dlgCheckBox
Function
Definesacheckbox.
Page111of132

EAGLEUserLanguage
Syntax
dlgCheckBox(string Text, int &Checked) [ statement ]
SeealsodlgRadioButton,dlgGroup,LayoutInformation,ACompleteExample
ThedlgCheckBoxstatementdefinesacheckboxwiththegivenText.
IfTextcontainsan'&',thecharacterfollowingtheampersandwillbecomeahotkey,and
whentheuserhitsAlt+hotkey,thecheckboxwillbetoggled.Tohaveanactual'&'
characterinthetextithastobeescaped.
dlgCheckBoxismainlyusedwithinadlgGroup,butcanalsobeusedotherwise.
AllcheckboxeswithinthesamedialogmusthavedifferentCheckedvariables!
IftheuserchecksadlgCheckBox,theassociatedCheckedvariableissetto1,otherwise
itissetto0.TheinitialvalueofCheckeddefineswhetheracheckboxisinitiallychecked.
IfCheckedisnotequalto0,thecheckboxisinitiallychecked.
TheoptionalstatementisexecutedeverytimethedlgCheckBoxistoggled.

Example
int mirror = 0;
int rotate = 1;
int flip
= 0;
dlgGroup("Orientation") {
dlgCheckBox("&Mirror", mirror);
dlgCheckBox("&Rotate", rotate);
dlgCheckBox("&Flip", flip);
}

dlgComboBox
Function
Definesacomboboxselectionfield.
Syntax
dlgComboBox(string array[], int &Selected) [ statement ]
SeealsodlgListBox,dlgLabel,LayoutInformation,ACompleteExample
ThedlgComboBoxstatementdefinesacomboboxselectionfieldwiththecontentsofthe
givenarray.
Selectedreflectstheindexoftheselectedcomboboxentry.Thefirstentryhasindex0.
Eachelementofarraydefinesthecontentsofoneentryinthecombobox.Noneofthe
stringsinarraymaybeempty(ifthereisanemptystring,allstringsafterandincluding
thatonewillbedropped).
TheoptionalstatementisexecutedwhenevertheselectioninthedlgComboBox
changes.
Beforethestatementisexecuted,allvariablesthathavebeenusedwithdialogobjects
Page112of132

EAGLEUserLanguage
areupdatedtotheircurrentvalues,andanychangesmadetothesevariablesinsidethe
statementwillbereflectedinthedialogwhenthestatementreturns.
IftheinitialvalueofSelectedisoutsidetherangeofthearrayindexes,itissetto0.

Example
string Colors[] = { "red", "green", "blue", "yellow" };
int Selected = 2; // initially selects "blue"
dlgComboBox(Colors, Selected) dlgMessageBox("You have selected " +
Colors[Selected]);

dlgDialog
Function
ExecutesaUserLanguageDialog.
Syntax
int dlgDialog(string Title) block ;
Returns
ThedlgDialogfunctionreturnsanintegervaluethatcanbegivenauserdefined
meaningthroughacalltothedlgAccept()function.
Ifthedialogissimplyclosed,thereturnvaluewillbe0.
SeealsodlgGridLayout,dlgHBoxLayout,dlgVBoxLayout,dlgAccept,dlgReset,dlgReject,A
CompleteExample
ThedlgDialogfunctionexecutesthedialogdefinedbyblock.Thisistheonlydialog
objectthatactuallyisaUserLanguagebuiltinfunction.Thereforeitcanbeusedanywhere
whereafunctioncallisallowed.
Theblocknormallycontainsonlyotherdialogobjects,butitisalsopossibletouseother
UserLanguagestatements,forexampletoconditionallyaddobjectstothedialog(seethe
secondexamplebelow).
BydefaultadlgDialogcontainsadlgVBoxLayout,soasimpledialogdoesn'thaveto
worryaboutthelayout.
AdlgDialogshouldatsomepointcontainacalltothedlgAccept()functioninorder
toallowtheusertoclosethedialogandacceptitscontents.
Ifallyouneedisasimplemessageboxorfiledialogyoumightwanttouseoneofthe
PredefinedDialogsinstead.

Examples
int Result = dlgDialog("Hello") {
dlgLabel("Hello world");
dlgPushButton("+OK") dlgAccept();
};
int haveButton = 1;
dlgDialog("Test") {
dlgLabel("Start");

Page113of132

EAGLEUserLanguage
if (haveButton)
dlgPushButton("Here") dlgAccept();
};

dlgGridLayout
Function
Opensagridlayoutcontext.
Syntax
dlgGridLayout statement
SeealsodlgCell,dlgHBoxLayout,dlgVBoxLayout,LayoutInformation,AComplete
Example
ThedlgGridLayoutstatementopensagridlayoutcontext.
TheonlydialogobjectthatcanbeuseddirectlyinstatementisdlgCell,whichdefinesthe
locationofaparticulardialogobjectwithinthegridlayout.
Therowandcolumnindexesstartat0,sotheupperleftcellhastheindex(0,0).
Thenumberofrowsandcolumnsisautomaticallyextendedaccordingtothelocationof
dialogobjectsthataredefinedwithinthegridlayoutcontext,soyoudon'thavetoexplicitly
definethenumberofrowsandcolumns.

Example
dlgGridLayout {
dlgCell(0, 0)
dlgCell(1, 0)
dlgCell(0, 1)
dlgCell(1, 1)
}

dlgLabel("Row
dlgLabel("Row
dlgLabel("Row
dlgLabel("Row

0/Col
1/Col
0/Col
1/Col

0");
0");
1");
1");

dlgGroup
Function
Definesagroupfield.
Syntax
dlgGroup(string Title) statement
SeealsodlgCheckBox,dlgRadioButton,LayoutInformation,ACompleteExample
ThedlgGroupstatementdefinesagroupwiththegivenTitle.
BydefaultadlgGroupcontainsadlgVBoxLayout,soasimplegroupdoesn'thavetoworry
aboutthelayout.
dlgGroupismainlyusedtocontainasetofradiobuttonsorcheckboxes,butmayaswell
containanyotherobjectsinitsstatement.
RadiobuttonswithinadlgGrouparenumberedstartingwith0.

Page114of132

EAGLEUserLanguage

Example
int align = 1;
dlgGroup("Alignment") {
dlgRadioButton("&Top", align);
dlgRadioButton("&Center", align);
dlgRadioButton("&Bottom", align);
}

dlgHBoxLayout
Function
Opensahorizontalboxlayoutcontext.
Syntax
dlgHBoxLayout statement
SeealsodlgGridLayout,dlgVBoxLayout,LayoutInformation,ACompleteExample
ThedlgHBoxLayoutstatementopensahorizontalboxlayoutcontextforthegiven
statement.

Example
dlgHBoxLayout {
dlgLabel("Box 1");
dlgLabel("Box 2");
dlgLabel("Box 3");
}

dlgIntEdit
Function
Definesanintegerentryfield.
Syntax
dlgIntEdit(int &Value, int Min, int Max)
SeealsodlgRealEdit,dlgStringEdit,dlgLabel,LayoutInformation,ACompleteExample
ThedlgIntEditstatementdefinesanintegerentryfieldwiththegivenValue.
IfValueisinitiallyoutsidetherangedefinedbyMinandMaxitwillbelimitedtothese
values.

Example
int Value = 42;
dlgHBoxLayout {
dlgLabel("Enter a &Number between 0 and 99");
dlgIntEdit(Value, 0, 99);
}

Page115of132

EAGLEUserLanguage

dlgLabel
Function
Definesatextlabel.
Syntax
dlgLabel(string Text [, int Update])
SeealsoLayoutInformation,ACompleteExample,dlgRedisplay()
ThedlgLabelstatementdefinesalabelwiththegivenText.
Textcanbeeitherastringliteral,asin"Hello",orastringvariable.
IfTextcontainsanyHTMLtags,thecharacters'<','>'and'&'mustbegivenas"&lt;",
"&gt;"and"&amp;",respectively,iftheyshallbedisplayedassuch.
IftheUpdateparameterisnot0andTextisastringvariable,itscontentscanbe
modifiedinthestatementof,e.g.,adlgPushButton,andthelabelwillbeautomatically
updated.This,ofcourse,isonlyusefulifTextisadedicatedstringvariable(not,e.g.,the
loopvariableofaforstatement).
IfTextcontainsan'&',andtheobjectfollowingthelabelcanhavethekeyboardfocus,
thecharacterfollowingtheampersandwillbecomeahotkey,andwhentheuserhits
Alt+hotkey,thefocuswillgototheobjectthatwasdefinedimmediatelyfollowingthe
dlgLabel.Tohaveanactual'&'characterinthetextithastobeescaped.

Example
string OS = "Windows";
dlgHBoxLayout {
dlgLabel(OS, 1);
dlgPushButton("&Change OS") { OS = "Linux"; }
}

dlgListBox
Function
Definesalistboxselectionfield.
Syntax
dlgListBox(string array[], int &Selected) [ statement ]
SeealsodlgComboBox,dlgListView,dlgLabel,LayoutInformation,ACompleteExample
ThedlgListBoxstatementdefinesalistboxselectionfieldwiththecontentsofthegiven
array.
Selectedreflectstheindexoftheselectedlistboxentry.Thefirstentryhasindex0.
Eachelementofarraydefinesthecontentsofonelineinthelistbox.Noneofthestrings
inarraymaybeempty(ifthereisanemptystring,allstringsafterandincludingthatone
willbedropped).
Page116of132

EAGLEUserLanguage
Theoptionalstatementisexecutedwhenevertheuserdoubleclicksonanentryofthe
dlgListBox.
Beforethestatementisexecuted,allvariablesthathavebeenusedwithdialogobjects
areupdatedtotheircurrentvalues,andanychangesmadetothesevariablesinsidethe
statementwillbereflectedinthedialogwhenthestatementreturns.
IftheinitialvalueofSelectedisoutsidetherangeofthearrayindexes,noentrywillbe
selected.

Example
string Colors[] = { "red", "green", "blue", "yellow" };
int Selected = 2; // initially selects "blue"
dlgListBox(Colors, Selected) dlgMessageBox("You have selected " +
Colors[Selected]);

dlgListView
Function
Definesamulticolumnlistviewselectionfield.
Syntax
dlgListView(string Headers, string array[], int &Selected[,
int &Sort]) [ statement ]
SeealsodlgListBox,dlgLabel,LayoutInformation,ACompleteExample
ThedlgListViewstatementdefinesamulticolumnlistviewselectionfieldwiththe
contentsofthegivenarray.
Headersisthetabseparatedlistofcolumnheaders.
Selectedreflectstheindexoftheselectedlistviewentryinthearray(thesequencein
whichtheentriesareactuallydisplayedmaybedifferent,becausethecontentsofa
dlgListViewcanbesortedbythevariouscolumns).Thefirstentryhasindex0.
Ifnoparticularentryshallbeinitiallyselected,Selectedshouldbeinitializedto-1.
Sortdefineswhichcolumnshouldbeusedtosortthelistview.Theleftmostcolumnis
numbered1.Thesignofthisparameterdefinesthedirectioninwhichtosort(positive
valuessortinascendingorder).IfSortis0oroutsidethevalidnumberofcolumns,no
sortingwillbedone.ThereturnedvalueofSortreflectsthecolumnandsortmode
selectedbytheuserbyclickingonthelistcolumnheaders.BydefaultdlgListViewsorts
bythefirstcolumn,inascendingorder.
Eachelementofarraydefinesthecontentsofonelineinthelistview,andmustcontain
tabseparatedvalues.Iftherearefewervaluesinanelementofarraythanthereare
entriesintheHeadersstringtheremainingfieldswillbeempty.Iftherearemorevaluesin
anelementofarraythanthereareentriesintheHeadersstringthesuperfluous
elementswillbesilentlydropped.Noneofthestringsinarraymaybeempty(ifthereis
anemptystring,allstringsafterandincludingthatonewillbedropped).
Page117of132

EAGLEUserLanguage
Alistentrythatcontainslinefeeds('\n')willbedisplayedinseverallinesaccordingly.
Theoptionalstatementisexecutedwhenevertheuserdoubleclicksonanentryofthe
dlgListView.
Beforethestatementisexecuted,allvariablesthathavebeenusedwithdialogobjects
areupdatedtotheircurrentvalues,andanychangesmadetothesevariablesinsidethe
statementwillbereflectedinthedialogwhenthestatementreturns.
IftheinitialvalueofSelectedisoutsidetherangeofthearrayindexes,noentrywillbe
selected.
IfHeadersisanemptystring,thefirstelementofthearrayisusedastheheaderstring.
Consequentlytheindexofthefirstentryisthen1.
ThecontentsofadlgListViewcanbesortedbyanycolumnbyclickingonthatcolumn's
header.Columnscanalsobeswappedby"click&dragging"acolumnheader.Notethatnone
ofthesechangeswillhaveanyeffectonthecontentsofthearray.Ifthecontentsshallbe
sortedalphanumericallyanumeric string[]arraycanbeused.

Example
string Colors[] = { "red\tThe color RED", "green\tThe color GREEN", "blue\tThe
color BLUE" };
int Selected = 0; // initially selects "red"
dlgListView("Name\tDescription", Colors, Selected) dlgMessageBox("You have
selected " + Colors[Selected]);

dlgPushButton
Function
Definesapushbutton.
Syntax
dlgPushButton(string Text) statement
SeealsoLayoutInformation,DialogFunctions,ACompleteExample
ThedlgPushButtonstatementdefinesapushbuttonwiththegivenText.
IfTextcontainsan'&',thecharacterfollowingtheampersandwillbecomeahotkey,and
whentheuserhitsAlt+hotkey,thebuttonwillbeselected.Tohaveanactual'&'
characterinthetextithastobeescaped.
IfTextstartswitha'+'character,thisbuttonwillbecomethedefaultbutton,whichwill
beselectediftheuserhitsENTER.
IfTextstartswitha'-'character,thisbuttonwillbecomethecancelbutton,whichwill
beselectediftheuserclosesthedialog.
CAUTION:Makesurethatthestatementofsuchamarkedcancelbuttoncontainsa
calltodlgReject()!Otherwisetheusermaybeunabletoclosethedialogatall!
Tohaveanactual'+'or'-'characterasthefirstcharacterofthetextithastobe
escaped.
Page118of132

EAGLEUserLanguage
IftheuserselectsadlgPushButton,thegivenstatementisexecuted.
Beforethestatementisexecuted,allvariablesthathavebeenusedwithdialogobjects
areupdatedtotheircurrentvalues,andanychangesmadetothesevariablesinsidethe
statementwillbereflectedinthedialogwhenthestatementreturns.

Example
int defaultWidth = 10;
int defaultHeight = 20;
int width = 5;
int height = 7;
dlgPushButton("&Reset defaults") {
width = defaultWidth;
height = defaultHeight;
}
dlgPushButton("+&Accept") dlgAccept();
dlgPushButton("-Cancel") { if (dlgMessageBox("Are you sure?", "Yes", "No") == 0)
dlgReject(); }

dlgRadioButton
Function
Definesaradiobutton.
Syntax
dlgRadioButton(string Text, int &Selected) [ statement ]
SeealsodlgCheckBox,dlgGroup,LayoutInformation,ACompleteExample
ThedlgRadioButtonstatementdefinesaradiobuttonwiththegivenText.
IfTextcontainsan'&',thecharacterfollowingtheampersandwillbecomeahotkey,and
whentheuserhitsAlt+hotkey,thebuttonwillbeselected.Tohaveanactual'&'
characterinthetextithastobeescaped.
dlgRadioButtoncanonlybeusedwithinadlgGroup.
AllradiobuttonswithinthesamegroupmustusethesameSelectedvariable!
IftheuserselectsadlgRadioButton,theindexofthatbuttonwithinthedlgGroupis
storedintheSelectedvariable.
TheinitialvalueofSelecteddefineswhichradiobuttonisinitiallyselected.IfSelected
isoutsidethevalidrangeforthisgroup,noradiobuttonwillbeselected.Inordertogetthe
correctradiobuttonselection,SelectedmustbesetbeforethefirstdlgRadioButtonis
defined,andmustnotbemodifiedbetweenaddingsubsequentradiobuttons.Otherwiseit
isundefinedwhich(ifany)radiobuttonwillbeselected.
TheoptionalstatementisexecutedeverytimethedlgRadioButtonisselected.

Example
int align = 1;
dlgGroup("Alignment") {
dlgRadioButton("&Top", align);

Page119of132

EAGLEUserLanguage
dlgRadioButton("&Center", align);
dlgRadioButton("&Bottom", align);
}

dlgRealEdit
Function
Definesarealentryfield.
Syntax
dlgRealEdit(real &Value, real Min, real Max)
SeealsodlgIntEdit,dlgStringEdit,dlgLabel,LayoutInformation,ACompleteExample
ThedlgRealEditstatementdefinesarealentryfieldwiththegivenValue.
IfValueisinitiallyoutsidetherangedefinedbyMinandMaxitwillbelimitedtothese
values.

Example
real Value = 1.4142;
dlgHBoxLayout {
dlgLabel("Enter a &Number between 0 and 99");
dlgRealEdit(Value, 0.0, 99.0);
}

dlgSpacing
Function
Definesadditionalspaceinaboxlayoutcontext.
Syntax
dlgSpacing(int Size)
SeealsodlgHBoxLayout,dlgVBoxLayout,dlgStretch,LayoutInformation,AComplete
Example
ThedlgSpacingstatementdefinesadditionalspaceinaverticalorhorizontalboxlayout
context.
Sizedefinesthenumberofpixelsoftheadditionalspace.

Example
dlgVBoxLayout {
dlgLabel("Label 1");
dlgSpacing(40);
dlgLabel("Label 2");
}

Page120of132

EAGLEUserLanguage

dlgSpinBox
Function
Definesaspinboxselectionfield.
Syntax
dlgSpinBox(int &Value, int Min, int Max)
SeealsodlgIntEdit,dlgLabel,LayoutInformation,ACompleteExample
ThedlgSpinBoxstatementdefinesaspinboxentryfieldwiththegivenValue.
IfValueisinitiallyoutsidetherangedefinedbyMinandMaxitwillbelimitedtothese
values.

Example
int Value = 42;
dlgHBoxLayout {
dlgLabel("&Select value");
dlgSpinBox(Value, 0, 99);
}

dlgStretch
Function
Definesanemptystretchablespaceinaboxlayoutcontext.
Syntax
dlgStretch(int Factor)
SeealsodlgHBoxLayout,dlgVBoxLayout,dlgSpacing,LayoutInformation,AComplete
Example
ThedlgStretchstatementdefinesanemptystretchablespaceinaverticalorhorizontal
boxlayoutcontext.
Factordefinesthestretchfactorofthespace.

Example
dlgHBoxLayout {
dlgStretch(1);
dlgPushButton("+OK")
{ dlgAccept(); };
dlgPushButton("Cancel") { dlgReject(); };
}

dlgStringEdit
Function
Definesastringentryfield.
Syntax
dlgStringEdit(string &Text)
Page121of132

EAGLEUserLanguage
SeealsodlgRealEdit,dlgIntEdit,dlgTextEdit,dlgLabel,LayoutInformation,AComplete
Example
ThedlgStringEditstatementdefinesatextentryfieldwiththegivenText.

Example
string Name = "Linus";
dlgHBoxLayout {
dlgLabel("Enter &Name");
dlgStringEdit(Name);
}

dlgTabPage
Function
Definesatabpage.
Syntax
dlgTabPage(string Title) statement
SeealsodlgTabWidget,LayoutInformation,ACompleteExample
ThedlgTabPagestatementdefinesatabpagewiththegivenTitlecontainingthegiven
statement.
IfTitlecontainsan'&',thecharacterfollowingtheampersandwillbecomeahotkey,
andwhentheuserhitsAlt+hotkey,thistabpagewillbeopened.Tohaveanactual'&'
characterinthetextithastobeescaped.
TabpagescanonlybeusedwithinadlgTabWidget.
BydefaultadlgTabPagecontainsadlgVBoxLayout,soasimpletabpagedoesn'thaveto
worryaboutthelayout.

Example
dlgTabWidget {
dlgTabPage("Tab &1") {
dlgLabel("This is page 1");
}
dlgTabPage("Tab &2") {
dlgLabel("This is page 2");
}
}

dlgTabWidget
Function
Definesacontainerfortabpages.
Syntax
dlgTabWidget statement

Page122of132

EAGLEUserLanguage
SeealsodlgTabPage,LayoutInformation,ACompleteExample
ThedlgTabWidgetstatementdefinesacontainerforasetoftabpages.
statementmustbeasequenceofoneormoredlgTabPageobjects.Theremustbeno
otherdialogobjectsinthissequence.

Example
dlgTabWidget {
dlgTabPage("Tab &1") {
dlgLabel("This is page 1");
}
dlgTabPage("Tab &2") {
dlgLabel("This is page 2");
}
}

dlgTextEdit
Function
Definesamultilinetextentryfield.
Syntax
dlgTextEdit(string &Text)
SeealsodlgStringEdit,dlgTextView,dlgLabel,LayoutInformation,ACompleteExample
ThedlgTextEditstatementdefinesamultilinetextentryfieldwiththegivenText.
ThelinesintheTexthavetobedelimitedbyanewlinecharacter('\n').Anywhitespace
charactersattheendofthelinescontainedinTextwillberemoved,anduponreturnthere
willbenowhitespacecharactersattheendofthelines.Emptylinesattheendofthetext
willberemovedentirely.

Example
string Text = "This is some text.\nLine 2\nLine 3";
dlgVBoxLayout {
dlgLabel("&Edit the text");
dlgTextEdit(Text);
}

dlgTextView
Function
Definesamultilinetextviewerfield.
Syntax
dlgTextView(string Text)
dlgTextView(string Text, string &Link) statement
SeealsodlgTextEdit,dlgLabel,LayoutInformation,ACompleteExample
Page123of132

EAGLEUserLanguage
ThedlgTextViewstatementdefinesamultilinetextviewerfieldwiththegivenText.
TheTextmaycontainHTMLtags.
IfLinkisgivenandtheTextcontainshyperlinks,statementwillbeexecutedeverytime
theuserclicksonahyperlink,withthevalueofLinksettowhateverthe<a href=...>
tagdefinesasthevalueofhref.

Example
string Text = "This is some text.\nLine 2\nLine 3";
dlgVBoxLayout {
dlgLabel("&View the text");
dlgTextView(Text);
}

dlgVBoxLayout
Function
Opensaverticalboxlayoutcontext.
Syntax
dlgVBoxLayout statement
SeealsodlgGridLayout,dlgHBoxLayout,LayoutInformation,ACompleteExample
ThedlgVBoxLayoutstatementopensaverticalboxlayoutcontextforthegiven
statement.
BydefaultadlgDialogcontainsadlgVBoxLayout,soasimpledialogdoesn'thaveto
worryaboutthelayout.

Example
dlgVBoxLayout {
dlgLabel("Box 1");
dlgLabel("Box 2");
dlgLabel("Box 3");
}

Layout Information
AllobjectswithinaUserLanguageDialogaplacedinsidealayoutcontext.
Layoutcontextscanbeeithergrid,horizontalorvertical.

Grid Layout Context


Objectsinagridlayoutcontextmustspecifythegridcoordinatesofthecellorcellsinto
whichtheyshallbeplaced.Toplaceatextlabelatrow5,column2,youwouldwrite
dlgGridLayout {
dlgCell(5, 2) dlgLabel("Text");
}

Page124of132

EAGLEUserLanguage
Iftheobjectshallspanovermorethanonecellyouneedtospecifythecoordinatesofthe
startingcellandtheendingcell.Toplaceagroupthatextendsfromrow1,column2upto
row3,column5,youwouldwrite
dlgGridLayout {
dlgCell(1, 2, 3, 5) dlgGroup("Title") {
//...
}
}

Horizontal Layout Context


Objectsinahorizontallayoutcontextareplacedlefttoright.
ThespecialobjectsdlgStretchanddlgSpacingcanbeusedtofurtherrefinethedistribution
oftheavailablespace.
Todefinetwobuttonsthatarepushedallthewaytotherightedgeofthedialog,youwould
write
dlgHBoxLayout {
dlgStretch(1);
dlgPushButton("+OK")
dlgAccept();
dlgPushButton("Cancel") dlgReject();
}

Vertical Layout Context


Objectsinaverticallayoutcontextfollowthesamerulesasthoseinahorizontallayout
context,exceptthattheyareplacedtoptobottom.

Mixing Layout Contexts


Vertical,horizontalandgridlayoutcontextscanbemixedtocreatethedesiredlayout
structureofadialog.SeetheCompleteExampleforademonstrationofthis.

Dialog Functions
ThefollowingfunctionscanbeusedwithUserLanguageDialogs:
dlgAccept()
dlgRedisplay()
dlgReset()
dlgReject()

closesthedialogandacceptsitscontents
immediatelyredisplaysthedialogafterchangestoany
values
resetsalldialogobjectstotheirinitialvalues
closesthedialogandrejectsitscontents

dlgAccept()
Function
Closesthedialogandacceptsitscontents.
Syntax
void dlgAccept([ int Result ]);
Page125of132

EAGLEUserLanguage
SeealsodlgReject,dlgDialog,ACompleteExample
ThedlgAcceptfunctioncausesthedlgDialogtobeclosedandreturnafterthecurrent
statementsequencehasbeencompleted.
Anychangestheuserhasmadetothedialogvalueswillbeacceptedandarecopiedinto
thevariablesthathavebeengivenwhenthedialogobjectsweredefined.
TheoptionalResultisthevaluethatwillbereturnedbythedialog.Typicallythisshould
beapositiveintegervalue.Ifnovalueisgiven,itdefaultsto1.
NotethatdlgAccept()doesreturntothenormalprogramexecution,soinasequence
like
dlgPushButton("OK") {
dlgAccept();
dlgMessageBox("Accepting!");
}

thestatementafterdlgAccept()willstillbeexecuted!

Example
int Result = dlgDialog("Test") {
dlgPushButton("+OK")
dlgAccept(42);
dlgPushButton("Cancel") dlgReject();
};

dlgRedisplay()
Function
Redisplaysthedialogafterchangingvalues.
Syntax
void dlgRedisplay(void);
SeealsodlgReset,dlgDialog,ACompleteExample
ThedlgRedisplayfunctioncanbecalledtoimmediatelyrefreshthedlgDialogafter
changeshavebeenmadetothevariablesusedwhendefiningthedialogobjects.
YouonlyneedtocalldlgRedisplay()ifyouwantthedialogtoberefreshedwhilestill
executingprogramcode.Intheexamplebelowthestatusischangedto"Running..."and
dlgRedisplay()hastobecalledtomakethischangetakeeffectbeforethe"program
action"isperformed.Afterthefinalstatuschangeto"Finished."thereisnoneedtocall
dlgRedisplay(),sincealldialogobjectsareautomaticallyupdatedafterleavingthe
statement.

Example
string Status = "Idle";
int Result = dlgDialog("Test") {
dlgLabel(Status, 1); // note the '1' to tell the label to be
updated!

Page126of132

EAGLEUserLanguage
dlgPushButton("+OK")
dlgAccept(42);
dlgPushButton("Cancel") dlgReject();
dlgPushButton("Run") {
Status = "Running...";
dlgRedisplay();
// some program action here...
Status = "Finished.";
}
};

dlgReset()
Function
Resetsalldialogobjectstotheirinitialvalues.
Syntax
void dlgReset(void);
SeealsodlgReject,dlgDialog,ACompleteExample
ThedlgResetfunctioncopiestheinitialvaluesbackintoalldialogobjectsofthecurrent
dlgDialog.
Anychangestheuserhasmadetothedialogvalueswillbediscarded.
CallingdlgReject()impliesacalltodlgReset().

Example
int Number = 1;
int Result = dlgDialog("Test") {
dlgIntEdit(Number);
dlgPushButton("+OK")
dlgAccept(42);
dlgPushButton("Cancel") dlgReject();
dlgPushButton("Reset") dlgReset();
};

dlgReject()
Function
Closesthedialogandrejectsitscontents.
Syntax
void dlgReject([ int Result ]);
SeealsodlgAccept,dlgReset,dlgDialog,ACompleteExample
ThedlgRejectfunctioncausesthedlgDialogtobeclosedandreturnafterthecurrent
statementsequencehasbeencompleted.
Anychangestheuserhasmadetothedialogvalueswillbediscarded.Thevariablesthat
havebeengivenwhenthedialogobjectsweredefinedwillberesettotheiroriginalvalues
whenthedialogreturns.
TheoptionalResultisthevaluethatwillbereturnedbythedialog.Typicallythisshould
Page127of132

EAGLEUserLanguage
be0oranegativeintegervalue.Ifnovalueisgiven,itdefaultsto0.
NotethatdlgReject()doesreturntothenormalprogramexecution,soinasequence
like
dlgPushButton("Cancel") {
dlgReject();
dlgMessageBox("Rejecting!");
}

thestatementafterdlgReject()willstillbeexecuted!
CallingdlgReject()impliesacalltodlgReset().

Example
int Result = dlgDialog("Test") {
dlgPushButton("+OK")
dlgAccept(42);
dlgPushButton("Cancel") dlgReject();
};

Escape Character
Somecharactershavespecialmeaningsinbuttonorlabeltexts,sotheyneedtobeescaped
iftheyshallappearliterally.
Todothisyouneedtoprependthecharacterwithabackslash,asin
dlgLabel("Miller \\& Co.");

Thiswillresultin"Miller&Co."displayedinthedialog.
Notethatthereareactuallytwobackslashcharactershere,sincethislinewillfirstgo
throughtheUserLanguageparser,whichwillstripthefirstbackslash.

A Complete Example
Here'sacompleteexampleofaUserLanguageDialog.
int hor = 1;
int ver = 1;
string fileName;
int Result = dlgDialog("Enter Parameters") {
dlgHBoxLayout {
dlgStretch(1);
dlgLabel("This is a simple dialog");
dlgStretch(1);
}
dlgHBoxLayout {
dlgGroup("Horizontal") {
dlgRadioButton("&Top", hor);
dlgRadioButton("&Center", hor);
dlgRadioButton("&Bottom", hor);
}
dlgGroup("Vertical") {
dlgRadioButton("&Left", ver);

Page128of132

EAGLEUserLanguage
dlgRadioButton("C&enter", ver);
dlgRadioButton("&Right", ver);
}

}
dlgHBoxLayout {
dlgLabel("File &name:");
dlgStringEdit(fileName);
dlgPushButton("Bro&wse") {
fileName = dlgFileOpen("Select a file", fileName);
}
}
dlgGridLayout {
dlgCell(0, 0) dlgLabel("Row 0/Col 0");
dlgCell(1, 0) dlgLabel("Row 1/Col 0");
dlgCell(0, 1) dlgLabel("Row 0/Col 1");
dlgCell(1, 1) dlgLabel("Row 1/Col 1");
}
dlgSpacing(10);
dlgHBoxLayout {
dlgStretch(1);
dlgPushButton("+OK")
dlgAccept();
dlgPushButton("Cancel") dlgReject();
}
};

Supported HTML tags


EAGLEsupportsasubsetofthetagsusedtoformatHTMLpages.Thiscanbeusedto
formatthetextofseveralUserLanguageDialogobjects,inthe#usagedirectiveorinthe
descriptionoflibraryobjects.
TextisconsideredtobeHTMLifthefirstlinecontainsatag.Ifthisisnotthecase,andyou
wantthetexttobeformatted,youneedtoenclosetheentiretextinthe
<html>...</html>tag.
ThefollowingtablelistsallsupportedHTMLtagsandtheiravailableattributes:
Tag

Description
AnHTMLdocument.Itunderstandsthefollowingattributes

<html>...</html>

<h1>...</h1>
<h2>...</h2>
<h3>...</h3>
<p>...</p>

bgcolorThebackgroundcolor,forexample
bgcolor="yellow"orbgcolor="#0000FF".
backgroundThebackgroundpixmap,forexample
background="granit.xpm".
textThedefaulttextcolor,forexampletext="red".
linkThelinkcolor,forexamplelink="green".

Atoplevelheading.
Asublevelheading.
Asubsublevelheading.
Aleftalignedparagraph.Adjustthealignmentwiththealign
attribute.Possiblevaluesareleft,rightandcenter.
Page129of132

EAGLEUserLanguage
<center>...</center
Acenteredparagraph.
>
<blockquote>...</bl
Anindentedparagraph,usefulforquotes.
ockquote>
Anunorderedlist.Youcanalsopassatypeargumenttodefinethe
bulletstyle.Thedefaultistype=disc,othertypesarecircleand
<ul>...</ul>
square.
Anorderedlist.Youcanalsopassatypeargumenttodefinethe
enumerationlabelstyle.Thedefaultistype="1",othertypesare
<ol>...</ol>
"a"and"A".
Alistitem.Thistagcanonlybeusedwithinthecontextofolorul.
<li>...</li>
Forlargerchunksofcode.Whitespacesinthecontentsare
<pre>...</pre>
preserved.Forsmallbitsofcode,usetheinlinestylecode.
Ananchororlink.Itunderstandsthefollowingattributes:

<a>...</a>

<em>...</em>
<strong>...</strong
>
<i>...</i>
<b>...</b>
<u>...</u>
<big>...</big>
<small>...</small>
<code>...</code>
<tt>...</tt>

Emphasized(sameas<i>...</i>).
Strong(sameas<b>...</b>).
Italicfontstyle.
Boldfontstyle.
Underlinedfontstyle.
Alargerfontsize.
Asmallerfontsize.
IndicatesCode.(sameas<tt>...</tt>.Forlargerchunksof
code,usetheblocktagpre.
Typewriterfontstyle.
Customizesthefontsize,familyandtextcolor.Thetagunderstands
thefollowingattributes:

<font>...</font>

<img...>

hrefThereferencetargetasin<a
href="target.qml">...</a>.Youcanalsospecifyan
additionalanchorwithinthespecifiedtargetdocument,for
example<a href="target.qml#123">...</a>.
nameTheanchorname,asin<a name="target">...</
a>.

colorThetextcolor,forexamplecolor="red"or
color="#FF0000".
sizeThelogicalsizeofthefont.Logicalsizes1to7are
supported.Thevaluemayeitherbeabsolute,forexample
size=3,orrelativelikesize=-2.Inthelattercase,the
sizesaresimplyadded.
faceThefamilyofthefont,forexampleface=times.

Animage.Thistagunderstandsthefollowingattributes:
Page130of132

EAGLEUserLanguage

<hr>
<br>
<nobr>...</nobr>

Ahorizonalline.
Alinebreak.
Nobreak.Preventswordwrap.
Atabledefinition.Thedefaulttableisframeless.Specifytheboolean
attributeborderinordertogetaframe.Otherattributesare:

<table>...</table>

<tr>...</tr>

bgcolorThebackgroundcolor.
widthThetablewidth.Thisiseitherabsoluteinpixelsor
relativeinpercentofthecolumnwidth,forexample
width=80%.
borderThewidthofthetableborder.Thedefaultis0(=
noborder).
cellspacingAdditionalspacearoundthetablecells.The
defaultis2.
cellpaddingAdditionalspacearoundthecontentsof
tablecells.Defaultis1.

Atablerow.Canonlybeusedwithintable.Understandsthe
attribute

<td>...</td>

srcTheimagename,forexample<img
src="image.xpm">.
Supportedimageformatsare:
".bmp"(WindowsBitmapFiles)
".pbm"(PortableBitmapFiles)
".pgm"(PortableGrayscaleBitmapFiles)
".png"(PortableNetworkGraphicsFiles)
".ppm"(PortablePixelmapFiles)
".xbm"(XBitmapFiles)
".xpm"(XPixmapFiles)
widthThewidthoftheimage.Iftheimagedoesnotfitto
thespecifiedsize,itwillbescaledautomatically.
heightTheheightoftheimage.
alignDetermineswheretheimageisplaced.Perdefault,
animageisplacedinline,justlikeanormalcharacter.Specify
leftorrighttoplacetheimageattherespectiveside.

bgcolorThebackgroundcolor.

Atabledatacell.Canonlybeusedwithintr.Understandsthe
attributes

bgcolorThebackgroundcolor.
Page131of132

EAGLEUserLanguage

<th>...</th>

widthThecellwidth.Thisiseitherabsoluteinpixelsor
relativeinpercentoftheentiretablewidth,forexample
width=50%.
colspanDefineshowmanycolumnsthiscellspans.The
defaultis1.
rowspanDefineshowmanyrowsthiscellspans.The
defaultis1.
alignAlignment,possiblevaluesareleft,rightand
center.Thedefaultisleftaligned.

Atableheadercell.Liketdbutdefaultstocenteralignmentanda
boldfont.

<author>...</author
Markstheauthorofthistext.
>
<dl>...</dl>
Adefinitionlist.
Adefinitiontag.Canonlybeusedwithindl.
<dt>...</dt>
Definitiondata.Canonlybeusedwithindl.
<dd>...</dd>
Tag
Meaning
&lt;
<
&gt;
>
&amp;
&
&nbsp;
nonbreakingspace
&auml;

&ouml;

&uuml;

&Auml;

&Ouml;

&Uuml;

&szlig;

&copy;

&deg;

&micro;

&plusmn;

Page132of132

You might also like