File: tk2.tcl

package info (click to toggle)
tk2 1.1-10
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 356 kB
  • ctags: 182
  • sloc: tcl: 6,182; makefile: 44; sh: 3
file content (176 lines) | stat: -rwxr-xr-x 4,302 bytes parent folder | download | duplicates (5)
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#!/bin/sh
# the next line restarts using wish \
exec wish "$0" "$@"

###################################################################
# This file is part of tk2, a utility program for the
# ICOM IC-R2 receiver.
# 
#    Copyright (C) 2001 - 2004, Bob Parnass
#					AJ9S
# 
# tk2 is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 2 of the License,
# or (at your option) any later version.
# 
# tk2 is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with tk2; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
# 02111-1307  USA
###################################################################


######################################################################
# NOTES:
#	There are 2 levels of data structures within this
#	program:
#
#	(1) Mimage - a 4,032 byte string stored in binary format
#		It must be converted to ASCII for reading and
#		writing to the radio.
#
#	(2) Arrays containing memory channel and configuration
#		information.
#
#
#	The memory image Mimage string becomes populated in these
#	scenarios:
#
#		- image data is read from the radio
#		- image data is read from a .tk2 file
#		- array data is encoded into the image
#			prior to writing the image to the radio
#
#	Some or all of the arrays become populated in these
#	scenarios:
#
#		- by parsing the memory image string
#		- by importing memory channel info from a .csv file
#		- by a user changing widget values in the GUI
#
# Most of the protocol and memory image layout information
# used in this software was obtained from the document entitled
# "Cloning ICOM Receivers, Using the ICOM IC-R2 Handheld
# Scanner as an example," by BlakkeKatte@yahoo.co.uk.
# It is available for download at http://uk.geocities.com/blakkekatte
#
# The template file consists of the memory image, optionally
# followed by memory channel labels.
#
######################################################################

######################################################################
# Write error messages to stderr if linux/unix, stdout otherwise
######################################################################

proc Tattle { msg } \
{
	global tcl_platform

	 set platform $tcl_platform(os) 
	 switch -glob $platform \
		{
		{[Ll]inux} \
			{
			puts stderr $msg
			}
		{unix} \
			{
			puts stderr $msg
			}
		default \
			{
			puts $msg
			}
		}

	return
}
############################################################
set Version "1.1"

set AboutMsg  "tk2
version $Version

Copyright 2001 - 2004, Bob Parnass
Oswego, Illinois
USA
http://parnass.com

Released under the GNU General Public License.

tk2 is a utility program for the
ICOM IC-R2 receiver.
This is beta software. If you find a defect,
please report it."

############################################################

# trace variable Sid r {puts stderr "Sid trace trap"}
set Pgm [lindex [split $argv0 "/"] end]
set Lfilename ""

if { [catch {set Libdir $env(tk2)} ] } \
	{
	Tattle "$Pgm: error: Environment variable tk2 must"
	Tattle "be set to the directory containing the library"
	Tattle "files for program $Pgm."
	exit 1
	}

set ScanFlag 0


# Sanity check for the Libdir environment variable.
if {$Libdir == ""}\
	{
	Tattle "$Pgm: error: Environment variable tk2 must"
	Tattle "be set to the directory containing the library"
	Tattle "files for program $Pgm."
	exit 1
	}

source [ file join $Libdir "misclib.tcl" ]
source [ file join $Libdir "mylib.tcl" ]
source [ file join $Libdir "api2.tcl" ]
source [ file join $Libdir "gui2.tcl" ]

SetUp


SetWinTitle

set lst [ InitStuff ]
set Rcfile [ lindex $lst 0 ]
set LabelFile [ lindex $lst 1 ]

FirstTimeCheck $Rcfile

# Set most global variables from configuration file.

PresetGlobals
ReadSetup
OverrideGlobals



set CancelXfer 0

set FileTypes \
	{
	{"IC-R2 data files"           {.csv .txt}     }
	}

set Mimage ""

# Create graphical widgets.

MakeGui

update idletasks