File: load.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 (74 lines) | stat: -rw-r--r-- 1,549 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
#
# load.tcl
#

proc load(go) {} {
    global Load

    # check file for reading
    set filename $Load(Directory)/$Load(Filename)
    if { ![isreadable $filename] } { return 0 }

    tcl_to_pm Load
 # Switch on value of Load(Format_Flag): 
 # 0 = unformatted
 # 1 = DsTool 1.x
 # 2 = DsTool 2.0
 # 3 = DsTool Tk
    switch $Load(Format_Flag) {
        0 - 
        1 {
           pm EXEC Load.Go 
           }
	2 {
           pm EXEC Load.Go
           pm PUT Load.Format_Flag 2
           }   
        3 {source $filename}	
        default {
		 puts "filesl: Load(Format_Flag) incorrectly set."
		 message_show "Error: Load(Format_Flag) incorrectly set."
		 return 0}
        }

   # in case this was set to something else, set it back... 
    pm PUT Defaults.Precision 17 
   # in case the points weren't saved, get an accurate count of what's in memory
    pm EXEC Memory.Count

    pm_to_tcl 
    return 1
}


proc load(infile) {} {
    global Control Load


    set directory ""
    set filename $Control(Infile)
    if {![isreadable $filename] } {
	set directory $Load(Directory)
	set filename = $directory$Control(Infile)
	if {![isreadable $filename] } { return 0 }
    }

    set Load(Directory) $directory
    set Load(Filename) $Control(Infile)
    tcl_to_pm Control

    source $filename

    return 1
}

proc isreadable fname {

    # if fname is not a file then then return error
    if {![file isfile $fname]} { return 0 }

    # if file is not readable then return error
    if {![file readable $fname]} { return 0 }

    return 1
}