📄 metakit for tcl.mht
字号:
<P></P>
<DT>EXAMPLES
<DD>Define a cursor pointing to a new empty row: <PRE> set cursor =
[mk::row create]</PRE>Initialize a temporary view with 100=20
copies of the string "Hello": <PRE> mk::cursor create cursor=20
mk::row insert $cursor 100 [mk::row create text "Hello"]</PRE>
<P>
<P></P>
<DT><A name=3Dmk_get>
<HR SIZE=3D1>
</A>
<H2>mk::get</H2>
<DD>
<H3>Fetch values</H3>
<P></P>
<DT>SYNOPSIS
<DD><B>mk::get</B> <I>cursor</I> ?-size?<BR><B>mk::get</B> =
<I>cursor</I> ?-size? <I>prop</I> <I>...</I>=20
<BR>
<P></P>
<DT>DESCRIPTION
<DD>The <B>mk::get</B> command fetches values from the row specified =
by=20
<I>cursor</I>.=20
<P>Without argument, <I>get</I> returns a list of <I>'prop1 value1 =
prop2=20
value2 ...'</I>. This format is most convenient for setting an array =
variable,=20
as the following example illustrates: <PRE> array set v [mk::get =
db.phonebook!0]
parray v</PRE>Note that the <I>cursor</I> argument can be the value =
of a=20
cursor variable, or it can be synthesized on the spot, as in the above =
example.=20
<P>If the <B>-size</B> option is specified, the size of property =
values is=20
returned instead of their contents. This is normally in bytes, but for =
integers it can be a negative value indicating the number of bits used =
to=20
store ints (-1, -2, or -4). This is an efficient way to determine the =
sizes of=20
property values without fetching them.=20
<P>If arguments are specified in the <I>get</I> command, they are =
interpreted=20
as property names and a list will be returned containing the values of =
these=20
properties in the specified order.=20
<P>If <I>cursor</I> does not point to a valid row, default values are =
returned=20
instead (no properties, and empty strings or numeric zero's, according =
to the=20
property types).=20
<P>
<P></P>
<DT>EXAMPLES
<DD>Set up an array containing all the fields in the third row: <PRE> =
array set fields [mk::get db.phonebook!2]</PRE>Created a line with=20
some formatted fields: <PRE> puts [eval [list format {%-20s %d}] =
[mk::get db.phonebook!2 name date]]</PRE>
<P>
<P></P>
<DT><A name=3Dmk_set>
<HR SIZE=3D1>
</A>
<H2>mk::set</H2>
<DD>
<H3>Store values</H3>
<P></P>
<DT>SYNOPSIS
<DD><B>mk::set</B> <I>cursor</I> <I>?prop</I> =
<I>value</I>=20
<I>...?</I> <BR>
<P></P>
<DT>DESCRIPTION
<DD>The <B>mk::set</B> command stores values into the row specified by =
<I>cursor</I>.=20
<P>If a property is specified which does not exist, it will be =
appended as a=20
new definition for the containing view. As an important side effect, =
all other=20
rows in this view will now also have such a property, with an =
appropriate=20
default value for the property. Note that when new properties are =
defined in=20
this way, they will be created as string properties unless qualified =
by a type=20
suffix (see <I>'mk::view layout'</I> for details on property types and =
their=20
default values).=20
<P>Using <I>mk::set</I> command without specifying properties returns =
the=20
current value and is identical to <I>mk::get</I>.=20
<P>If <I>cursor</I> points to a non-existent row past the end of the =
view, an=20
appropriate number of empty rows will be inserted first.=20
<P>
<P></P>
<DT><A name=3Dmk_loop>
<HR SIZE=3D1>
</A>
<H2>mk::loop</H2>
<DD>
<H3>Iterate over the rows of a view</H3>
<P></P>
<DT>SYNOPSIS
<DD><B>mk::loop</B> <I>cursorName</I> <I>{body}</I>=20
<BR><B>mk::loop</B> <I>cursorName</I> <I>path</I>=20
<I>{body}</I> <BR><B>mk::loop</B> <I>cursorName</I>=20
<I>path</I> <I>first</I> <I>?limit?</I> =
<I>?step?</I>=20
<I>{body}</I> <BR>
<P></P>
<DT>DESCRIPTION
<DD>The <B>mk::loop</B> command offers a convenient way to iterate =
over the=20
rows of a view. Iteration can be restricted to a certain range, and =
can=20
optionally use a forward or backward step. This is a convenience =
function=20
which is more efficient than performing explicit iteration over an =
index and=20
positioning a cursor.=20
<P>When called with just a <I>path</I> argument, the loop will iterate =
over=20
all the rows in the corresponding view. The <I>cursorName</I> loop =
variable=20
will be set (or reset) on each iteration, and is created if it did not =
yet=20
exist.=20
<P>When <I>path</I> is not specified, the <I>cursorName</I> variable =
must=20
exist and be a valid cursor, although its current position will be =
ignored.=20
The command <I>'mk::loop X {...}'</I> is identical to <I>'mk::loop X =
$X=20
{...}'</I>.=20
<P>The <I>first</I> argument specifies the first index position to use =
(default 0), the <I>limit</I> argument specifies the last argument =
(default=20
'end'), and the <I>step</I> argument specifies the increment (default =
1). If=20
<I>step</I> is negative and <I>limit</I> exceeds <I>first</I>, then =
the loop=20
body will never be executed. A zero <I>step</I> value can lead to =
infinite=20
looping unless the <I>break</I> command is called inside the loop.=20
<P>The <I>first</I>, <I>limit</I>, and <I>step</I> arguments may be =
arbitrary=20
integer expressions and are evaluated exactly once when the loop is =
entered.=20
<P>Note that you cannot easily use a loop to insert or delete rows, =
since=20
changes to views do not adjust cursors pointing into that view. =
Instead, you=20
can use tricks like moving backwards (for deletions), or splitting the =
work=20
into two separate passes.=20
<P></P>
<DT><A name=3Dmk_elect>
<HR SIZE=3D1>
</A>
<H2>mk::select</H2>
<DD>
<H3>Selection and sorting</H3>
<P></P>
<DT>SYNOPSIS
<DD><B>mk::select</B> <I>path</I> <I>?options</I>=20
<I>...?</I> <BR>
<P></P>
<DT>DESCRIPTION
<DD>The <B>mk::select</B> command combines a flexible selection =
operation with=20
a way to sort the resulting set of rows. The result is a list of row =
index=20
numbers (possibly empty), which can be used to reposition a cursor and =
to=20
address rows directly.=20
<P>A selection is specified using any combination of these criteria:=20
<UL>
<DL>
<DT><I>prop</I> <I>value</I>=20
<DD>Numeric or case-insensitive match=20
<DT><B>-min</B> <I>prop</I> <I>value</I>=20
<DD>Property must be greater or equal to value (case is ignored)=20
<DT><B>-max</B> <I>prop</I> <I>value</I>=20
<DD>Property must be less or equal to value (case is ignored)=20
<DT><B>-exact</B> <I>prop</I> <I>value</I>=20
<DD>Exact case-sensitive string match=20
<DT><B>-glob</B> <I>prop</I> <I>pattern</I>=20
<DD>Match "glob-style" expression wildcard=20
<DT><B>-globnc</B> <I>prop</I> <I>pattern</I>=20
<DD>Match "glob-style" expression, ignoring case=20
<DT><B>-regexp</B> <I>prop</I> <I>pattern</I>=20
<DD>Match specified regular expression=20
<DT><B>-keyword</B> <I>prop</I> <I>word</I>=20
<DD>Match word as free text or partial prefix </DD></DL></UL>If =
multiple=20
criteria are specified, then selection succeeds only if all criteria =
are=20
satisfied. If <I>prop</I> is a list, selection succeeds if <I>any</I> =
of the=20
given properties satisfies the corresponding match.=20
<P>Optional selection constraints:=20
<UL>
<DL>
<DT><B>-first</B> <I>pos</I>=20
<DD>Selection starts at specified row index=20
<DT><B>-count</B> <I>num</I>=20
<DD>Return no more than this many results </DD></DL></UL>Note: not =
yet very=20
useful with sorting, which is done after these constraints have been =
applied.=20
<P>To sort the set of rows (with or without preliminary selection), =
use:=20
<UL>
<DL>
<DT><B>-sort</B> <I>prop</I> <BR><B>-sort</B> {<I>prop</I> ...}=20
<DD>Sort on one or more properties, ascending=20
<DT><B>-rsort</B> <I>prop</I> <BR><B>-rsort</B> {<I>prop</I> ...}=20
<DD>Sort on one or more properties, descending =
</DD></DL></UL>Multiple sort=20
options are combined in the order given.=20
<P>
<P></P>
<DT>EXAMPLES
<DD>Select a range of entries: <PRE> foreach i [mk::select =
db.phonebook -min date 19980101 -max date 19980131] {
puts "Dated Jan 1998: [mk::get db.phonebook!$i name]"
}</PRE>Search for a unique match (<I>'-count 2'</I> speeds up =
selection=20
when many entries match): <PRE> set v [mk::select db.phonebook =
-count 2 -glob name "John*"]
switch [llength $v] {
0 {puts "not found"}
1 {puts "found: [mk::get db.phonebook![lindex $v 0] =
name]"}
2 {puts "there is more than one entry matching 'John*'"}
}</PRE>Sort by descending date and by ascending name: <PRE> =
foreach i [mk::select db.phonebook -rsort date -sort name] {
puts "Change log: [mk::get db.phonebook!$i date name]"
}</PRE>
<P>
<P></P>
<DT><A name=3Dmk_channel>
<HR SIZE=3D1>
</A>
<H2>mk::channel</H2>
<DD>
<H3>Channel interface</H3>
<P></P>
<DT>SYNOPSIS
<DD><B>mk::channel</B> <I>path</I> <I>prop</I> =
<I>?mode?</I>=20
<BR>
<P></P>
<DT>DESCRIPTION
<DD>The <B>mk::channel</B> command provides a channel interface to =
binary=20
fields. It needs the <I>path</I> of a row and the name of a binary=20
<I>prop</I>, and returns a channel descriptor which can be used to =
read or=20
write from.=20
<P>Channels are opened in one of three modes:=20
<BLOCKQUOTE><B>read</B> - <I>open for reading existing contents=20
(default)</I> <BR><B>write</B> - <I>clear contents and start saving=20
data</I><BR><B>append</B> - <I>keep contents, set seek pointer to =
end</I>=20
</BLOCKQUOTE>
<P>Note: do not insert or delete rows in a view within which there are =
open=20
channels, because subsequent reads and writes may end up going to the =
wrong=20
memo property.=20
<P></P>
<DT>EXAMPLES
<DD>Write a few values (with line separators): <PRE> mk::view =
layout db.v {b:B}
mk::view size db.v 1
set fd [mk::channel db.v!0 b w]
puts $fd one
puts $fd two
puts $fd three
close $fd</PRE>Read values back, line by line: <PRE> set fd =
[mk::channel db.v!0 b]
while {[gets $fd text] >=3D 0} {
puts $text
}
close $fd</PRE>
<P></P></DD></DL><!--END-->
<P>
<HR SIZE=3D1>
© 2005 Jean-Claude Wippler <<A=20
href=3D"mailto:jcw@equi4.com">jcw@equi4.com</A>> </BODY></HTML>
------=_NextPart_000_001B_01C87A5E.3F217190
Content-Type: image/gif
Content-Transfer-Encoding: base64
Content-Location: http://www.equi4.com/metakit/tcl.gif
R0lGODdhMwBLAPcAAP//////zP//mf//Zv//M///AP/M///MzP/Mmf/MZv/MM//MAP+Z//+ZzP+Z
mf+ZZv+ZM/+ZAP9m//9mzP9mmf9mZv9mM/9mAP8z//8zzP8zmf8zZv8zM/8zAP8A//8AzP8Amf8A
Zv8AM/8AAMz//8z/zMz/mcz/Zsz/M8z/AMzM/8zMzMzMmczMZszMM8zMAMyZ/8yZzMyZmcyZZsyZ
M8yZAMxm/8xmzMxmmcxmZsxmM8xmAMwz/8wzzMwzmcwzZswzM8wzAMwA/8wAzMwAmcwAZswAM8wA
AJn//5n/zJn/mZn/Zpn/M5n/AJnM/5nMzJnMmZnMZpnMM5nMAJmZ/5mZzJmZmZmZZpmZM5mZAJlm
/5lmzJlmmZlmZplmM5lmAJkz/5kzzJkzmZkzZpkzM5kzAJkA/5kAzJkAmZkAZpkAM5kAAGb//2b/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DdWeSYQPFZtMCE
DR3xQHAxHYINZhvpQFCCEe2QoXn2NEUSGdjkFdYRBdykoWYjCuSaS7DJVhJgmW24UT07RQVESaTo
eACIRu3GE4MkHeJbaSFupKVLDvi2ChBNkVJPmBQZN1A9gjmwFRkPlHTmemIVdKRLsS1VUkMl8jSV
UTIe8FtTVdCYUkGeiQVEPqQ8QRJjUGYEUqASodeQAzPgFCBH44WJwHccOfaRY1imqKl5DvzY3kfv
hf/XHWdGUsiYjAIpaitPK7WHFH8H2FPpgcQWa2xC9diTH38yyABgDkUeO1B1u0Jkl3/PFvYQZ7pW
m9Koe3rrUkgAhAvRESdOJFmQbBKq1oXn4vbRAgtkZitrAMALUYboWgRtqkYVqcNGt6XGoQ71VAGU
FfpalNZ4SO7gkUTB6sicYMNiGtGJHAFGWkQSmrdDvW0RRO1GNj7Um0yqsGWveRGq66RDtObqkrwp
ftklXpWqW0BK0eI51BE6KElSFzW121CvtVYVm5KH5DdRBN4N1ODQT8uWw1pBoChmlFGVlI+O3H0F
tkv5TanVl6scNmZKB6jAIiKd7MiBxha5OZBRKx//GpM9SoP09kYPWKFUViRZEYCjg1ukQ1LIkFFB
TDKY+/WbUT0QCHPOkXRmtxXpKeXYZGStV+BEEWR5ZEUvBVQFwp416FAAHoHMmWmCTtHsr+XgGxks
dtXw5QKd/BqaznhJkgzDEw+xWEeQsc8KtzPG9PMptotAXAjkgNPLUnnvMEEDqwqAROeuOoMDsL6a
IsQDOhTtXued3xBnecV13l7bv8/++wdYU0VqxrUUccYt/JmBDiaigwP8SAd3qccBGoUR9LQHXvi6
GkfOxcHVcOQysKoIvlYnrosEpoRDIVd7UGiUtBhPLj6SAbCEZRCRKCs/B+CPDv3zn2fpQEBA0ElA
AQAAOw==
------=_NextPart_000_001B_01C87A5E.3F217190
Content-Type: image/gif
Content-Transfer-Encoding: base64
Content-Location: http://www.equi4.com/metakit/e4s.gif
R0lGODlhYQAjALMAAAAAADExMWNjY5ycnM7Ozv8AAP8xMf9jY/+cnP/Ozv//////////////////
/////ywAAAAAYQAjAAAE/lDJSau9OOvNu/9gKI4WYJ5oakpqi7KuC8eqVNx4rt8U3c6+EzAIGAZt
uySudxI4n8+XQiUgEAaC2rQpCKCc0hb4p1AWDIYd00TAhJsWQgrYzgoV3tV2jicrD0g5awBtF28A
ARIEAQECioeECnZ6eUV7UpVSSQYTahModTQzbXIniX16oJKYd2SZd0kJnTqDoTEzEq9tA60ntpS9
fK96O4CyZbSfvpJQY6mIRo6llqqTlpVG1345nAmcyILKbBfT1NCXJtLBkda563fDljqyaIFL4pEE
ze1bpyoDCqbRWQXvHTAtORAoQGAAkII04QZa03LHzgAvvwbyKvhM2LYb/scqHIh46ReZEwD7FAIC
RF06lugO8kmYoOaxBCPvDTS0rpCVCRs76gnoExLHmZvs8cC3soLRlIoeCUXUNOhUmZqSgtMZ00c2
Rl4CWDGIiNFJIrDMJBlEJJuorm/RplWbzO0tuHflXvW6le5SEoADCx5MuLDhwxt+Il7M+FOjCmIb
SwYsx1DTyYU3nqqwCBFURWGbZok8gfRm0kDzOKoggNfm0i9DyGnz2CnA2RV4XZbzGY+625aA5otE
gVFAyKtrgwBQ5cLFCV04B+9x+TmWRNE5B9QNuTeLAVZ4ieiMWsJz868DTv90eQqe9wG8h81yOX6c
smDHS8iSe3P2CZWVTNBefNiJB9lmxJXmXYAkcHdeD8Dtth4L7XUhjXEH7pdgLt7hcQqGINhRHmie
3XdBFr3hNsWCqgHQm30X5JEeZjTWaOONOOao4446RgAAOw==
------=_NextPart_000_001B_01C87A5E.3F217190--
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -