PragScript is an interpreted language in the LISP family. If you’re already familiar with a LISP dialect, you’ll find PragScript very easy to use. If you’re new to LISP, don’t despair – LISP is one of the easiest languages to learn. If you feel you need more information than provided here, we advise you to consult an introductory LISP text book.
When you create a new script, place it in one of the following standard script folders. These folders are automatically created during the installation of UMLStudio, and are named:
By doing so:
...\UMLStudio\Scripts\CodeGen (use this for code generation scripts) ...\UMLStudio\Scripts\DocGen (use this for document generation scripts) ...\UMLStudio\Scripts\Other (use this for other forms of generation) ...\UMLStudio\Scripts\Import (use this for data import scripts) ...\UMLStudio\Scripts\Export (use this for data export scripts) ...\UMLStudio\Scripts\RevEng (use this for reverse engineering scripts) ...\UMLStudio\Scripts\Task (use this for task scripts)
For a RevEng script, you should defined a function named PragReverse, which serves as the entry-point for execution. This function must have the following signature:
(fun PragReverse (docName files)
...)
When this function is called by PragScript, docName is set to the name of the UMLStuido project document, and files is a list, each of whose members is either
For a Task script, you should defined a function named PragTask, which serves as the entry-point for execution. This function must have the following signature:
(fun PragTask ()
...)
For all other scripts, you should define a function named PragMain, with the following signature:
(fun PragMain (scope docName genPath genName genBanner genFlags)
...)
When this function is called by PragScript, the parameters are initialized according to the user selections made in the dialog box displayed for running a script:
When you run a script, the PragScript interpreter first loads the script (i.e., parses the expressions and loads them into memory), and then calls PragReverse or PragMain, which in turn calls other functions, and so on. If an error occurs during execution then it will be reported in the log window, followed by a dump of the PragScript stack. This dump can be investigated to identify the source of the error.
All exposed options should appear at the top of a script file, before any actual code. Comments, however, can appear before and in between options.
Each exposed option consists of an option specification line, which may be optionally followed by an option description line. An option specification line always start with the characters ;$. For example, here is an option for allowing the user to decide if a generated file should be added to the project tree:
;$ Add To Project TreeAn option description line always starts with the characters ;?. For example, the above option line may be followed by a description line, as follows:
;$ Add To Project TreeThe above option is an example of a flag option. It may be set or reset, but has no other value. A value option, on the other hand, also takes a value. A value option should be followed by an = symbol, even if its value if empty. Here is a value option, with no initial value:
;? Adds an icon for the generated file to the project tree.
;$ Author And Revision=Here is another example:
;$ Include Header File=#include "Common.h"This option takes the initial value "Common.h". Before running the script, the user will have the opportunity to change this value. If a value is intended to be multi-line, these lines should still be joined as one line, but separated by ^r^n. For example:
;$ Include Header File=#include "Common.h"^r^n#include "Std.h"A value can be limited to a set of predetermined values, resulting in a choice option. To do this, the permissible values should be separated by |. Here is an example:
;$ Image Format=BITMAP|JPEG|PNGAt run-time, when the user is presented with a choice option, the permissible values appear in a combo, so that no other value can be selected.
All exposed options are translated into corresponding option variables before the script is executed. The name of each option variable consists of a $ and the words in the option, with any blanks removed. For example, the above options result in the following variables:
$AddToProjectTreeThese variables can be freely referred to in the script code.
$AuthorAndRevision
$IncludeHeaderFile
$ImageFormat
Each option variable is set after being presented to the user and before running the script, according to these rules:
(setq str "hello")
is a list of three elements: setq (a function name), str (a variable), and "hello" (a string constant). The two parentheses mark the begin and end of the list. When this expression is evaluated by the PragScript interpreter, it causes the string "hello" to be assigned to the variable str.
All function calls use the prefix notation: the function name appears first in a list, followed by its arguments. This syntax is somewhat different from that of procedural languages, where only the function arguments appear within parentheses. For example, in a procedural language, the above example would probably be written as: setq(str, "hello").
Expressions are typically written as nested lists, so that a function call becomes an argument to another function call. For example, in
(and (> count 0) (/ sum count))
The and function is given two arguments, each of which is another function call. The effect is that if count is greater than zero then the overall result is sum divided by count. This example also illustrates that a function name need not be alphanumeric. Both > and / are valid function names. Again, in a procedural language, these functions would probably appear as infix operators. For example, the equivalent in C would be:
(count > 0) ? (sum / count) : nil
nil Bound to itself and represents an empty list (and 'false'). t Bound to itself and represents 'true'. eof Bound to itself and represents 'end-of-file'. inchan Represents the default input channel. outchan Represents the default output channel. errchan Represents the default error channel.
The second form (called backquote) is denoted by the ` symbol which may also appear before an expression. It has the same effect as quote, except that when it appears before a list, it causes the following:
(setq x '(10 20)) gives: (10 20) `x gives: x `(x ,x) gives: (x (10 20)) `(x @x) gives: (x 10 20)
; This is a commentAlso anything appearing between /* and */ is a comment. For example:
/* This is a commentComments are simply ignored by the interpreter.
that extends beyond one line */
=> expression to be evaluated
result of evaluation
(PgList 'model 'all)
Returns a list of references to all the models in the current project.
(pgList 'model)
Returns a list of references to all the top-level models (i.e., models that have no parent) in the current
project.
(PgList 'model parentModelRef)
Returns a list of references to all the models in the current project whose parent model is denoted by
parentModelRef.
(PgList 'master ['selOnly])
Returns a list of references to all the masters in the current project.
When selOnly is present, only the masters selected in the lister pane are considered.
(PgList 'drawable parentModelRef ['selOnly])
Returns a list of references to all the drawables in the model denoted by parentModelRef.
When selOnly is present, only selected drawables are considered.
(PgList 'place parentModelRef ['selOnly])
Returns a list of references to all the places in the model denoted by parentModelRef.
When selOnly is present, only selected places are considered.
(PgList 'link parentModelRef ['selOnly])
Returns a list of references to all the links in the model denoted by parentModelRef.
When selOnly is present, only selected links are considered.
(PgList 'primitive parentModelRef ['selOnly])
Returns a list of references to all the primitives in the model denoted by parentModelRef.
When selOnly is present, only selected primitives are considered.
(PgList 'tag parentModelRef ['selOnly])
Returns a list of references to all the tags and messages in the model denoted by parentModelRef.
When selOnly is present, only selected tags/messages are considered.
(PgList 'member parentGroupRef)
Returns a list of references to all the members in the group denoted by parentGroupRef.
(PgList 'attribute masterRef)
Returns a list of references to all the non-macro attributes in the master denoted by masterRef.
(PgList 'macro masterRef)
Returns a list of references to all the macro attributes in the master denoted by masterRef.
(PgList 'method masterRef)
Returns a list of references to all the methods in the master denoted by masterRef.
(PgList 'type masterRef)
Returns a list of references to all the types in the master denoted by masterRef.
(PgList 'exception masterRef)
Returns a list of references to all the exceptions in the master denoted by masterRef.
(PgFind 'master 'name ['toolName ['namespace]])
Returns a reference to the master whose name is denoted by name, or
nil if there is no such master.
(PgFind 'model name)
Returns a reference to the model whose name is denoted by name, or
nil if there is
no such model.
(PgFind 'model 'currModel)
Returns a reference to the current model, or nil if there is no current model.
(PgFind 'place modelRef 'masterName 'toolName ['namespace])
Returns a reference to the place matching the parameters, or nil if there is
no such place.
(PgProps modelRef)
Returns the properties of the model denoted by modelRef as a list having the
following structure:
((name "...")where "..." denotes an appropriate string; typeSym may be one of default, class, usecase, sequence, state, activity, implementation; accessSym may be one of public, protected, private, package; and theFlags may be one or more of genCode, stepLink, or curveLink. If the model is a tool model, then two additional clauses are also returned:
(type typeSym)
(access accessSym)
(comment "...")
(flags theFlags)
(parentMaster masterRef)
(parentModel modelRef)
(rect left top right bottom))
where kindSym is either link or place; stereoParentRef is a reference to the parent tool model (if this is a stereotype tool model) or nil; and semanticsSym denotes the semantics for the tool (e.g., Inheritance).
(kind kindSym stereoParentRef)
(semantics semanticsSym)
(PgProps masterRef)
Returns the properties of the master denoted by masterRef as a list having the
following structure:
((name "...")where "..." denotes an appropriate string; toolSym may be one of place1, ..., place14; accessSym may be one of public, protected, private, package; and theFlags may be one or more of genCode, interface, abstract, final, and urlLink. The pars and args clauses are mutually exclusive. The former is present when a parameterized class has parameters specified. The latter is present when a class instantiates a parameterized class with corresponding arguments.
(namespace "...")
(tool toolSym)
(refCount n)
(access accessSym)
(stereotype "...")
(file "...")
(comment "...")
(link hyperLink)
(flags theFlags)
(model toolModelRef)
(refine modelRef)
(pars (parName parType) ...)
(args argName ...))
(PgProps placeRef)
Returns the properties of the place denoted by placeRef as a list having the
following structure:
((master masterRef)where toolSym may be one of place1, ..., place14; juncRefs denotes references to the junctions of the place (if any); memRefs denotes references to the members of the place (if it is a place group); and theFlags may be one or more of annotate, or detailed. The (instance "...") clause will be present if the place represents a class instance, and will contain the instance name. The (endPt x y) clause will be present if the place appears in a sequence diagram, and represents the shaft end-point.
(tool toolSym)
(rect left top right bottom)
(flags theFlags)
(instance "...")
(endPt x y)
(junctions juncRefs)
(members memRefs))
(PgProps linkRef)
Returns the properties of the link denoted by linkRef as a list having the
following structure:
((name "...")where "..." denotes an appropriate string; accessSym may be one of public, protected, private, package; theFlags may be one or more of genCode, stepLink, curveLink, and urlLink; and toolSym may be one of link1, ..., link10.
(access accessSym)
(stereotype "...")
(type "...")
(role "..." "...")
(card "..." "...")
(comment "...")
(link "...")
(flags theFlags)
(source placeRef)
(target placeRef)
(model toolModelRef)
(points x1 y1 x2 y2 ...)
(tool toolSym)
(rect left top right bottom))
(PgProps junctionRef)
Returns the properties of the junction denoted by junctionRef as a list having the following structure:
((tool junction)where idx denotes the zero-based index of the junction in the junction menu; placeRef denotes the place to which the junction is attached; x and y denote the point on the place's border where the junction is attached; and sideSym may be one of left, right, top, or bottom, denoting the side of the place where the junction is attached.
(junction idx)
(pivot placeRef)
(tip x y)
(side sideSym)
(text "...")
(rect left top right bottom))
(PgProps primitiveRef)
Returns the properties of the primitive denoted by primitiveRef as a list.
For line, polyline, and polygon primitives it returns a list of the form:
((points x1 y1 x2 y2 ...)For text primitives it returns a list of the form:
(tool toolSym)
(rect left top right bottom))
((text "..." editable)For rectangular primitives (rectangle, rounded rectangle, and ellipse), it returns a list of the form:
(tool toolSym)
(rect left top right bottom))
((tool toolSym)For icons primitives, it returns a list of the form (where idx denotes the zero-based index of the icon in the icon menu):
(rect left top right bottom))
((tool icon)For primitive groups it returns a list of the form:
(icon idx)
(rect left top right bottom))
((members memRefs)Where toolSym is one of line, polyline, polygon, textBox, rectangle, roundRectangle, ellipse, primitiveGroup; "..." denotes a valid string; editable is the editable symbol if the text box is editable or nil otherwise; and memRefs consists of references to the group members.
(tool toolSym)
(rect left top right bottom))
(PgProps tagRef)
(PgProps messageRef)
Returns the properties of the tag denoted by tagRef as a list of the form:
((pivot placeRef)or the properties of the message denoted by messageRef as a list of the form:
(tip x y)
(text "...")
(tool tag)
(rect left top right bottom))
((pivot linkRef)where placeRef is a reference to the place to which the tag is attached; linkRef is a reference to the link to which the message is attached; x and y denote the point of connection; "..." denotes a valid string; and theFlags may be one or more of reverse and urlLink (for messages only).
(text "...")
(comment "...")
(link "...")
(flags theFlags)
(tool message)
(rect left top right bottom))
(PgProps attributeRef)
Returns the properties of the master attribute denoted by attributeRef as a list of
the form:
((name "...")where "..." denotes a valid string; accessSym is one of public, protected, or private; and modeSyms consists of any combination of the symbols static, const, getset, annotate, final, volatile, transient, and macro.
(type "...")
(card "...")
(container "...")
(value "...")
(comment "...")
(access accessSym)
(mode modeSyms))
(PgProps methodRef)
Returns the properties of the master method denoted by methodRef as a list of the form:
((name "...")where "..." denotes a valid string; accessSym is one of public, protected, or private; modeSyms consists of any combination of the symbols static, const, virtual, annotate, final, abstract, synchronized, and native; parProps consists of the parameter properties for the method, each having the form:
(returns "...")
(comment "...")
(access accessSym)
(mode modeSyms)
(pars parProps)
(others otherProps)
(code "..."))
((name "...")where dirSyms may consists of the symbols in and out. OtherProps consists of the other properties for the method, each having the form:
(type "...")
(value "...")
(dir dirSyms))
("..." kind)where kind may be the symbol exception or context.
(PgProps typeRef)
Returns the properties of the master type denoted by typeRef as a list of the form:
((name "...")where "..." denotes a valid string; accessSym may be one of private, protected, or public; modeSyms may contain annotate; kindSym may be one of simple, enum, or struct; elemProps consists of the element properties for the type, each having the form:
(def "...")
(comment "...")
(access accessSym)
(mode modeSyms)
(kind kindSym)
(elems parProps)
((name "...")
(type "...")
(value "..."))
(PgProps exceptionRef)
Returns the properties of the master exception denoted by exceptionRef as a
list of the form:
((name "...")where "..." denotes a valid string and memProps consists of the members properties for the exception, each having the form:
(comment "...")
(members memProps))
((name "...")
(type "...")
(value "..."))
(PgMarked objRef)
Returns t if the object denoted by objRef is marked,
and nil otherwise.
(PgMark objRef)
Marks the object denoted by objRef.
(PgUnmark objRef)
Unmarks the object denoted by objRef.
(PgMarkAll 'model)
(PgMarkAll 'master)
(PgMarkAll 'drawable)
Marks all models, masters, or drawables in the project.
(PgUnmarkAll 'model)
(PgUnmarkAll 'master)
(PgUnmarkAll 'drawable)
Unmarks all models, masters, or drawables in the project.
(PgWriteLog ...)
Writes zero or more arguments to the log window. The arguments can be any valid expressions.
(PgShowLog show)
Shows the log window and brings it to the front.
(PgClearLog)
Clears the contents of the log window.
(PgAssociations masterRef)
Searches all models in the project and returns a list that contains the associations for the master
denoted by masterRef. This list is of the form:
((base baseLinkRefs)where baseLinkRefs consists of references to the inheritance links (link tool 1) that connect places of the given master to other places; implementLinkRefs consists of references to the implements links (link tool 8) that connect places of the given master to other places; containLinkRefs consists of references to the containment links (link tool 1 and link tool 2) that connect places of the given master to other places; and relationLinkRefs consists of references to all other types of links that connect places of the given master to other places.
(implement implementLinkRefs)
(contain containLinkRefs)
(relation relationLinkRefs))
(PgMakeName prefix name)
Makes and returns a valid name using name and prefix.
The resulting name is produced by discarding any white space in name
and prepending prefix to it.
Either prefix or name may be an empty string.
(PgMakeComment comment prefix [nTabs])
Makes a valid comment using the comment and prefix strings.
The latter is used to transform each line in comment into a proper comment.
For example, for C++ code generation, "// " may be passed for prefix,
so that it is prepended to each comment line. The nTabs argument optionally
specifies the number of tabs to be placed before each comment line in order to indent the comment.
(PgDate)
Returns the current date as an integer reference number.
This number can be passed to PgDateParts to obtain the various parts of the date.
(PgDateParts date)
Given a date reference number (returned by PgDate), returns a list that contains
the various parts of the date, as exemplified below:
((year 1998)
(month 3 "March")
(day 2 "Monday")
(hour 9)
(minute 22)
(second 16))
(PgNewGuid)
Creates and returns a new GUID as a string. A GUID is a Globally Unique ID, used for
identifying COM components.
=> (PgNewGuid)
"b7294640-6b3f-11d4-97c2-2ec272000000"
(PgProject)
Returns a reference to the current project.
(PgProjectFile)
Returns a list that contains useful information about the current project file.
The general format of the list is:
((path projectFilePath)
(title projectFileTitle)
(date lastModifyDate))
(PgCreateImage modelRef selOnly format dir)
Creates an image for the model denoted by modelRef.
If selOnly in non-nil then only the selected drawables
in the model are considered. The image is created in the directory denoted by dir
and using the format denoted by format, which may be one of
"bmp" (for bitmap), "jpg" (for JPEG),
or "png" (for PNG).
The image file will have the same name as the model. The return value is the full path of the generated
image file.
(PgMergeFiles oldFile newFile mergedFile preserveBegin preserveEnd)
Merges the files denoted by oldFile and newFile to produce the
merged file denoted by mergedFile.
The merging process looks for comment blocks in oldFile that bear the strings
denoted by preserveBegin and preserveEnd. For example:
// PRESERVE:BEGINSuch code is preserved by the merge process. Returns t if successful and nil otherwise.
// Code that appears here is preserved...
// PRESERVE:END
(PgTry ...)
Evaluates the arguments one by one. Returns nil if no error occurs,
or t if an error occurs during evaluation.
(PgSortRefs refList)
Returns a list which is the result of alphabetically sorting the objects denoted by
refList in name order.
The latter may be a list of references to models, masters, attributes, methods, or exceptions.
(PgMakeProject "UML.not")(PgSaveProject projectRef filePath)
(PgClearTree which)
Clears the generated files in the folder denoted by the argument (in the explorer pane),
which may be one of codeModel, docoModel,
otherModel, or reversed.
(PgAddTree which fileName expand)
Adds the file denoted by fileName to the generated file folder
denoted by which
(which may be one of codeModel, docoModel,
otherModel, or reversed). When expand
is non-nil, it also expands the folder.
(PgMakeModel projectRef props)
Creates a new model and adds it to the project denoted by projectRef.
Returns a reference to the model.
The model properties (denoted by props) may contain the following clauses in any order:
(name "...")where:
(type typeSym)
(access accessSym)
(comment "...")
(flags theFlags)
(zoom zoomLevel)
(parentMaster masterRef)
(parentModel modelRef)
(rect left top right bottom)
(PgSelectModel modelRef)
Selects the model denoted by modelRef and refreshes it (even if it is already selected).
(PgCalcModel modelRef)
Recalculates the drawables in the model denoted by modelRef to properly size and clip them.
(PgLayoutModel modelRef 'autoSize 'recursive)
Automatically arranges the drawables in the model denoted by modelRef to produce a reasonable layout.
This function is especially useful for arranging a set of classes produced as a result of reverse engineering.
Only marked places are rearranged during the process.
Pass non-nil for autoSize if you want each class automatically resized.
Pass non-nil for recursive if you want the process
to be recursively applied to the model's submodels.
(PgMakeMaster projectRef [masterRef] props)
Creates a new master and adds it to the project denoted by projectRef.
When masterRef is specified, that master is updated rather than creating a new one.
Returns a reference to the master. The master properties
(denoted by props) may contain the following clauses in any order:
(name "...")where:
(namespace "...")
(tool toolName)
(access accessSym)
(stereotype "...")
(file "...")
(comment "...")
(link hyperLink)
(flags theFlags)
(pars (parName parType) ...)
(args argName ...)
(PgClearMaster masterRef)
Removes all the children (attributes, methods, etc.) of the master denoted by masterRef.
(PgMakeAttribute masterRef props)
Creates a new attribute and adds it to the master denoted by masterRef.
Returns a reference to the attribute. The attribute properties
(denoted by props) may contain the following clauses in any order:
(name "...")where:
(type "...")
(card "...")
(container "...")
(value "...")
(comment "...")
(access accessSym)
(mode modeSyms)
(name "...")where:
(returns "...")
(comment "...")
(access accessSym)
(mode modeSyms)
(pars ((name "...") (type "...") (value "...") (dir dirSyms)) ...)
(others ("..." kind) ...)
(code "...")
(name "...")where:
(def "...")
(comment "...")
(access accessSym)
(mode modeSyms)
(kind kindSym)
(elems ((name "...") (type "...") (value "...") ...)
(name "...")
(comment "...")
(members ((name "...") (type "...") (value "...")) ...)
(master masterRef)where:
(instance "...")
(rect left top right bottom)
(flags theFlags)
(looks theLooks)
(endPt x y)
(PgMakePlaceGroup modelRef props)
Same as PgMakePlace, except that it may also have the following clause:
(members memRefs)where memRefs consists of one or more references to the drawables contained by the place group.
(PgMakeSwimlane modelRef props)
Same as PgMakePlace, except that it may also have the following clause:
(members memRefs)where:
(leftLane swimlaneRef)
(rightLane swimlaneRef)
(PgMakeLink modelRef props)
Creates a new link and adds it to the model denoted by modelRef.
Returns a reference to the link. The link properties
(denoted by props) may contain the following clauses in any order:
(name "...")where:
(tool toolName)
(access accessSym)
(stereotype "...")
(type "...")
(role "..." "...")
(card "..." "...")
(comment "...")
(link hyperLink)
(flags theFlags)
(looks ...)
(source sourceRef)
(target targetRef)
(points x1 y1 x2 y2 ...)
(rect left top right bottom)
(PgMakeJunction modelRef props)
Creates a new junction and adds it to the model denoted by modelRef.
Returns a reference to the junction. The junction properties
(denoted by props) may contain the following clauses in any order:
(pivot placeRef)where:
(junction idx)
(text "...")
(tip x y)
(PgMakeTag modelRef props)
Creates a new tag and adds it to the model denoted by modelRef.
Returns a reference to the tag. The tag properties
(denoted by props) may contain the following clauses in any order:
(pivot placeRef)where:
(text "...")
(tip x y)
(looks ...)
(rect left top right bottom)
(PgMakeMessage modelRef props)
Creates a new message and adds it to the model denoted by modelRef.
Returns a reference to the message. The message properties
(denoted by props) may contain the following clauses in any order:
(pivot linkRef)where:
(text "...")
(comment "...")
(link hyperLink)
(flags theFlags)
(looks ...)
(points x1 y1 x2 y2)
(rect left top right bottom)
(PgMakeLine modelRef props)
Creates a new line primitive and adds it to the model denoted by modelRef.
Returns a reference to the primitive. The line properties
(denoted by props) may contain the following clauses in any order:
(tool toolSym)where:
(points x1 y1 x2 y2 ...)
(looks ...)
(PgMakeBox modelRef props)
Creates a new rectangular primitive and adds it to the model denoted by modelRef.
Returns a reference to the primitive. The rectangule properties
(denoted by props) may contain the following clauses in any order:
(tool toolSym)where:
(icon iconIdx)
(rect left top right bottom)
(looks ...)
(PgMakeText modelRef props)
Creates a new text primitive and adds it to the model denoted by modelRef.
Returns a reference to the primitive. The text properties
(denoted by props) may contain the following clauses in any order:
(text "..." editable)where:
(rect left top right bottom)
(looks ...)
(PgMakePrimGroup modelRef props)
Creates a new primitive group and adds it to the model denoted by modelRef.
Returns a reference to the primitive. The group properties
(denoted by props) may contain the following clauses in any order:
(rect left top right bottom)where:
(looks ...)
(members memRefs)
(PgDelete drawableRef)
Deletes the drawable denoted by drawableRef.
Returns t if successful, and nil otherwise.
(PgDelete masterRef)
Deletes the master denoted by masterRef. The master is not deleted if
its reference count is non-zero (i.e., if there are existing places that refer to it).
Returns t if successful, and nil otherwise.
(PgDelete masterRef partRef)
Deletes the attribute, method, type, or exception denoted by partRef in the
master denoted by masterRef.
Returns t if successful, and nil otherwise.
=> (eval '(list 1 2 3))(call fun arg*)
(1 2 3)
=> (call 'conc '(a b) '(c d))
(a b c d)
(apply fun arglist)
This function takes a function (denoted by fun) and a list of arguments to that
function (denoted by arglist). It calls the function with the given arguments
and returns the result.
=>(apply 'sum '(1 2 3))
6
=>(mkdir "test")(open name mode)
t
=>(setq f (open "test" "w"))
<channel:135236>
(close chan)
Closes the channel chan, and returns t.
=> (close f)
t
(copyfile srcPath dstPath)
Copies the file denoted by srcPath to the file denoted by dstPath.
If the destination file does not exist, it is created. Returns t.
=> (copyfile "Test.java" "CopyOfTest.java")
t
(pathprop path)
Returns a list of properties for the file or directory denoted by path,
or nil if it does not exist.
=> (pathprop "C:\temp\Sample.txt")perm will denote either "r" (for read-only) or "rw" (for read/write); kind will denote "file" or "dir"; size is relevant for files only and denotes the size of the file in bytes.
((perm "rw") (kind "file") (size 4534) (modified "05 Jan 2003, 10:20:02") (created "05 Jan 2003, 10:20:02"))
(flush [chan])
Flushes the buffer of the specified channel (or the default output channel if no channel is
specified), and returns t.
=> (flush f)(read [chan])
t
=> (read) hello(print expr ... expr [chan])
hello
=> (print "hello")(tab column [chan])
"hello"t
=> (princ "hello")
hellot
=> (princom "hello^r^nFriend!" "\line \tab ")
hello\line \tab Friend!t
=> (tab 10)(terpri [chan])
t
=> (terpri)(prlen expr [max])
t
=> (prlen "hello")(iobuf [chan])
7
=> (iobuf)(chan? expr)
0
=> (chan? inchan)(pp expr [chan])
t
=> (fun atoms (expr)
(cond [(null? expr) 0]
[(atom? expr) 1]
[t (+ (atoms (car expr)) (atoms (cdr expr)))]))
atoms
=> (pp 'atoms)
(lam (expr)
(cond ((null? expr) 0)
((atom? expr) 1)
(t (+ (atoms (car expr)) (atoms (cdr expr))))))t
=> (+ 10 20)(- num1 num2)
30
=> (- 10.5 20.8)(* num1 num2)
-10.299999
=> (* 2.4 3)(/ num1 num2)
7.200000
=> (/ 10 3)(sum num*)
3
=> (/ 10 3.0)
3.333332
=> (sum 2 10 40 33)(prod num*)
85
=> (prod 1.3 2 8)(% num1 num2)
20.799999
=> (% 10 3)(^ num1 num2)
1
=> (^ 4 3)(++ inum)
64.000000
=> (++ 5)(-- inum)
6
=> (-- 5)(abs num)
4
=> (abs -3.14)(neg num)
3.140000
=> (neg 1.23)(int rnum)
-1.230000
=> (int 10.54)(real inum)
10
=> (real 10)(< num1 num2)
10.000000
=> (< 4 4.2)(> num1 num2)
t
=> (> 4 4.2)(<= num1 num2)
nil
=> (<= 4 4.2)(>= num1 num2)
t
=> (>= 4 4.0)(= num1 num2)
t
=> (= 4 4.2)(/= num1 num2)
nil
=> (/= 5 5.4)(number? expr)
t
=> (number? 10.22)(int? expr)
t
=> (int? 10.22)(real? expr)
nil
=> (real? 10.22)
t
=> (<< "hello" "hi")(>> str1 str2)
t
=> (>> "hello" "hi")(== str1 str2)
nil
=> (== "hello" "HELLO")(strcmp str1 str2)
nil
=> (strcmp "artist" "scientist")(strto str to)
-18
=> (strto "artist" 'upper)(nthchar str n)
"ARTIST"
=> (nthchar "hello" 1)(setchar str n ch)
101 ;; ASCII code for 'e'
=> (setchar "big" 1 (nthchar "o" 0))(substr str i j)
"bog"
=> (substr "automatically" 5 4)(subststr str oldStr newStr)
"atic"
=> (substr "aaa.bbb.ccc" "." "/")(findstr str substr)
"aaa/bbb/ccc"
=> (findstr "automatically" "mat")(strlen str)
4
=> (strlen "hello")(strconc expr1 expr2 ...)
5
=> (strconc "auto" "matic" 2)(pathconc path1 path2 ...)
"automatic2"
=> (pathconc "Project\Part1" "Test.java")(pathparts path)
"Project\Part1\Test.java"
=> (pathparts "C:Project\Part1\Test.java")(nilstr? str)
("C:" "Project\Part1" "Test" "java")
=> (nilstr? "")(string? expr)
t
=> (string? "hello")
t
=> (symname 'lam)(synonym sym1 sym2)
"lam"
=> (synonym add +)(gensym)
add
=> (add 4.5 5)
9.500000
=> (gensym)(concat str+)
g0000
=> (concat 'loop "-" "variable")(binding sym)
loop-variable
=> (binding '+)(symbol? expr)
lam#76
=> (symbol? 'x)(bound? sym)
t
=> (bound? 'x)
t
=> (car '(a b c))(cdr list)
a
=> (cdr '(a b c))(c..r list)
(b c)
=> (cadr '(a b c))(nthelem list n)
b
=> (cdddr '(a b c))
nil
=> (nthelem '(a b c) 2)(nthpair list n)
b
=> (nthpair '(a b c) 2)(rplaca list newhead)
(b c)
=> (rplaca '(a b c) 'x)(rplacd list newtail)
(x b c)
=> (rplacd '(a b c) '(x))(lastpair list)
(a x)
=> (lastpair '(a b c))(lastelem list)
(c)
=> (lastelem '(a b c))(sublist list key)
c
=> (sublist '((name Alan) (sports cycling chess)) 'sports)(cons expr list)
(cycling chess)
=> (cons 'a '(b c))(list expr*)
(a b c)
=> (list 'a '(b) 'c)(length list)
(a (b) c)
=> (length '(a b c))(conc list1 list2+)
3
=> (conc '(a b) '(c) '(d e))(remove elem list)
(a b c d e)
=> (*conc '(a b) '(c) '(d e))
(a b c d e)
=> (remove 'a '(a b a c))(subst this that list)
(b c)
=> (*remove 'a '(a b a c))
(b c)
=> (subst 'x 'a '(a (b a) c))(reverse list)
(x (b x) c)
=> (*subst 'x 'a '(a (b a) c))
(x (b x) c)
=> (reverse '(a (b c) d))(member expr list)
(d (b c) a)
=> (*reverse '(a (b c) d))
(d (b c) a)
=> (member '(b c) '(a (b c) d))(equal expr1 expr2)
((b c) d)
=> (memq 'c '(a b c d))
(c d)
=> (equal '(a b c) '(a b c))(nequal expr1 expr2)
t
=> (eq 'a 'a)
t
=> (nequal '(a b c) '(a b c))(atom? expr)
nil
=> (neq 'a 'a)
nil
=> (atom? 'a)(list? expr)
t
=> (list? '(a))(null? expr)
t
=> (null? '())(pair? expr)
t
=> (pair? '(a b c))
t
=> (convset '(a b a c a))(convlist set)
{a c b}
=> (*convset '(a b a c a))
{b c a}
=> (convlist '{a b c})(eset expr*)
(c b a)
=> (*convlist '{a b c})
(a b c)
=> (eset 'a 'b 'a 'b 'c)(iset gen (var1 dom1 [vari domi]*) expr*)
{c b a}
=> (iset (* x x) (x '(1 2 3 4 5 6 7 8 9)) (= (% x 2) 0))(union set*)
{64 36 16 4}
=> (iset (list x y) (x '{1 2 3} y '{1 2 3}))
{(3 1) (3 2) (3 3) (2 1) (2 2) (2 3) (1 1) (1 2) (1 3)}
=> (union '{a b c d} '{e a c f})(intsec set*)
{f e a b c d}
=> (intsec '{a b c d} '{e a c f})(diff set1 set2)
{c a}
=> (diff '{a b c d} '{e a c f})(subset set1 set2)
{d b}
=> (subset '{a b c} '{a c d b})
t
=> (setq x 10)(not expr)
10
=> (cond [(< x 10) 'short]
[(= x 10) 'medium]
[t 'large])
medium
=> (not (member 'a '(e f b)))(and expr*)
t
=> (and (member 'a '(a b c))(or expr*)
(member 'b '(a b c)))
(b c)
=> (or (member 'g '(a b c))(==> expr1 expr2)
(member 'c '(a b c)))
(c)
=> (==> (member 'a '(a b))(<=> expr1 expr2)
(member 'a '(a b c)))
t
=> (<=> (eq 'x 'y)(all (var1 dom1 [vari domi]*) expr*)
(eq 'y 'x))
t
=> (all (x '{1 2 3 4 5}) (< (* x x) 30))(exist (var1 dom1 [vari domi]*) expr*)
t
=> (exist (x '{1 2 3} y '{10 20 30}) (= (+ x y) 23))(one (var dom default) expr*)
t
=> (one (x '{10 20 30} 'ERROR) (= (/ x 10) 2))
20
=> (putprop 'table 'blue 'color)(remprop sym property)
blue
=> (putprop 'table '15 'height)
15
=> (remprop 'table 'color)(get sym property)
(color blue)
=> (get 'table 'height)(plist sym)
15
=> (plist 'table)(setplist sym plist)
(height 15)
=> (setplist 'table '(color blue height 15))
(color blue height 15)
=> (assoc 'job '((name Peter) (job pilot) (age 35)))(assq key alist)
(job pilot)
=> (assq 'job '((name Peter) (job pilot) (age 35)))
(job pilot)
=> (setq x (vector 5))(store (vector index) expr)
vector[5]
=> (store (x 0) '(a b c))(dimension vector)
(a b c)
=> (x 0)
(a b c)
=> (dimension x)(vector? expr)
5