1##########################################################################
2# TEPAM - Tcl's Enhanced Procedure and Argument Manager
3##########################################################################
4#
5# 1b_procedure_interactive.demo: This file is part of the TEPAM demo
6#
7# Copyright (C) 2009, 2010 Andreas Drollinger
8# 
9# RCS: @(#) $Id: 1c_procedure_interactive_aux.demo,v 1.1 2010/02/11 21:54:38 droll Exp $
10##########################################################################
11# See the file "license.terms" for information on usage and redistribution
12# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
13##########################################################################
14
15#### Initialization ####
16
17DemoControl(Initialization) 1
18DemoControl(IsExecutable) {0}
19
20# This demo shows two features for interactive procedure calls.
21# The first example shows how additional arguments can be declared and defined that will 
22# just be used for the interactive dialog box.
23# The second example shows how the declared arguments can be commented in a way that the
24# interactive argument definition form organizes the entries in sections (frames).
25
26   package require Tk
27   package require tepam
28   namespace import -force tepam::*; # Import tepam::procedure and tepam::argument_dialogbox
29
30#### AuxArgs ####
31
32DemoControl(IsExecutable) {1}
33
34# In case a procedure is called interactively, additional argument attributes can be provided 
35# to the interactive argument definition form via the -auxargs attribute that is itself a list 
36# of attribute name/attribute data pairs:
37# For example, if a procedure takes as argument a file name it may be beneficial to specify for 
38# the interactive argument definition form the required file type. This information can be 
39# provided via the -auxargs attribute to the argument definition form:
40
41   procedure copy {
42      -return            -
43      -short_description "File copy"
44      -description       "This procedure allows copying a file."
45      -args {
46         {-source -type existingfile -description "Existing file" -auxargs {-filetypes {{"Log files" *.log} {"All files" *.*}}}}
47         {-dest -type file -description "Archived new file"}
48      }
49   } {
50      puts "copy $source into $dest"
51   }
52
53   copy -interactive
54
55#### Argument sections and comments ####
56
57DemoControl(IsExecutable) {1}
58
59# Commenting the declared procedure arguments correctly will allows the interactive
60# argument definition form to organize the different data entry widgets in sections/
61# frames.
62# An argument definition list that starts with '#' is considered as a section comment. 
63# The argument definition list will be trimmed from the '#' characters and the remaining 
64# string will be used as section comment. Section comments can be used to structure 
65# visually the argument definition code. But section comments are also used to structure 
66# the generated help texts and the interactive argument definition forms.
67
68   procedure path_search {
69      -return            -
70      -short_description "Path search"
71      -description       "This function searches an itinerary"
72      -args {
73         {#### Itinerary start ####}
74         {- Please enter into the following fields the itinerary start location}
75         {-start_city -type string}
76         {-start_street -type string}
77         {-start_street_nbr -type integer}
78
79         {#### Itinerary cross point ####}
80         {- Please enter into the following fields an intermediate point of your itinerary}
81         {-through_city -type string}
82         {-through_street -type string}
83         {-through_street_nbr -type integer}
84
85         {#### Itinerary destination ####}
86         {- Specify in the following ifelds your itinarary destination}
87         {-destination_city -type string}
88         {-destination_street -type string}
89         {-destination_street_nbr -type integer}
90         
91      }
92   } {
93      foreach var {mtype font size fg bg no_border text} {
94         if {[info exists $var]} {
95            append Arguments "$var='[set $var]', "
96         }
97      }
98      puts "path_search([string range $Arguments 0 end-2])"
99   }
100
101   path_search -interactive
102
103##########################################################################
104# $RCSfile: 1c_procedure_interactive_aux.demo,v $ - ($Name:  $)
105# $Id: 1c_procedure_interactive_aux.demo,v 1.1 2010/02/11 21:54:38 droll Exp $
106# Modifications:
107# $Log: 1c_procedure_interactive_aux.demo,v $
108# Revision 1.1  2010/02/11 21:54:38  droll
109# TEPAM module checkin
110#
111##########################################################################
112
113