File: app_init.tcl

package info (click to toggle)
dstooltk 2.0-3
  • links: PTS
  • area: main
  • in suites: potato, slink
  • size: 2,500 kB
  • ctags: 3,169
  • sloc: ansic: 27,185; tcl: 4,770; makefile: 587; sh: 70; csh: 7
file content (91 lines) | stat: -rw-r--r-- 1,545 bytes parent folder | download | duplicates (2)
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
89
90
91
#
# app_init.tcl
#

proc app_init_tcl {} {
    global DEBUG tcl_precision tcl_prompt1 main

    #set the DEBUG flag
    set DEBUG 0

    # full precision for double <--> str conversions
    set tcl_precision 17
 
    # set prompt routine
    set tcl_prompt1 "app_prompt"
    
    install_postmaster

    # set initial message
    message_push "DsTool - A DYNAMICAL SYSTEMS TOOLKIT"
}

proc app_prompt {} {
    puts -nonewline "DsTool% "
}


proc load_model n {
    global Model

    begin_wait "Loading new model."
    pm PUT Model.Load_Number $n
    pm EXEC Model.Load
    pm_to_tcl
    if { [llength [ info procs window(rebuild)]] > 0 } {
	window(rebuild)
    }
    end_wait "New model loaded."

}

proc load_model_by_name name {
    global Model

    for {set i 0} {$i < $Model(Names)} {incr i} {
	if {[string compare $name $Model(Names,$i)] == 0} {
	    load_model $i
	    return
	}
    }
    
    # Cannot match model name

}

proc pmtcl_func args {
    tcl_to_pm
    pm_to_tcl
    eval $args
    pm_to_tcl
}

proc message_show msg {
    global main
    set main(message) $msg
}

proc message_push msg {
    global main

    lappend main(msgstack) $msg
    message_show $msg
}

proc message_pop {args} {
    global main

    set n [llength $main(msgstack)]
    if {$n <= 1} {
	puts "error - nothing left on main message stack"
    } else {
	incr n -1
	if {[llength $args]} {
	    message_show [lindex $args 0]
	} else {
	    message_show [lindex $main(msgstack) [expr $n-1]]
	}
	set main(msgstack) [lreplace $main(msgstack) $n $n]
    }
}