[Tcladdressbook-commits] Help TclAB_QuickStart.tcl,1.2,1.3
Status: Alpha
Brought to you by:
bdesgraupes
|
From: <bde...@us...> - 2003-12-28 07:47:27
|
Update of /cvsroot/tcladdressbook/Help In directory sc8-pr-cvs1:/tmp/cvs-serv4106/Help Modified Files: TclAB_QuickStart.tcl Log Message: [search] examples Index: TclAB_QuickStart.tcl =================================================================== RCS file: /cvsroot/tcladdressbook/Help/TclAB_QuickStart.tcl,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- TclAB_QuickStart.tcl 9 Dec 2003 09:09:35 -0000 1.2 +++ TclAB_QuickStart.tcl 28 Dec 2003 07:47:23 -0000 1.3 @@ -6,7 +6,7 @@ # Author: Bernard Desgraupes # e-mail: <bde...@ea...> # Web page of the Tcladdressbook extension: -# http://sourceforge.net/project/showfiles.php?group_id=96169 +# <http://sourceforge.net/projects/tcladdressbook> # # $Date$ # $Revision$ @@ -14,84 +14,281 @@ # Load the extension -package require addressbook - -# Count the existing groups and person records -addressbook count -groups -addressbook count -persons + package require addressbook +# Using the commands +# The [groups] command # List the groups (name and ID) -addressbook groups + + addressbook groups + # List the groups (only ID) -addressbook groups -ids + + addressbook groups -ids + +# List the subgroups of a specific group (name and ID) + + set groupid [lindex [addressbook groups -ids] 2] + addressbook groups -ingroup $groupid + +# List the subgroups of a specific group (only ID) + + addressbook groups -ids -ingroup $groupid + +# The [persons] command # List the person records (name and ID) -addressbook persons + + addressbook persons + # List the person records (only ID) -addressbook persons -ids + addressbook persons -ids -# Store the info about "me" in the array arr and display the results -# with the [parray] command -addressbook getme arr -parray arr -# Put the ID of the first record in the variable theid -set theid [lindex [addressbook persons -ids] 0] -# Store the info about this record in the array arrperson and display the -# results with the [parray] command -addressbook record $theid arrperson -parray arrperson +# The [count] command +# Count the existing groups and person records -# Put the ID of the first group in the variable theid -set theid [lindex [addressbook groups -ids] 0] -# Store the info about this group in the array arrgrp and display the -# results with the [parray] command -addressbook record $theid arrgrp -parray arrgrp + addressbook count -groups + addressbook count -persons + addressbook count -persons -ingroup [lindex [addressbook groups -ids] 0] -# Find the type of the object corresponding to the ID $theid (ABPerson or ABGroup) -addressbook type $theid + +# The [getme] command +# Store the info about "me" in the variable myrecord. + + set myrecord [addressbook getme] + +# The value of myrecord is a keyed list. One can use the usual Tcl list +# commands or the special keylist commands defined in the TclX extension +# like this: + + keylkeys myrecord + keylget myrecord Email.work + keylget myrecord Address.home.ZIP + clock format [keylget myrecord Birthday] + +# The [record] command +# Store the ID of the first record in the variable theid + + set theid [lindex [addressbook persons -ids] 0] + +# Store the info about this record in the variable "person". The syntax is +# the same as with the [getme] command. + + set person [addressbook record $theid] + keylkeys person + keylget person Email.work + keylget person Address.home.ZIP + clock format [keylget person Birthday] + + + +# Store the ID of the first group in the variable theid + + set theid [lindex [addressbook groups -ids] 0] + +# Store the info about this group in the variable grp + + set grp [addressbook record $theid] + keylkeys grp + keylget grp GroupName + clock format [keylget grp Modification] + + + +# The [type] command +# Find the type (ABPerson or ABGroup) of the object corresponding +# to the ID $theid + + addressbook type $theid + + + +# The [property names] command # Get the list of all existing properties for groups or persons -addressbook properties -groups -addressbook properties -persons + + addressbook property names -groups + addressbook property names -persons + +# The [remove] command # Remove the record corresponding to the ID $theid from the database -addressbook remove $theid + + addressbook delete $theid + # Check that there were changes (1 if yes, 0 if no) -addressbook changed + + addressbook changed + # Save the changes to make them permanent -addressbook save + + addressbook save # Remove the record corresponding to the ID $theid from a specific group: # it is removed as member of this subgroup but will be removed from the # database only if it does not belong to other groups. -set groupid [lindex [addressbook groups -ids] 0] -set theid [lindex [addressbook persons -ids] 0] -addressbook remove $theid -fromgroup $groupid + set groupid [lindex [addressbook groups -ids] 0] + set theid [lindex [addressbook persons -ids] 0] + addressbook delete $theid -fromgroup $groupid -# List the subgroups of a specific group (name and ID) -set theid [lindex [addressbook groups -ids] 2] -addressbook groups $theid -ingroup $groupid -# List the subgroups of a specific group (only ID) -addressbook groups $theid -ingroup $groupid -ids +# The [parents] command # List the parents of a person record (the various groups it belongs to). # One can also find the parents of a group with this command. -set theid [lindex [addressbook persons -ids] 0] -addressbook parents $theid + + set theid [lindex [addressbook persons -ids] 0] + addressbook parents $theid + # List the parents of a person record (only ID) -addressbook parents $theid -ids + + addressbook parents -ids $theid + + + +# The [create] command + (group|person) + +# The [property type] command +# Get the name of a particular property + + addressbook property type -groups UID + addressbook property type -persons Address + + +# The [property add] command +# Add a new property of type String called Instrument + + addressbook property add -persons Instrument String + + +# Add a new property of type Date called Meeting + + addressbook property add -groups Meeting Date + + +# The [property remove] command +# Remove the properties created above + + addressbook property remove -persons Instrument + addressbook property remove -groups Meeting + + + +# The [export] command +# Create a VCard corresponding to a particular record. + + set theid [lindex [addressbook persons -ids] 0] + +# The data returned is binary. You can store it in a file. + + set vcardData [addressbook export $theid] + + + +# The [import] command + + set fname [file join /Users bernardo someVcard.vcf] + set fid [open $fname r] + set vcard [read $fid] + close $fid + addressbook import $vcard + + + +# The [image] command + + set theid [lindex [addressbook persons -ids] 0] + set img [addressbook image $theid] + + + +# The [set] command + + set theid [lindex [addressbook persons -ids] 0] + addressbook set $theid First + + + + addressbook set $theid First Georgios + addressbook changed + addressbook save + + + + addressbook set $theid First Johann-Sebastian + +# Multi string value + addressbook set $theid Email {{Work wo...@ha...} {Concerts DD...@su...}} + addressbook set $theid Email {{Work op...@or...} {Concerts BW...@CA...}} + + +# Date value + addressbook set $theid Birthday [clock scan "1 Apr 1985"] + + +# Multi date value + addressbook set $theid ABDate + addressbook set $theid ABDate [list [list "birthday Franny" 621597600] [list "birthday Zooey" 816692400]] + + + +# Multi dictionary value + addressbook set $theid Address + addressbook set $theid Address [list [list Home [list {CountryCode fr} {City Paris} {Country France} {ZIP 75001} {Street "1, avenue de l'Opéra"}] ] ] + + + +# The [search] command + + addressbook search -persons -ids -nocase Last == "Bach" + addressbook search -persons -ids -nocase Last > "Ba" + + + + addressbook search -persons -nocase Modification >= 1070199949 + addressbook search -persons -nocase Modification < 1070199949 + + +# Multi string value. It searches one value at a time. + addressbook search -persons Phone == {Work "01 02 03 04 05"} + +# Empty label --> to search on all phones + addressbook search -persons Phone >= {"" "01 02 03 04 05"} + + +# Multi dict value. It searches one key in one dictionary at a time. + addressbook search -persons -nocase Address == {Home {ZIP 98765}} + addressbook search -persons -nocase Address >= {Home {ZIP 98}} + +# Empty label --> to search on all labels + addressbook search -persons -nocase Address >= {"" {City Paris}} + +# Empty key --> to search on all keys + addressbook search -persons -nocase Address >= {home {"" abc}} + +# Empty label and key --> to search on all labels and keys + addressbook search -persons -nocase Address >= {"" {"" abc}} + + + +# Using keyed lists + + package require tclx + + +# ---------------------------------------------------------------------- +# Last updated 2003-12-28 08:36:25 |