File: get.tcl

package info (click to toggle)
scilab 2.4-1
  • links: PTS
  • area: non-free
  • in suites: potato, slink
  • size: 55,196 kB
  • ctags: 38,019
  • sloc: ansic: 231,970; fortran: 148,976; tcl: 7,099; makefile: 4,585; sh: 2,978; csh: 154; cpp: 101; asm: 39; sed: 5
file content (88 lines) | stat: -rw-r--r-- 1,706 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
############################################
# TKSCILAB Gui Interface facility for Scilab
# Bertrand Guiheneuf - 1998 
############################################
#




######################################################################################
proc GetField { handle field } {
# This the procedure called when get(...) is invoked by Scilab 
# There is a simple default behaviour when there is no
# a default behaviour when there is no
# specific get function associated to $field
# it just returns the value of the field 
# in a *string*.

  global Win;
  set name $Win($handle);
  global "$name";
  
  # implemented fields
  set KnownFunc  { value };

  # is it an implemented?
  set idx  [lsearch $KnownFunc $field];
    
  if { $idx != -1} {
    
    # call the specific getfield
    "Get$field" $name ;    

  } else {

    # just get the string
      if ([info exists "$name\($field)"]) {
	  return [set "$name\($field)"];
      } else {
	  return "";
      }
  }
}










proc Getvalue { name } {
    # return the value field of a control
    # when the control is a listbox, retruns a string 
    # 'idx1|idx2 ...' where idx1, .. are the indexes of
    # the selected items;

    global $name;
    
    set style [ set "$name\(style)"];
    switch -exact -- $style {
	
	listbox {
	    
	    set path [ set "$name\(path)"];
	    set sel [$path.list curselection];
	    set tmp [list];
	    for {set i 0} {$i< [llength $sel]} {incr i} {
		set current [lindex $sel $i];
		incr current; 
		lappend tmp $current;
	    }
	    
	    return [join $tmp |];
	}
	
	default {
	    if ([info exists "$name\(value)"]) {
		return [set "$name\(value)"];
	    } else {
		return "";
	    }
	}
    }

}