This file is indexed.

/usr/bin/tk-brief is in tk-brief 5.9-1.1ubuntu1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

   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
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
#!/bin/bash
# \
exec wish "$0" "$@"

# Copyright (C) 1998-2000 [Ralf Müller]     
#     This program 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.
#     
#     This program 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 this program; if not, write to the Free Software
#     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 						   
set version "5.9"; set version_soll "4.0"; set version_f "4.0"

set Datum(wert) \\today

# Dutch translation thanks to [Remko en Sander]

if {$tcl_platform(platform) == "unix"} {
  font create -family helvetica -weight normal -size 12
  set cfile "$env(HOME)/.tk-brief.conf"
} elseif {$tcl_platform(platform)== "windows"} {
  font create -family helvetica -weight bold -size 10
  set cfile "serienbrief"
} else {
  puts "please mail $tcl_platform(platform) to author"
  set cfile "~/.tk-brief.conf"
  font create -family helvetica -weight bold -size 12
}

option add *font font1

if { [file exists "$env(HOME)/.serienbrief"] && ![file exists ${cfile}] } {
    file rename "$env(HOME)/.serienbrief" ${cfile}
    }

set all_feature_list [list  absender_anzahl abs_nummer titelliste namenliste \
    zusatzliste adressenliste ortliste telephonliste Telefax(do_it) \
    telefaxliste Email(do_it) emailliste Bank(do_it) bankliste blzliste \
    kontoliste Postvermerk(do_it) Postvermerk(wert) an name adresse ort \
    Betreff(wert) Iz(do_it) Iz(wert) Ihr_S(do_it) Ihr_S(wert) \
    Mein_Z(do_it) Mein_Z(wert) uz Anrede(wert) \
    gruss Anlagen(do_it) Anlagen(wert) Verteiler(do_it) Verteiler(wert) \
    print_command edit_command latex_command pdf_command dvips_command \
    ispell_command Fenster(do_it) Fenster(wert) Http(do_it) http trenn \
    loch falt klass fenst size Unterschrift(leer) briefstyle german \
    sprache directory xdvi_command fax_command faxnummer Pak(do_it) \
    Pak(wert) color color2 uni logoliste logobreite coptions sffamily \
    fen_flaglist fax_flaglist email_flaglist url_flaglist \
    bank_flaglist class_list falt_list klass_list sf_list german_list trenn_list \
    mark_list loch_list fen_inhaltlist latex_type acroread_command]
set do_it_list [list Telefax Email Bank Postvermerk Iz Ihr_S Mein_Z Anlagen \
    Verteiler Fenster Http Pak]
set wert_list [list Postvermerk Mein_Z Anlagen Ihr_S Iz Verteiler Fenster Pak]
set cfg_list [list an name adresse ort Betreff(wert) Iz(do_it) Iz(wert) Ihr_S(do_it) \
    Ihr_S(wert) Mein_Z(do_it) Mein_Z(wert) uz Anrede(wert) gruss Anlagen(do_it) \
    Anlagen(wert) Postvermerk(do_it) Postvermerk(wert) Verteiler(do_it) Verteiler(wert)]

proc get_default {name} {
  set Default(titelliste) Titel; set Default(absender_anzahl) 1; 
  set Default(abs_nummer) 0
  set Default(namenliste) "Fred from Jupiter"; set Default(zusatzliste) "";
  set Default(adressenliste) "Channel 8"; set Default(ortliste) "99999 Mars"
  set Default(telephonliste) "++00 1243 555 555"; set Default(telefaxliste) ""
  set Default(emailliste) "jupi@fred.mars.solarsystem.milkyway.de"
  set Default(bankliste) "fridolin bank"; set Default(blzliste) "80 200 30"; 
  set Default(kontoliste) "99 999"; set Default(http) ""
  set Default(fen_flaglist) "0"; set Default(fax_flaglist) 0
  set Default(fen_inhaltlist) ""
  set Default(bank_flaglist) 0; set Default(email_flaglist) 0
  set Default(url_flaglist) 0; set Default(class_list) g-brief
  set Default(german_list) 0; set Default(loch_list) 1
  set Default(falt_list) 1; set Default(klass_list) 0;  set Default(sf_list) 1
  set Default(trenn_list) 1; set Default(mark_list) 1
  set Default(uni) 0; set Default(logoliste) ""; set Default(logobreite) "1cm"
  set Default(Postvermerk_do_it) 0; set Default(Postvermerk_wert) ""
  set Default(Bank_do_it) 0; set Default(Fenster_do_it) 0
  set Default(Telefax_do_it) 0; set Default(Email_do_it) 0
  set Default(Http_do_it) 0; set Default(an) "To"; 
  set Default(name) "Fred from Saturn"; set Default(adresse) "Milky Way 12"
  set Default(ort) "Uranus"; set Default(Betreff_wert) ""
  set Default(Iz_do_it) 0; set Default(Iz_wert) ""; set Default(Ihr_S_do_it) 0
  set Default(Ihr_S_wert) ""; set Default(Mein_Z_do_it) 0 
  set Default(Mein_Z_wert) ""; set Default(uz) 0; 
  set Default(Anrede_wert) "Dear Sirs:"; 
  set Default(Anlagen_do_it) 0; set Default(Anlagen_wert) ""
  set Default(gruss) "Sincerely"; set Default(Verteiler_do_it) 0
  set Default(Verteiler_wert) ""; set Default(print_command) "lpr -Plaser"
  set Default(edit_command) "xterm -fn 10x20 -e sensible-editor"
  set Default(latex_command) "latex"; set Default(dvips_command) "dvips"
  set Default(falt) 1;   set Default(loch) 0; set Default(trenn) 1
  set Default(ispell_command) "xterm -fn 10x20 -e ispell -T latin1 -t "
  set Default(Fenster_wert) "Fred from Jupiter Channel 8 9999 Mars"
  set Default(http) "http://www.deres-mueller.de/tk\\_Brief/"
  set Default(klass) 0;set Default(fenst) 1; set Default(Unterschrift_leer) 1
  set Default(size) "11pt"; set Default(briefstyle) "g-brief"
  set Default(german) 1; set Default(sprache) "English"
  set Default(directory) "./"; set Default(xdvi_command) "xdvi"
  set Default(fax_command) "sendfax"; set Default(faxnummer) ""
  set Default(Pak_do_it) 0;set Default(Pak_wert) ""
  set Default(color) LightSteelBlue;set Default(color2) black
  set Default(directory) "./"; set Default(version_f) "4.0"
  set Default(coptions) ""; set Default(sffamily) "1"
  set Default(latex_type) "pdflatex";  set Default(acroread_command) "xdg-open"
  set Default(pdf_command) "pdflatex"
  regsub "\\(" $name "_" name
  regsub "\\)" $name "" name
  return $Default($name)
}

proc read_new_config {} {
  uplevel #0 {
    while {[gets $readfile zeile] >=0} {
      regsub "\\|" [lindex $zeile 0] "" feature
      regsub {([^ ]*)[ \t]+(.*)} $zeile {\2} zeile

      set $feature $zeile
    }
  }
}

proc check_config {} {
  uplevel #0 {
    foreach feature $all_feature_list {
      if {![info exists $feature]} {
	set ${feature} [get_default ${feature}]
	puts "${feature} \[default\]  [set ${feature}] "
      }
    }
  }
}

proc read_checkbuttons {} {
  uplevel #0 {
    set BANK_FLAG($abs_nummer) $Bank(do_it)
    set TELEFAX_FLAG($abs_nummer) $Telefax(do_it)
    set EMAIL_FLAG($abs_nummer) $Email(do_it)
    set FEN($abs_nummer) $Fenster(do_it)
    set FEN_INHALT($abs_nummer) $Fenster(wert)
    set HTTP_FLAG($abs_nummer) $Http(do_it)
    set TRENN($abs_nummer) $trenn; set GERMAN($abs_nummer) $german
    set KLASS($abs_nummer) $klass; set FENST($abs_nummer) $fenst
    set LOCH($abs_nummer) $loch; set SF($abs_nummer) $sffamily
    set FALT($abs_nummer) $falt
    set CLASS($abs_nummer) $briefstyle;
  }
}

proc get_from_config_file {config_file feature} {
  upvar $feature $feature
  global do_it_list
  global wert_list
  set do_it 0
  set wert 0
  set leer 0
  if {[lsearch $do_it_list $feature ]>=0}  {
    set do_it 1
    if {[lsearch $wert_list $feature]>=0} {
      set wert 1
    }
  } elseif {[lsearch [list Betreff Anrede] $feature] >=0} {
    set wert 1
  } elseif {[lsearch [list Unterschrift] $feature]>=0} {
    set leer 1
  }
  
  if ($do_it) {
    gets $config_file ${feature}(do_it)
    set merker [set ${feature}(do_it)]
    if {$merker == ""} {
      set ${feature}(do_it) [get_default ${feature}_do_it]
      if {$merker != [set ${feature}(do_it)]} {
	puts "${feature}(do_it) not in config_file -> default: [set ${feature}(do_it)] "
      }
    }
  }  
  if ($wert) {
    gets $config_file ${feature}(wert)
    set merker [set ${feature}(wert)]
    if {$merker == ""} {
      set ${feature}(wert) [get_default ${feature}_wert]
      if {$merker != [set ${feature}(wert)]} {
	puts "${feature}(wert) \[default\] [set ${feature}(wert)] "
      }
    }
  }  elseif ($leer) {
    gets $config_file ${feature}(leer)
    if {[set ${feature}(leer)] == ""} {
      set ${feature}(leer) [get_default ${feature}_leer]
      puts "${feature}(leer) \[default\]  [set ${feature}(leer)] "
    }
  } 
  if {($wert==0)&&($do_it==0)&&($leer==0)} {
    gets $config_file ${feature}
    set merker [set $feature]
    if {$merker==""} {
      set ${feature} [get_default $feature]
      if {$merker!=[set $feature]} {
	puts "$feature \[default\] [set $feature] "
      }
    }
  }
}

proc read_file_config {} {
  uplevel #0 {
    if [file exists ${filename}.cfg] {
      set cf [open ${filename}.cfg "r"]
      set readfile $cf
      read_new_config
      close $cf
    }
  }
}

proc read_config {} {
  uplevel #0 { 
    gets $config_file versionzeile
    set version_f [lindex $versionzeile end]
    if {$version_f < 5} {set old_config 1} else {set old_config 0}
    if {$old_config} {
      puts "old configuration found"
      foreach f [list absender_anzahl abs_nummer titelliste namenliste \
	  zusatzliste adressenliste ortliste telephonliste Telefax telefaxliste \
	  Email emailliste Bank bankliste blzliste kontoliste Postvermerk an \
	  name adresse ort Betreff Iz Ihr_S Mein_Z  uz Anrede gruss \
	  Anlagen Verteiler print_command edit_command latex_command pdf_command \
	  dvips_command ispell_command Fenster Http http trenn loch falt klass \
	  fenst size Unterschrift briefstyle german sprache directory \
	  xdvi_command fax_command faxnummer Pak color color2 uni logoliste \
	  logobreite coptions sffamily fen_flaglist fax_flaglist email_flaglist \
	  url_flaglist bank_flaglist class_list falt_list klass_list sf_list \
	  german_list trenn_list mark_list loch_list fen_inhaltlist latex_type acroread_command] {
	get_from_config_file $config_file $f
      }
      close $config_file
    } else {
      set readfile $config_file
      read_new_config
      close $config_file
      check_config
    }
    
    if {$abs_nummer > $absender_anzahl} {
      puts "Fehler in Konfigurationsfile. Absender > Anzahl... Korrigiert."
      set absender_anzahl $abs_nummer
    } 
    if {$absender_anzahl == 0} {
      puts "Fehler in Konfigurationsfile. Anzahl Absender:= 1"
      set  absender_anzahl 1
    }
    for {set j 0} {$j<$absender_anzahl} {incr j} {
      set_list_value TITEL titelliste $j; set_list_value A_ORT ortliste $j
      set_list_value A_NAME namenliste $j; set_list_value BANK_FLAG bank_flaglist $j
      set_list_value BLZ blzliste $j; set_list_value A_ZUSATZ  zusatzliste $j
      set_list_value BANK bankliste $j; set_list_value A_ADRESSE  adressenliste $j
      set_list_value TELEPHON  telephonliste $j;set_list_value TELEFAX telefaxliste $j
      set_list_value EMAIL  emailliste $j; set_list_value KONTO  kontoliste $j
      set_list_value UNI uni 0;  set_list_value CLASS class_list $j
      set_list_value EMAIL_FLAG email_flaglist $j
      set_list_value TELEFAX_FLAG fax_flaglist $j; set_list_value FEN fen_flaglist $j
      set_list_value FEN_INHALT fen_inhaltlist $j
      set_list_value TRENN trenn_list $j; set_list_value FENST mark_list $j
      set_list_value LOCH loch_list $j
      set_list_value FALT falt_list $j; set_list_value KLASS klass_list $j
      set_list_value GERMAN german_list $j; set_list_value SF sf_list $j
      lappend absender_liste $A_NAME($j)
      set_list_value HTTP http $j; set_list_value HTTP_FLAG url_flaglist $j
      if {$uni != ""} {
	set_list_value UNI uni $j; set_list_value LOGOBREITE logobreite $j
	set_list_value LOGO logoliste $j
      }
    }
    read_file_config
  }
}
proc set_language {} {
  uplevel #0 {
set wmtl(Deutsch) "Fehler beim Übersetzen:";set izl(Deutsch) "Ihr Z."
set wmt(Deutsch) "tk-Brief v. $version von Ralf Müller"
set abs(Deutsch) "Dateiname";set adr(Deutsch) "An";set namel(Deutsch) "Name"
set str(Deutsch) "Straße";set faxn(Deutsch) "Faxnummer";set ORT(Deutsch) "Ort"
set postv(Deutsch) "Postvermerk";set vertl(Deutsch) "Verteiler";
set mzl(Deutsch) "Mein Z.";set uzl(Deutsch) "Unser Z.";
set isl(Deutsch) "Ihr Schreiben vom ";set betr(Deutsch) "Betreff"
set anr(Deutsch) "Anrede";set grl(Deutsch) "Gruß";set anll(Deutsch) "Anlagen"
set confl(Deutsch) "Konfiguration";set titl(Deutsch) "Titel"
set confll(Deutsch) "Konfiguration von tk-Brief";set absl(Deutsch) "Absender:"
set zusl(Deutsch) "Zusatz";set fenl(Deutsch) "Fenster";set logo(Deutsch) "Logo"
set blzl(Deutsch) "BLZ";set konl(Deutsch) "Konto";set bankl(Deutsch) "Bank"
set trenl(Deutsch) "Trennlinien";set lochl(Deutsch) "Lochermarken"
set fall(Deutsch) "Faltmarken";set fenll(Deutsch) "Fenstermarken"
set klasl(Deutsch) "klassisch";set endl(Deutsch) "Ende"
set spl(Deutsch) "Speichern";set editl(Deutsch) "Editor";
set drl(Deutsch) "Drucken";set umsch(Deutsch) "Umschlag drucken"
set editll(Deutsch) "Editiere Text";set spell(Deutsch) "Rechtschreibung"
set texl(Deutsch) "LaTeX-Datei";set vorl(Deutsch) "Vorschau"
set serl(Deutsch) "Serienbrief";set serll(Deutsch) "Serienbriefe mit tk-Brief"
set serl1(Deutsch) "Erst Adressen eingeben im Format:";
set cancel(Deutsch) "Abbruch";set edital(Deutsch) "Editiere Adressen"
set serl2(Deutsch) "<An>;<Name>;<Straße>;<PLZ und Ort>"
set editt(Deutsch) "Editiere Text";set editt(Deutsch) "Editiere Text"
set genl(Deutsch)  "Erzeuge PostScript";set aufl(Deutsch) "Aufräumen"
set really2(Deutsch) "Wirklich drucken?";set faxen(Deutsch) "Sende Fax"
set sigl(Deutsch) "Unterschrift";set dirl(Deutsch) "Verzeichnis"
set pak(Deutsch) "Paket";set col(Deutsch) "Farb-Palette"
set col2(Deutsch) "Text-Farbe";set new(Deutsch) "Neuen Absender einführen"
set del(Deutsch) "Absender loeschen";set really(Deutsch) "Wirklich darstellen?"
set kein_abs(Deutsch) "Kein Absender definiert\nBitte neuen Absender einfügen"
set adress_edit(Deutsch) "Keine Adressen definiert\nBitte Adressesn eingeben"
set copt(Deutsch) "Klassenoptionen"; set sffam(Deutsch) "Sans Serif Schrift"
set mindestend(Deutsch) "Es muß mindestens ein Absender definiert sein."

set wmtl(English) "Error during compilation" ; set abs(English) "Filename"
set wmt(English) "tk-Brief v. $version by Ralf Müller";set adr(English) "To"
set namel(English) "Name"; set str(English) "Street";set ORT(English) "City"
set faxn(English) "Faxnumber";set postv(English) "post message"
set vertl(English) "Sender"; set izl(English) "Your S."
set mzl(English) "My S.";set uzl(English) "Our S."
set isl(English) "Your letter from ";set betr(English) "Concerning"
set anr(English) "Salutation";set grl(English) "Greeting"
set anll(English) "Add ons";set confl(English) "Configuration"
set confll(English) "configuration of tk-Brief"
set absl(English) "Sender"; set titl(English) "Title"
set zusl(English) "Addition"; set fenl(English) "Window"
set logo(English) "Logo"; set blzl(English) "bank \#"
set konl(English) "Account"; set bankl(English) "Bank"
set trenl(English) "dividing lines"; set lochl(English) "hole marks"
set fall(English) "folding marks"; set fenll(English) "window marks"
set klasl(English) "classical"; set endl(English) "End"
set spl(English) "Save"; set editl(English) "Editor"
set drl(English) "Print"; set umsch(English) "Print Cover"
set editll(English) "Edit Text"; set spell(English) "Spell Check"
set texl(English) "LaTeX-File"; set vorl(English) "Preview"
set serl(English) "Multiple Let.";set edital(English) "Edit addresses"
set serll(English) "Multiple letters with tk-Brief"
set serl1(English) "Fill in addresses first. Format:"
set serl2(English) "<to>;<name>;<street>;<ZIP and city>"
set editt(English) "Edit text";set really(English) "Confirm preview?"
set cancel(English) "Cancel";set genl(English) "Generate PostScript"
set really2(English) "Confirm print?";set faxen(English) "Send Fax"
set aufl(English) "Clear"; set sigl(English) "Signature"
set dirl(English) "Directory"; set pak(English) "package"
set col(English) "Color of palette";set col2(English) "Color of text"
set new(English) "Create new Sender"; set del(English) "delete Sender"
set kein_abs(English) "No sender defined\nPlease create new sender"
set adress_edit(English) "No addresses defined\nPlease insert addresses"
set copt(English) "class options"; set sffam(English) "sans serif font"
set mindestend(English) "At least 1 sender has to be defined"

set wmtl(Français) "Erreur lors de la compilation" ; set abs(Français) "Nom fichier"
set wmt(Français) "tk-Brief v. $version de Ralf Müller";set adr(Français) "A"
set namel(Français) "Nom"; set str(Français) "Rue";set ORT(Français) "Ville"
set faxn(Français) "Fax";set postv(Français) "Remarque"
set vertl(Français) "Expéditeur"; set izl(Français) "Votre Id."
set mzl(Français) "Mon Id.";set uzl(Français) "Notre Id."
set isl(Français) "Votre lettre du ";set betr(Français) "Objet"
set anr(Français) "Salutation";set grl(Français) "Form. polit."
set anll(Français) "Pièces jointes";set confl(Français) "Configuration"
set confll(Français) "Configuration de tk-Brief"
set absl(Français) "Expéditeur"; set titl(Français) "Titre"
set zusl(Français) "Complément"; set fenl(Français) "Fenêtre"
set logo(Français) "Logo"; set blzl(Français) "banque \#"
set konl(Français) "Compte"; set bankl(Français) "Banque"
set trenl(Français) "lignes de séparation"; set lochl(Français) "marques de perforation"
set fall(Français) "marques de pliage"; set fenll(Français) "coins de fenêtre"
set klasl(Français) "classique"; set endl(Français) "Fin"
set spl(Français) "Enregistrer"; set editl(Français) "Editeur"
set drl(Français) "Imprimante"; set umsch(Français) "Imprimer enveloppe"
set editll(Français) "Editer texte"; set spell(Français) "Correcteur d'orthographe"
set texl(Français) "Fichier LaTeX"; set vorl(Français) "Aperçu"
set serl(Français) "Publipostage";set edital(Français) "Editer adresses"
set serll(Français) "Publipostage avec tk-Brief"
set serl1(Français) "Editer d'abord les adresses. Format:"
set serl2(Français) "<A>;<nom>;<rue>;<code postal et ville>"
set editt(Français) "Editer texte";set really(Français) "Confirmer aperçu?"
set cancel(Français) "Annuler";set genl(Français) "Ajouter PostScript"
set really2(Français) "Confirmer impression?";set faxen(Français) "Envoyer Fax"
set aufl(Français) "Effacer"; set sigl(Français) "Signature"
set dirl(Français) "Répertoire"; set pak(Français) "extension"
set col(Français) "Palette de couleurs";set col2(Français) "Couleur du texte"
set new(Français) "Créer nouvel expéditeur"; set del(Français) "Effacer expéditeur"
set kein_abs(Français) "Expéditeur non défini\nVeuillez créer nouvel expéditeur"
set adress_edit(Français) "Adresse non définie\nVeuillez insérer adresse"
set copt(Français) "type document"; set sffam(Français) "police sans serif"
set mindestend(Français) "Au moins 1 expéditeur doit être défini"

set wmtl(Nederlands) "Fout tijdens compilatie"; set abs(Nederlands) "Bestand"
set wmt(Nederlands) "tk-Brief v. $version door Remko en Sander";
set adr(Nederlands) "Aan"; set namel(Nederlands) "Naam"
set str(Nederlands) "Straat"; set ORT(Nederlands) "Plaats"
set faxn(Nederlands) "Fax"; set postv(Nederlands) "P.S."
set vertl(Nederlands) "C.C."; set izl(Nederlands) "Uw kenmerk"
set mzl(Nederlands) "Mijn kenmerk"; set uzl(Nederlands) "Ons kenmerk"
set isl(Nederlands) "Uw brief van "; set betr(Nederlands) "Betreft"
set anr(Nederlands) "Aanroep"; set grl(Nederlands) "Afsluiting"
set anll(Nederlands) "Bijlagen"; set confl(Nederlands) "Configuratie"
set confll(Nederlands) "configuratie van tk-Brief"
set absl(Nederlands) "Afzender"; set titl(Nederlands) "Titel"
set zusl(Nederlands) "Toevoeging"; set fenl(Nederlands) "Venster"
set logo(Nederlands) "Logo"; set blzl(Nederlands) "Bank \#"
set konl(Nederlands) "Rekening \#"; set bankl(Nederlands) "Bank"
set trenl(Nederlands) "deellijnen"; set lochl(Nederlands) "gaatjesmarkering"
set fall(Nederlands) "vouwmarkering"; set fenll(Nederlands) "venstermarkering"
set klasl(Nederlands) "klassiek"; set endl(Nederlands) "Einde"
set spl(Nederlands) "Opslaan"; set editl(Nederlands) "Editen"    
set drl(Nederlands) "Afdrukken"; set umsch(Nederlands) "Omslag Afdrukken"
set editll(Nederlands) "Wijzig Tekst"; set spell(Nederlands) "Spelling Check"
set texl(Nederlands) "LaTeX-Bestand"; set vorl(Nederlands) "Voorbeeld"
set serl(Nederlands) "Multiple Let."; set edital(Nederlands) "Wijzig addresen"
set serll(Nederlands) "Multiple letters with tk-Brief"
set serl1(Nederlands) "Vul eerst het adres in. Formaat:"
set serl2(Nederlands) "<aan>;<naam>;<straat>;<postcode en plaats>"
set editt(Nederlands) "Wijzig tekst";set genl(Nederlands) "Genereer PostScript"
set really(Nederlands) "Werkelijk voorbeeld?";set cancel(Nederlands) "Afbreken"
set really2(Nederlands) "Werkelijk afdrukken?"; set aufl(Nederlands) "Opruimen"
set faxen(Nederlands) "Verstuur Fax"; set sigl(Nederlands) "Afsluiting"
set dirl(Nederlands) "Folder"; set pak(Nederlands) "pakket"
set col(Nederlands) "Achtergrondkleur"; set col2(Nederlands) "Tekstkleur"
set new(Nederlands) "Creëer nieuwe Afzender";
set del(Nederlands) "verwijder Afzender"
set kein_abs(Nederlands) "Geen afzender gedefinieerd\nCreëer nieuwe afzender"
set adress_edit(Nederlands) "Geen adres gedefinieerd\nVul adressen in"
set copt(Nederlands) "Klasse opties"; set sffam(Nederlands) "sans serif font"
set mindestend(Nederlands) "At least 1 sender has to be defined"
}
}

proc save_config {} {
  uplevel #0 {    
    read_checkbuttons
    set config_file [open $cfile "w"]
    foreach l [list titelliste namenliste zusatzliste adressenliste ortliste telephonliste telefaxliste bankliste blzliste kontoliste emailliste uni logoliste http logobreite fen_flaglist fax_flaglist email_flaglist url_flaglist bank_flaglist class_list trenn_list falt_list mark_list loch_list klass_list german_list sf_list fen_inhaltlist] {catch {unset $l}}
    if ($absender_anzahl==0) {
      puts $kein_abs(Deutsch)
      return
    }
    set CLASS($abs_nummer) $briefstyle
    for {set i 0} {$i < $absender_anzahl} {incr i} {
      set_list titelliste TITEL $i ; set_list namenliste A_NAME $i
      set_list zusatzliste A_ZUSATZ $i;set_list adressenliste A_ADRESSE $i
      set_list ortliste A_ORT $i; set_list telephonliste TELEPHON $i
      set_list telefaxliste TELEFAX $i; set_list emailliste EMAIL $i
      set_list bankliste BANK $i; set_list blzliste BLZ $i
      set_list kontoliste KONTO $i; set_list uni UNI $i
      set_list logoliste LOGO $i; set_list http HTTP $i
      set_list logobreite LOGOBREITE $i;  set_list fen_flaglist FEN $i
      set_list fen_inhaltlist FEN_INHALT $i
      set_list fax_flaglist TELEFAX_FLAG $i; set_list email_flaglist EMAIL_FLAG $i
      set_list url_flaglist HTTP_FLAG $i; set_list bank_flaglist BANK_FLAG $i
      set_list class_list CLASS $i; set_list trenn_list TRENN $i
      set_list falt_list FALT $i; set_list mark_list FENST $i
      set_list klass_list KLASS $i; set_list german_list GERMAN $i
      set_list sf_list SF $i; set_list loch_list LOCH $i
    }
    
    puts $config_file "version| $version"
    foreach f $all_feature_list {
      puts $config_file "${f}|  [set $f]"
    }
    close $config_file
    set of [open ${filename}.cfg "w"]
    foreach f $cfg_list {
      puts $of "${f}| [set $f]"
    }
    close $of
  }
}

proc LadeDatei Datei {
  global sprache; global wmtl; global fehler; global texl
  if { ![ winfo exists .zeige ] } {
    toplevel .zeige
    if [info exists fehler] {
      wm title .zeige  $wmtl($sprache)
    } else {
      wm title .zeige  $texl($sprache)
    }
    text .zeige.text -relief raised -bd 2 -yscrollcommand ".zeige.scroll set"
    scrollbar .zeige.scroll -command ".zeige.text yview"
    button .zeige.ok -text ok -command "destroy .zeige"
    pack .zeige.scroll -side right -fill y
    pack .zeige.text -side left
    pack .zeige.ok -side top -fill x
    .zeige.text delete 1.0 end
    set d [open $Datei]
    while {![eof $d]} {
      .zeige.text insert end [read $d 1000]
    }
    close $d
  }   else { raise .zeige }
}

proc touchfile {file} {
  if [file exists ${file}] {
    file atime ${file} [clock seconds]
  } else {
    set if [open  ${file} "w"]
    close $if
  }
}

proc get_anzahl {file} {
  set anzahl 0
  set if  [open ${file} "r"]
  while {[gets $if zeile ]>=0} {
    incr anzahl
  }
  close $if
  return $anzahl
}

proc get_adresses {} {
  uplevel #0 {
    if {![file exists ${filename}.adresses]} {
      puts $adress_edit($sprache)
      catch "exec $edit_command $filename.adresses"
    }
    set anzahl 0
    set id1 [open ${filename}.adresses "r"]
    set merker $Anrede(wert)
    while { [ gets $id1 zeile ] != -1 } {
      set list_in_zeile [split $zeile ";" ]
      if {[llength $list_in_zeile] != 0} {
	set serie_an($anzahl) [lindex $list_in_zeile 0]
	set serie_name($anzahl) [ lindex $list_in_zeile 1 ]
	set serie_adresse($anzahl) [ lindex $list_in_zeile 2 ]
	set serie_ort($anzahl) [ lindex $list_in_zeile 3 ]
	set ANREDE [lindex $list_in_zeile 4]
	if {[llength $list_in_zeile]=="5"} {
	  set serie_Anrede($anzahl) $ANREDE
	} else {
	  set serie_Anrede($anzahl) $merker
	}
      }
      incr anzahl
    }
  }
}

proc execute_seriencommand {} {
  uplevel #0 {
    for {set seriennummer 0} {$seriennummer<$anzahl} {incr seriennummer} {
      set an $serie_an($seriennummer)
      set name $serie_name($seriennummer)
      set adresse $serie_adresse($seriennummer)
      set ort $serie_ort($seriennummer)
      set Anrede(wert) $serie_Anrede($seriennummer)
      set faxnummer ""
      generate_texfile
      translate_latex $filename
      if {$executioncommand=="xdvi" } {
	exec $xdvi_command $filename 
      } else {
	set out_file "${filename}_${seriennummer}.ps"
	puts "generating $out_file"
	catch "exec -- $dvips_command $filename -o $out_file "
	if {$executioncommand=="print"} {
	  catch "exec $print_command $out_file"
	}
      }
    }
  }
}

proc get_cmdline {} {
  uplevel #0 {
    set cmdline 0
    while {$argc > 0} {
      switch -exact -- [lindex $argv 0] {
	-h  -
	-hilfe {
	  if {$sprache=="Deutsch"} {
	    puts "\n\n\n\n\n"
	    puts "tk-Brief Version $version von Ralf Müller\n\n"
	    puts "Aufruf: tk-brief \[-a AN\] \[-N NAME\] \[-str STRAßE\] \[-o ORT\] \[-dir VERZEICHNIS\] \[-fax FAXNUMMER\] \[FILENAME\]\n"
	  } elseif {$sprache=="English"} {
	    puts "\n\n\n\n\n"
	    puts "tk_Brief version $version by Ralf Müller\n"
	    puts "usage: tk-brief \[-a To\] \[-N NAME\] \[-str STREET\] \[-o CITY\] \[-dir DIRECTORY\] \[-fax FAXNUMBER\] \[FILENAME\]\n"
	  } elseif {$sprache=="Français"} {
            puts "\n\n\n\n\n"
            puts "tk_Brief version $version by Ralf Müller\n, translated by Karine Sparta"
            puts "usage: tk-brief \[-a A\] \[-N NOM\] \[-str RUE\] \[-o VILLE\] \[-dir REPERTOIRE\] \[-fax FAXNUMBER\]
+\[FILENAME\]\n"
          }elseif {$sprache=="Nederlands"} {
	    puts "\n\n\n\n\n"
	    puts "tk_Brief version $version by Ralf Müller, translated by Remko en Sander\n"
	    puts "usage: tk-brief \[-a To\] \[-N NAAM\] \[-str STRAAT\] \[-o PLAATS\] \[-dir FOLDER\] \[-fax FAXNUMNER\] \[BESTANDSNAAM\]\n"
	  }
	  exit
	}
	-a  -
	-an {
	  set an [lindex $argv 1];incr argc -1;set argv [lrange $argv 1 end]
	  set cmdline 1
	}
	-N {
	  set name [lindex $argv 1];incr argc -1;set argv [lrange $argv 1 end]
	  set cmdline 1
	}
	-str  -
	-strasse {
	  set adresse [lindex $argv 1];incr argc -1;set argv [lrange $argv 1 end]
	  set cmdline 1
	}
	-o  -
	-ort {
	  set ort [lindex $argv 1];incr argc -1;set argv [lrange $argv 1 end]
	  set cmdline 1
	}
	-dir {
	  set directory [lindex $argv 1];incr argc -1;
	  set argv [lrange $argv 1 end]
	}
	-fax {
	  set faxnummer [lindex $argv 1];incr argc -1
	  set argv [lrange $argv 1 end]
	  set cmdline 1
	}
	default {
	  set filename [lindex $argv 0]
	}
      }
      incr argc -1; set argv [lrange $argv 1 end]
    }
  }
}

proc enable_conf_entries {} {
  uplevel #0 {
    toggle_2 .conf.absender_email.e0 Email
    toggle_2 .conf.absender_http.e0 Http
    toggle_2 .conf.absender_f.e0 Telefax
    toggle_2 .conf.absender_fenster.e0 Fenster
    toggle_2 .conf.absender_bank.e0 Bank
    if {$Bank(do_it) == 0 } { 
      pack forget .conf.absender_BLZ
      pack forget .conf.absender_Konto
    } else {
      pack .conf.absender_BLZ -in .conf.left
      pack .conf.absender_Konto -in .conf.left
    }
  }
}

proc enable_entries {} {
  uplevel #0 {
    toggle .adresse_pv.e0 $Postvermerk(do_it)
    toggle .adresse_vert.e0 $Verteiler(do_it)
    toggle .adresse_iz.e0 $Iz(do_it)
    toggle .adresse_iz.e2 $Mein_Z(do_it)
    toggle .adresse_uz.e0 $Ihr_S(do_it)
    toggle .adresse_anlage.e0 $Anlagen(do_it)
  }
}

proc toggle_2 {eintrag variable} {
  global $variable
  if {[set ${variable}(do_it)] == 1} { 
    if {[$eintrag cget -width]!=0} {
      $eintrag configure -state normal; $eintrag configure -relief sunken
      $eintrag configure -fg black
    }
  } else {
    $eintrag configure -state disabled; $eintrag configure -relief flat
    $eintrag configure -fg gray
  }
}
proc toggle {eintrag flag} {
  if {$flag == 1} { 
    $eintrag configure -state normal; $eintrag configure -relief sunken
    $eintrag configure -fg black
  }
  if {$flag != 1} {
    $eintrag configure -state disabled; $eintrag configure -relief flat
    $eintrag configure -fg gray
  }
}

proc insert_command {pipe command inhalt} {
  if {$command != ""} {
    puts $pipe "${command}${inhalt}"
  } 
}

proc create_header {} {
  uplevel #0 {
    if {$sprache== "Deutsch"} {
      set classoptions "$size,german"
    } elseif {$sprache=="English"} {
      set classoptions "$size,english"
    }  elseif {$sprache=="Français"} {
      set classoptions "$size,french"
    } elseif {$sprache=="Nederlands"} {
      set classoptions "$size,dutch"
    }
    puts $out "\\documentclass\[$classoptions,${coptions}\]\{$class(1)\}"
    puts $out "\\usepackage\{babel\}"
    puts $out "\\usepackage\[utf8x\]\{inputenc\}"
    puts $out "\\usepackage\{graphicx\}"
#    puts $out "\\usepackage\{pslatex\}"
    if {$german == 1} {puts $out "\\usepackage\{german\}"}
    if {$Pak(do_it) ==1} {puts $out "\\usepackage\{$Pak(wert)\}"}

  }
}

proc generate_umschlag {} {
  uplevel #0 {
    set class(1) article; set size 12pt
    set out [open ${filename}_umschlag.tex "w"]
    create_header
    if {$sffamily} {
      set fontinsert "\\sffamily"
      set fontinsert2 "\\sf"
    } else {
      set fontinsert ""
      set fontinsert2 ""
    }
    puts $out "\\setlength\{\\parindent\}\{0cm\}"
    puts $out "\\setlength\{\\oddsidemargin\}\{-1cm\}"
    puts $out "\\setlength\{\\headsep\}\{-2cm\}"
    puts $out "\\setlength\{\\topskip\}\{-5cm\}\n"
    puts $out "\\begin\{document\}\n${fontinsert}"
    puts $out "\\begin\{tabular\}\{p\{10cm\}\l\}"
    puts $out "\\small Absender:&\\\\"
    puts $out "\\small $A_NAME($abs_nummer)&\\\\"
    puts $out "\\small $A_ADRESSE($abs_nummer)&\\\\"
    puts $out "\\small $A_ORT($abs_nummer)&\\\\\[2.5cm\]"
    puts $out "&\\large\\textbf\{${fontinsert2} $an\}\\\\\[1mm\]"
    puts $out "&\\large\\textbf\{${fontinsert2} $name\}\\\\\[1mm\]"
    puts $out "&\\large\\textbf\{${fontinsert2} $adresse\}\\\\\[1mm\]"
    if {$Postvermerk(do_it)==1} {puts $out "&\\large\\textbf\{${fontinsert2} $Postvermerk(wert)\}\\\\\[1mm\]"}
    puts $out "\\\\\[1mm\]"
    puts $out "&\\large\\textbf\{${fontinsert2} $ort\}"
    puts $out "\\end\{tabular\}"
    puts $out "\\thispagestyle\{empty\}"
    puts $out "\\end\{document\}"
    close $out
  }
}

proc generate_logo {} {
  uplevel #0 {
    if {$class(1)=="logo-brief"} {
      if {$LOGO($abs_nummer)!=""} {
	if {$LOGOBREITE($abs_nummer)==""} {
	  set LOGOBREITE($abs_nummer) "2cm"
	}
	puts $out "\\LOGO\{$LOGO($abs_nummer)\}\{$LOGOBREITE($abs_nummer)\}"
      }
    }
    if {($class(1)=="uni-brief")||($class(1)=="rwth-brief")} {
      puts $out "\\Logo\{$LOGO($abs_nummer)\}"
      puts $out "\\Logowidth\{$LOGOBREITE($abs_nummer)\}"
    }
    if {$class(1)=="g-brief"} {
      if {$LOGO($abs_nummer)!=""} {
	if {$LOGOBREITE($abs_nummer)==""} {
	  set LOGOBREITE($abs_nummer) "2cm"
	}
	puts $out "\\LOGO\{$LOGO($abs_nummer)\}\{$LOGOBREITE($abs_nummer)\}"
      }
    }
  }
}

proc generate_item {pipe Item} {
  upvar $Item $Item
  if (![info exists ${Item}(do_it)]) {set ${Item}(do_it) 1}
  if {([set ${Item}(wert)]!="")&&([set ${Item}(do_it)]==1)} {
    puts $pipe "[set ${Item}(command)]\{[set ${Item}(wert)]\}"
  }
}

proc set_list_value {feature list i} {
  upvar $feature $feature
  upvar $list $list
  if {([info exists $list])&&([llength [set $list]] > $i)} {
    set ${feature}($i) [lindex [set $list] $i]
  } else {
    if ![info exists $list] {
      set $list [get_default $list]
    }
    set ${feature}($i) [get_default $list]
  }
}

proc set_list {list feature i} {
  upvar $feature $feature
  upvar $list $list
  if ![info exists $feature] {
    
  }
  lappend $list [set ${feature}($i)]
}

proc get_absender_info {} {
  uplevel #0 {
    if ![info exists Blz] {
      set Blz(command) ""
      set Konto(command) ""
    }
    if {$sffamily} {set fontinsert2 "\\sf"} else {set fontinsert2 ""}
    set Fentser(do_it) $FEN($abs_nummer)
    set Fenster(wert) $FEN_INHALT($abs_nummer)
    set Telephon(wert) "${fontinsert2} $TELEPHON($abs_nummer)"
    set Telefax(do_it) $TELEFAX_FLAG($abs_nummer)
    set Telefax(wert) "${fontinsert2} $TELEFAX($abs_nummer)"
    set Email(do_it) $EMAIL_FLAG($abs_nummer)
    set Email(wert) "${fontinsert2} $EMAIL($abs_nummer)"
    set Http(do_it) $HTTP_FLAG($abs_nummer)
    set Http(wert) "${fontinsert2} $HTTP($abs_nummer)"
    set Bank(do_it) $BANK_FLAG($abs_nummer)
    set Bank(wert) "${fontinsert2} $BANK($abs_nummer)\}$Blz(command)\{$BLZ($abs_nummer)\}$Konto(command)\{$KONTO($abs_nummer)"
    if {$Unterschrift(leer)==1} {
      set Unterschrift(wert) $A_NAME($abs_nummer)
    } else {
      set Unterschrift(wert) " "
    }
    set trenn $TRENN($abs_nummer); set german $GERMAN($abs_nummer)
    set klass $KLASS($abs_nummer); set fenst $FENST($abs_nummer)
    set loch $LOCH($abs_nummer); set sffamily $SF($abs_nummer)
    set falt $FALT($abs_nummer); set Fenster(do_it) $FEN($abs_nummer) 
    set Fenster(wert) $FEN_INHALT($abs_nummer)
  }
}    

proc generate_gimmicks {} {
  uplevel #0 {
    if {$sffamily} {set fontinsert2 "\\sf"} else {set fontinsert2 ""}
    get_absender_info
    set Empfaenger(wert) "${fontinsert2} $an\\strut\\\\$name\\\\$adresse\\\\\\strut\\\\$ort\\\\$faxnummer"
    
    foreach i [list Telephon Telefax Email Http Bank Unterschrift Postvermerk Betreff Datum Mein_Z Anrede Empfaenger] {
      generate_item $out $i
    }
    
    if {$Iz(do_it) == 1} {
      set izinhalt "\{$Iz(wert)\}"
      if {($class(1)=="dinbrief")&&($Ihr_S(do_it)==1)} {
	set isinhalt "\{$Iz(wert), $Ihr_S(wert)\}"
      } else {
	if {$Ihr_S(do_it) == 1} {puts $out "$Ihr_S(command)\{$Ihr_S(wert)\}"}
      }
      insert_command $out $Iz(command) $izinhalt
    }
  }
}

proc gruss_vert_post {} {
  uplevel  #0 {
    if {($class(1)=="g-brief")||($class(1)=="uni-brief")||($class(1)=="logo-brief")||($class(1)=="rwth-brief")} {
      set Gruss(wert) "${gruss}\}\{1cm"
    } else {
      set Gruss(wert) $gruss
    }
    foreach i [list Gruss Anlagen Verteiler] {generate_item $out $i}
  }
}

proc extended_absender {} {
  uplevel #0 {
    set Absender(wert) "$TITEL($abs_nummer) $A_NAME($abs_nummer)"
    set Strasse(wert) $A_ADRESSE($abs_nummer)
    set Zusatz(wert) $A_ZUSATZ($abs_nummer)
    set Ort(wert) $A_ORT($abs_nummer)
    if {($UNI($abs_nummer)=="2")} {
      puts $out "\\renewcommand\{\\telefontex\}\{\}"
      puts $out "\\renewcommand\{\\datumtext\}\{\}"
      set Fenster(do_it) 1
      set Fenster(wert) " "
    }
    foreach i [list Absender Strasse Zusatz Ort] {generate_item $out $i}
  }
}

proc fenster_inhalt {} {
  uplevel #0 {
    if {$Fenster(do_it) == 0} {
      if {$sffamily} {set fontinsert2 "\\sf"} else {set fontinsert2 ""}
      set Fenster(wert) "${fontinsert2} $A_NAME($abs_nummer),$A_ADRESSE($abs_nummer),$A_ORT($abs_nummer)" 
    } 
    generate_item $out Fenster
  }
}

proc begin_document {} {
  uplevel #0 {
    if {$sffamily} {
      set fontinsert "\\sffamily"
    } else {
      set fontinsert ""
    }
    puts $out "\\begin\{document\}${fontinsert}"
  }
}

proc begin_class {} {
  uplevel #0 {
    puts $out "\\begin\{$class(2)\}$Begin(wert)"
  }
}

proc insert_text {} {
  uplevel #0 {
    if {![file exists $filename.text] } {
      set of [open $filename.text "w"]
      puts $of  "\\textbf{Maybe the letter should have some content too?}"
      close $of
    } 
    set if [open $filename.text "r"]
    fcopy $if $out
    puts $out ""
  }
}

proc end_it {} {
  uplevel #0 {
    puts $out "\\end\{$class(2)\}"
    puts $out "\\end\{document\}"
    close $out
  }
}

proc execute_generation_commands {} {
  uplevel #0 {
    puts $out "${flags}"
    if {($class(1)=="g-brief")||($class(1)=="uni-brief")||($class(1)=="logo-brief")||($class(1)=="rwth-brief")} {
      extended_absender
      generate_gimmicks      
      gruss_vert_post
      begin_document
      fenster_inhalt
      begin_class
    } elseif {(($class(1)=="dinbrief")||($class(1)=="letter")||($class(1)=="scrlettr"))} {
      generate_item $out Absender
      fenster_inhalt
      begin_document
      begin_class
      generate_gimmicks
    } elseif {($class(1)=="brief")} {
      get_absender_info
      begin_document
      fenster_inhalt
      foreach i [list Absender Datum  Telephon Telefax Email Unterschrift] {
	generate_item $out $i
      }
      begin_class
      foreach i [list Betreff Anrede] {
	generate_item $out $i
      }
    }
    insert_text
    if {(($class(1)=="dinbrief")||($class(1)=="letter")||($class(1)=="brief")||($class(1)=="scrlettr"))} gruss_vert_post
    end_it
  }
}

proc missing_feature {feature class} {
  global missing
  upvar $feature $feature
  if {[set ${feature}(do_it)]==1} {
    puts "don't know how to use $feature in $class. If you know this, please email solution to"
    puts "ralf@deres-mueller.de\n"
  }
  set ${feature}(do_it) 0
  set ${feature}(command) ""
  if {${feature}=="Bank"} {
    set Blz(command) ""
    set Konto(command) ""
  }
  set missing($feature) 1
}

proc create_dummy_command {command} {
  global $command
  set ${command}(command) ""
  set ${command}(do_it) 0
}

proc define_g-brief {} {
  uplevel #0 {
    set Empfaenger(do_it) 1
    set Absender(command) "\\Name";  set Strasse(command) "\\Strasse"
    set Zusatz(command) "\\Zusatz"; set Ort(command) "\\Ort"
    set Telephon(command) "\\Telefon"; set Telefax(command) "\\Telefax"
    set Email(command) "\\EMail"; set Http(command) "\\HTTP"
    set Bank(command) "\\Bank"; set Blz(command) "\\BLZ"
    set Konto(command) "\\Konto"; set Unterschrift(command) "\\Unterschrift"
    set Postvermerk(command) "\\Postvermerk";set Betreff(command) "\\Betreff"
    set Empfaenger(command) "\\Adresse";set Datum(command) "\\Datum"
    set Iz(command) "\\IhrZeichen"; set Ihr_S(command) "\\IhrSchreiben"
    set Mein_Z(command) "\\MeinZeichen"; set uzcommand "\\unserzeichen"
    set Anrede(command) "\\Anrede"; set Gruss(command) "\\Gruss"
    set Anlagen(command) "\\Anlagen"; set Verteiler(command) "\\Verteiler"
    set Absender(wert) "$TITEL($abs_nummer) $A_NAME($abs_nummer)"
    set Fenster(command) "\\RetourAdresse"
    set flags ""
    if {$fenst==1} {set flags "${flags}\n\\fenstermarken"}
    if {$trenn==1} {set flags "${flags}\n\\trennlinien"}
    if {$loch== 1} {set flags "${flags}\n\\lochermarke"}
    if {$falt== 1} {set flags "${flags}\n\\faltmarken"}
    if {$klass==1} {set flags "${flags}\n\\klassisch"}
    if {$uz==1} {set flags "${flags}\n\\unserzeichen"}
    if {$UNI($abs_nummer) == "1"} {
      set class(1) uni-brief; set class(2) uni-brief
    } elseif {$UNI($abs_nummer)=="3"} {
      set class(1) rwth-brief; set class(2) rwth-brief
    } else {
      set class(1) g-brief; set class(2) g-brief
    }
    if {$briefstyle=="logo-brief"} {
      set class(1) logo-brief; set class(2) g-brief
    }
    set Begin(wert) "\\vspace\{0.5cm\}"
  }
}

proc define_dinbrief {} {
  uplevel #0 {
    set class(1) dinbrief; set class(2) letter; create_header
    set flags ""
    if {$trenn == 1} {set flags "${flags}\n\\windowrules"} else {
      set flags "${flags}\n\\nowindowrules"
    }
    if {$falt == 1} {set flags "${flags}\n\\windowtics"} else {
      set flags "${flags}\n\\nowindowtics"
    }
    if {$klass == 1} {set flags "${flags}\n\\disabledraftstandard"} else {
      set flags "${flags}\n\\enabledraftstandard"
    }
    set Absender(command) "\\address"
    set Absender(wert) "$TITEL($abs_nummer) $A_NAME($abs_nummer)\\\\$A_ADRESSE($abs_nummer)\\\\$A_ZUSATZ($abs_nummer)\\strut\\\\$A_ORT($abs_nummer)"
    set Begin(wert) "{$an\\strut\\\\$name\\\\$adresse\\\\\\strut\\\\$ort}"
    set Ort(command) "\\place"; set Telephon(command) "\\phone\{\}"
    foreach f [list Telefax Email Http Bank] {
      missing_feature $f $class(1)
    }
    set Unterschrift(command) "\\signature";
    set Fenster(command) "\\backaddress"
    set Postvermerk(command) "\\postremark"
    set Betreff(command) "\\subject";set Datum(command) "\\date"
    foreach c [list Ihr_S Telefax Blz Konto] {create_dummy_command $c}
    if {$uz ==1} {missing_feature OUR_SIGN $class(1); set uz 0}
    set Iz(command) "\\yourmail";set Mein_Z(command) "\\sign"
    set Anrede(command) "\\opening";set Gruss(command) "\\closing"
    set Anlagen(command) "\\encl";set Verteiler(command) "\\cc"
  }
}

proc define_letter {} {
  uplevel #0 {
    set class(1) letter; set class(2) letter; create_header
    set Absender(command) "\\address"
    set Absender(wert) "$TITEL($abs_nummer) $A_NAME($abs_nummer)\\\\$A_ADRESSE($abs_nummer)\\\\$A_ZUSATZ($abs_nummer)\\strut\\\\$A_ORT($abs_nummer)"
    set flags ""
    set Begin(wert) "\{$an\\\\$name\\\\$adresse\\\\\\strut\\\\$ort\}"
    set Telephon(command) "\\telephone\{\}"
    foreach c [list Fenster Mein_Z Postvermerk Betreff Blz Konto subject] {
      create_dummy_command $c
    }
    foreach f [list Telefax Email Http Bank Iz] {
      missing_feature $f $class(1)
    }
    set Unterschrift(command) "\\signature"; set Datum(command) "\\date"
    set Betreff(command) "\\subject"; set iscommamd "\\ymail"
    set Iz(do_it) 0; set Mein_Z(do_it) 0
    set Anrede(command) "\\opening"; set Gruss(command) "\\closing"
    set Anlagen(command) "\\encl"; set Verteiler(command) "\\cc"
  }
}

proc define_brief {} {
  uplevel #0 {
    set class(1) brief; set class(2) brief;  create_header
    set Absender(command) "\\maakbriefhoofd"
    set Absender(wert) "$TITEL($abs_nummer) $A_NAME($abs_nummer)\}\{$A_ADRESSE($abs_nummer)\\\\$A_ZUSATZ($abs_nummer)\\\\$A_ORT($abs_nummer)"
    set Fenster(command) "\\antwoordadres"
    set flags ""
    set Datum(command) "\\datum"; set Ihr_S(command) "\\uwbriefvan"
    set Mein_Z(command) "\\onskenmerk"; set Iz(command) "\\uwkenmerk"
    set Telephon(command) "\\voetitem\{tel:\}"
    set Telefax(command) "\\voetitem\{fax:\}";set Email(command) "\\voetitem\{email:\}"
    set Begin(wert) "\{$an\\\\$name\\\\$adresse\\\\$ort\}"
    set Betreff(command) "\\betreft";set Anrede(command) "\\opening"
    set Gruss(command) "\\afsluiting";set beilagencommand "\\bijlagen"
    set Verteiler(command) "\cc"; set Unterschrift(command) "\\ondertekening"
    set uzcommand ""
    foreach f [list Http Bank Postvermerk] {
      missing_feature $f $class(1)
    }
    foreach c [list Anlagen Postvermerk Verteiler Blz Konto] {
      create_dummy_command $c
    }
  }
}

proc define_KOMA {} {
  uplevel #0 {
    set class(1) scrlettr; set class(2) letter;  create_header
    set flags ""
    if {$falt == 1} { set flags "${flags}\\foldmarkson"} else {
      set flags "${flags} \\foldmarksoff"
    }
    if {$klass == 1} {set flags "${flags}\\subjecton"} else {
      set flags "${flags}\\subjectoff"
    }
    set Absender(command) "\\name"
    set Absender(wert) "$TITEL($abs_nummer) $A_NAME($abs_nummer)\}\n\\address\{$A_ADRESSE($abs_nummer)\\\\$A_ZUSATZ($abs_nummer)\\strut\\\\$A_ORT($abs_nummer)"
    set Fenster(command) "\\backaddress"
    set Begin(wert) "\{$an\\\\$name\\\\$adresse\\\\\\strut\\\\$ort\}"
    set Telephon(command) "\\telephone";set Iz(command) "\\yourref"
    set Ihr_S(command) "\\yourmail";set mycommand "\myref"
    foreach f [list Telefax Email Http Bank] {
      missing_feature $f $class(1)
    }
    foreach c [list Mein_Z Postvermerk Blz Konto] {
      create_dummy_command $c
    }
    set Unterschrift(command) "\\signature";set Betreff(command) "\\subject"
    set Datum(command) "\\date";set Anrede(command) "\\opening"
    set Gruss(command) "\\closing";set Anlagen(command) "\\encl"
    set Verteiler(command) "\\cc"; set uzcommand ""
  } 
}

proc generate_texfile {} {
  uplevel #0 {
    file delete ${filename}.aux
    foreach feature [list FAX EMAIL URL BANK_ACCOUNT YOUR_MAIL OUR_SIGN] {
      set missing($feature) 0
    }
    set dir [file dirname $filename]; set filename [file tail $filename]
    if {$dir != ""} { cd $dir }
    set out [ open $filename.tex "w" ]
    set Empfaenger(do_it) 0
    if {$briefstyle == "logo-brief"} {
      define_g-brief;
      create_header; generate_logo
      if {$LOGO($abs_nummer) != ""} generate_logo
      execute_generation_commands      
    } elseif {$briefstyle == "g-brief"} {
      define_g-brief;
      if {$UNI($abs_nummer) == "1"} {
	create_header; generate_logo
	puts $out "\\Logoo\{Diffraktometer\}";puts $out "\\Logoowidth\{3cm\}"
	puts $out "\\uni\n\\Institut\{Institut f\\\"\{u\}r Kristallographie\}"
      } elseif {$UNI($abs_nummer)=="3"} {
	create_header; generate_logo
#	puts $out "\\Logoo\{Diffraktometer\}";puts $out "\\Logoowidth\{3cm\}"
	puts $out "\\uni\n\\Institut\{Institut f\\\"\{u\}r Kristallographie\}"	
       } else {
	create_header; generate_logo
      }
      if {$LOGO($abs_nummer) != ""} generate_logo
      execute_generation_commands
    } elseif {$briefstyle=="dinbrief"} {
      define_dinbrief
      execute_generation_commands
    } elseif {$briefstyle=="letter"} {
      define_letter
      execute_generation_commands
    } elseif {$briefstyle=="brief"} {
      define_brief
      execute_generation_commands
    } elseif {$briefstyle=="KOMA"} {
      define_KOMA
      execute_generation_commands
    }
  }
}

proc translate_latex {filename} {
  global latex_command
  set fehler [catch {exec $latex_command \\nonstopmode\\input\{$filename\} \
	>$filename.out}]
  if { $fehler == 1} {LadeDatei $filename.out}
}

proc translate_pdflatex {filename} {
  global pdf_command
  set fehler [catch {exec $pdf_command \\nonstopmode\\input\{$filename\} \
	>$filename.out}]
  if { $fehler == 1} {LadeDatei $filename.out}
}

proc translate_dvips {filename} {
  global dvips_command
  catch "exec $dvips_command $filename -o ${filename}.ps"
}
proc print_out {filename} {
  global print_command
  set fehler [catch "exec $print_command ${filename}.ps" fehlercode ]
  if { $fehler == 1} {bgerror $fehlercode}
}

if {![file exists $cfile]} {
  set of [open $cfile "w"]
  close $of
} 
set filename tk-brief
set config_file [open $cfile "r"]
read_config
get_cmdline
tk_setPalette $color; option add *foreground $color2
set_language
cd $directory

###############################################################
#            Widget Creation
###############################################################

proc create_new_absender {} {
  uplevel #0 {
    incr absender_anzahl; set neu "Neu ${absender_anzahl}"
    set abs_nummer [expr $absender_anzahl -1]
    set TITEL($abs_nummer) "";  set A_NAME($abs_nummer) $neu
    set A_ZUSATZ($abs_nummer) ""; set A_ADRESSE($abs_nummer) ""
    set A_ORT($abs_nummer)  ""; set TELEPHON($abs_nummer) ""
    set TELEFAX_FLAG($abs_nummer) 0; set TELEFAX($abs_nummer) ""
    set EMAIL_FLAG($abs_nummer) 0; set EMAIL($abs_nummer)  ""
    set FEN($abs_nummer) 0; set BANK_FLAG($abs_nummer) 0
    set FEN_INHALT($abs_nummer) ""
    set BANK($abs_nummer)  ""; set BLZ($abs_nummer)  ""
    set KONTO($abs_nummer) ""; set UNI($abs_nummer) 0
    set LOGO($abs_nummer) ""; set LOGOBREITE($abs_nummer) "1cm"
    set HTTP_FLAG($abs_nummer) 0; set HTTP($abs_nummer) ""
    set CLASS($abs_nummer) "g-brief"
    set FENST($abs_nummer) 1; set FALT($abs_nummer) 1
    set KLASS($abs_nummer) 0; set GERMAN($abs_nummer) 1
    set SF($abs_nummer) 1; set TRENN($abs_nummer) 1
    set LOCH($abs_nummer) 1;
    .conf.nummer.menu insert end radiobutton -label "Neu ${absender_anzahl}" \
	-variable absender_index
    lappend absender_liste $neu;
    set absender_index "Neu ${absender_anzahl}"
    reconfigure
  }
}

proc delete_absender {} {
  uplevel #0 {
    if {$absender_anzahl > 1} {
      incr absender_anzahl -1
      set d [lsearch $absender_liste $absender_index]
      .conf.nummer.menu delete $d
      foreach l [list TITEL A_NAME A_ZUSATZ A_ADRESSE A_ORT TELEPHON TELEFAX \
	  EMAIL BANK BLZ KONTO UNI LOGO HTTP LOGOBREITE TELEFAX_FLAG EMAIL_FLAG \
	  BANK_FLAG FEN HTTP_FLAG SF CLASS FALT FENST GERMAN KLASS TRENN LOCH \
	  FEN_INHALT] {
	for {set i [expr $d+1]} {$i <= $absender_anzahl} {incr i} {
	  set ${l}([expr $i-1]) [set ${l}($i)]
	}
	unset ${l}([expr $i-1])
      }
      set abs_nummer 0
      set absender_index $A_NAME(0)
      set absender_liste [lreplace $absender_liste $d $d]
      reconfigure
    } else {
      puts $mindestens($sprache)
    }
  }
}
proc labelentry {widget label lw ew variable} {
  frame $widget
  label $widget.label -text $label -width $lw
  entry $widget.e0 -text $variable -width $ew
  pack $widget.label $widget.e0 -side left -in $widget
}

proc checkentry {widget label ew variable} {
  frame $widget
  checkinsert $widget $label $ew ${variable}(do_it) ${variable}(wert) 0
}

proc checkentry2 {widget label ew cvariable evariable} {
  frame $widget
  checkinsert $widget $label $ew $cvariable $evariable 0
}

proc checkinsert {widget label ew cvariable evariable nr} {
  regsub \\(do_it\\) $cvariable "" tvariable
  checkbutton $widget.c${nr} -text $label -variable $cvariable -onvalue 1 \
      -offvalue 0 -command "toggle_2 $widget.e${nr} ${tvariable}" -justify left
  entry $widget.e${nr} -textvariable $evariable -width $ew 
  if {$ew == 0} {
    $widget.e${nr} configure -relief flat
  }
  pack $widget.c${nr} $widget.e${nr} -side left -in $widget
}

proc checkb {widget variable text} {
  checkbutton $widget -variable $variable -onvalue 1 -offvalue 0 -text $text -anchor w
}

wm title . $wmt($sprache)
frame .left -relief groove -borderwidth 10

frame .right 
frame .adresse_
labelentry .adresse_file $abs($sprache) 12 30  filename
bind .adresse_file.e0 <Return> {
  read_file_config
  enable_entries
}
labelentry .adresse_an $adr($sprache) 12 30 an
labelentry .adresse_n $namel($sprache) 12 30 name
labelentry .adresse_a $str($sprache) 12 30 adresse
labelentry .adresse_o $ORT($sprache) 12 30 ort
labelentry .adresse_fax $faxn($sprache) 12 30 faxnummer
checkentry .adresse_pv $postv($sprache) 25 Postvermerk
checkentry .adresse_vert $vertl($sprache) 27 Verteiler
checkentry .adresse_iz $izl($sprache) 2 Iz
checkinsert .adresse_iz $mzl($sprache) 2 Mein_Z(do_it) Mein_Z(wert) 2
checkinsert .adresse_iz $uzl($sprache) 0 dummy(do_it) dummy(wert) 3
checkentry .adresse_uz $isl($sprache) 10 Ihr_S
labelentry .adresse_bet $betr($sprache) 12 30 Betreff(wert)
labelentry .adresse_red $anr($sprache) 12 30 Anrede(wert)
labelentry .adresse_gru $grl($sprache) 12 30 gruss
checkentry .adresse_anlage $anll($sprache) 30 Anlagen

enable_entries

button .exit -text $endl($sprache) -command {
  save_config
  exit
}
button .config -text $confl($sprache) -command {
  if { ![ winfo exists .conf ] } {
    toplevel .conf
    wm title .conf $confll($sprache)
    frame .conf.left -relief sunken -borderwidth 4
    frame .conf.right -relief sunken -borderwidth 4
    pack .conf.left .conf.right -side left -padx 5 -pady 5 -fill y
    checkentry .conf.pak $pak($sprache) 10 Pak
    labelentry .conf.option $copt($sprache) 18 12 coptions
    label .conf.absender -text $absl($sprache)  -anchor w
    button .conf.new -text $new($sprache) -command create_new_absender
    eval tk_optionMenu .conf.nummer absender_index $absender_liste
    trace variable absender_index w reconfigure
    button .conf.del -text $del($sprache) -command delete_absender
    labelentry .conf.absender_t $titl($sprache) 10 20 TITEL($abs_nummer)
    labelentry .conf.absender_n $namel($sprache) 10 20 A_NAME($abs_nummer) 
    labelentry .conf.absender_a $str($sprache) 10 20 A_ADRESSE($abs_nummer) 
    labelentry .conf.absender_z $zusl($sprache) 10 20 A_ZUSATZ($abs_nummer)
    labelentry .conf.absender_o $ORT($sprache) 10 20 A_ORT($abs_nummer)
    checkentry .conf.absender_fenster $fenl($sprache) 20 Fenster
    labelentry .conf.absender_logo $logo($sprache) 10 20 LOGO($abs_nummer)      
    labelentry .conf.absender_tel "Tel." 10 20 TELEPHON($abs_nummer) 
    checkentry2 .conf.absender_f "Fax" 20 Telefax(do_it) TELEFAX($abs_nummer) 
    checkentry2 .conf.absender_email "E-Mail" 20  Email(do_it) EMAIL($abs_nummer)
    checkentry2 .conf.absender_http "URL" 20 Http(do_it) HTTP($abs_nummer)
    checkentry2 .conf.absender_bank $bankl($sprache) 20 Bank(do_it) BANK($abs_nummer)
    .conf.absender_bank.c0 configure -command enable_conf_entries
    labelentry .conf.absender_BLZ $blzl($sprache) 10 20  BLZ($abs_nummer)
    labelentry .conf.absender_Konto $konl($sprache) 10 20 KONTO($abs_nummer)
    
    frame .conf.size
    tk_optionMenu .conf.spell sprache "Deutsch" "English"  "Français"  "Nederlands"
    tk_optionMenu .conf.style briefstyle "g-brief" "dinbrief" "letter" "KOMA" "brief" "logo-brief"
    tk_optionMenu .conf.pdf latex_type "pdflatex" "latex" 
    radiobutton .conf.size.10 -variable size -value 10pt -text "10pt"
    radiobutton .conf.size.11 -variable size -value 11pt -text "11pt"
    radiobutton .conf.size.12 -variable size -value 12pt -text "12pt"
    button .conf.color -text $col($sprache) -command {
      set old_color $color
      set color [tk_chooseColor]
      if {$color == "" } {
	set color $old_color
      } 
      tk_setPalette $color
    }
    button .conf.color2 -text $col2($sprache) -command {
      set old_color $color2; set color2 [tk_chooseColor]
      if {$color2 == "" } {
	set color2 $old_color
      } else {
	set answer [tk_messageBox -type okcancel -message "tk_Brief has to be restarted to take effekt." ]
	if {$answer=="ok"} {
	  save_config
	  exit
	}
      }
    }
    checkb .conf.trenn trenn $trenl($sprache) 
    checkb .conf.loch loch $lochl($sprache)
    checkb .conf.falt falt $fall($sprache)
    checkb .conf.fenst fenst $fenll($sprache)
    checkb .conf.klass klass  $klasl($sprache)
    checkb .conf.germ german "german-Style" 
    checkb .conf.sffamily sffamily $sffam($sprache)

    button .conf.exit -text $endl($sprache) -command {
      update idletasks
      read_checkbuttons
      destroy .conf
    }
    button .conf.save -text $spl($sprache) -command {save_config}
    
    labelentry .conf.dir $dirl($sprache) 11 19 directory
    labelentry .conf.edit $editl($sprache) 11 19 edit_command
    labelentry .conf.printer $drl($sprache) 11 19 print_command
    labelentry .conf.pdflatex "PdfLatex" 11 19 pdf_command
    labelentry .conf.latex "LaTeX" 11 19 latex_command
    labelentry .conf.xdvi "preview-command" 11 19 xdvi_command
    labelentry .conf.dvips "dvips" 11 19 dvips_command
    labelentry .conf.ispell "ispell" 11 19 ispell_command
    labelentry .conf.faxcom "Fax" 11 19 fax_command
    
    pack  .conf.style .conf.size .conf.pak .conf.option .conf.new .conf.nummer .conf.del .conf.absender .conf.absender_t .conf.absender_n .conf.absender_a  .conf.absender_z .conf.absender_o .conf.absender_fenster .conf.absender_logo .conf.absender_tel .conf.absender_f .conf.absender_email .conf.absender_http .conf.absender_bank  -in .conf.left  -fill x 
    pack .conf.size.10 .conf.size.11 .conf.size.12 -side left -fill x
    pack .conf.spell .conf.pdf .conf.color .conf.color2 .conf.trenn .conf.falt .conf.loch \
	.conf.fenst .conf.klass .conf.germ .conf.sffamily .conf.exit .conf.save \
	.conf.dir .conf.edit .conf.printer .conf.latex .conf.pdflatex .conf.xdvi \
	.conf.ispell .conf.faxcom -in .conf.right  -fill x
    enable_conf_entries
  } else {raise .conf}
  set absender_index [lindex $absender_liste $abs_nummer]
}
button .edit_b -text $editll($sprache) -command {
  catch "exec $edit_command $filename.text &"
}

button .ispell -text $spell($sprache) -command {
  generate_texfile
  catch "exec $ispell_command $filename.text"
}

button .view -text $texl($sprache) -command {
  generate_texfile
  LadeDatei $filename.tex
}    

button .latex -text "LaTeX" -command {
  generate_texfile	
  if {$latex_type=="pdflatex"} {
    translate_latex $filename
  } else {
    translate_pdflatex $filename
  }
}

button .xdvi -text $vorl($sprache) -command {
  generate_texfile
  if {$latex_type=="pdflatex"} {
    translate_pdflatex $filename
    exec $acroread_command ${filename}.pdf
  } else {    
    translate_latex $filename
    exec $xdvi_command $filename &
  }
}

button .print -text $drl($sprache) -command {
  generate_texfile
  if {$latex_type=="pdflatex"} {
    translate_pdflatex $filename
    exec pdf2ps ${filename}.pdf ${filename}.ps
    print_out $filename
  } else {
    translate_latex $filename
    translate_dvips $filename
    print_out $filename
  }
}

button .umschlag -text $umsch($sprache) -command {
  generate_umschlag
  translate_latex ${filename}_umschlag
  translate_dvips ${filename}_umschlag
  print_out ${filename}_umschlag
  catch "file delete ${filename}_umschlag.ps"
}

button .do_it -text $serl($sprache) -command {
  if { ![ winfo exists .serie ] } {
    toplevel .serie  -relief ridge -borderwidth 10
    wm title .serie $serll($sprache)
    labelentry .serie.file $abs($sprache) 10 20  filename 
    label .serie.text -text $serl1($sprache)
    label .serie.text2 -text $serl2($sprache) 
    button .serie.exit -text $endl($sprache) -command { destroy .serie }
    button .serie.edit_ad -text $edital($sprache) -command {
      touchfile ${filename}.adresses
      catch "exec $edit_command $filename.adresses &"
    }
    button .serie.edit_b -text $editt($sprache) -command {
      catch "exec $edit_command $filename.text &"
    }
    button .serie.xdvi -text $vorl($sprache) -command {
      get_adresses
      if { [ winfo exists .error ] } { destroy .error}
      toplevel .error
      wm title .error $really($sprache)
      set mesl(Deutsch) "Es werden $anzahl Dateien dargestellt. OK?"
      set mesl(English) "$anzahl files will be previewed. OK?"
      set mesl(Français) "$anzahl fichiers seront aperçus. OK?"
      set mesl(Nederlands) "$anzahl bestanden voorbeeld bekijken. OK?"
      label .error.l -text $mesl($sprache)
      frame .error.b
      button .error.ok -text $vorl($sprache) -command {
	set executioncommand xdvi
	execute_seriencommand
	destroy .error
      }
      button .error.no -text $cancel($sprache) -command {
	destroy .error
      }
      pack .error.l .error.b
      pack .error.ok .error.no -fill x -side left -in .error.b
    }
    
    button .serie.ps -text $genl($sprache) -command {
      get_adresses
      set executioncommand gen_ps
      execute_seriencommand
    }
    
    button .serie.print -text $drl($sprache) -command {
      get_adresses
      if { [ winfo exists .error ] } { destroy .error}
      toplevel .error
      wm title .error $really2($sprache)
      set mesl2(Deutsch) "Es werden $anzahl Dateien gedruckt. OK?"
      set mesl2(English) "$anzahl files will be printed. OK?"
      set mesl2(Nederlands) "$anzahl bestanden zullen worden afgedrukt. OK?"
      label .error.l -text $mesl2($sprache)
      frame .error.b
      button .error.ok -text $drl($sprache) -command {
	set executioncommand print
	execute_seriencommand
	destroy .error
      }
      button .error.no -text $cancel($sprache) -command {
	destroy .error
      }
      pack .error.l .error.b
      pack .error.ok .error.no -fill x -side left -in .error.b
    }
    
    button .serie.clear -text $aufl($sprache) -command {
      get_adresses
      for {set nummer 0} {$nummer < $anzahl} {incr nummer} {
	lappend filelist ${filename}_${nummer}.ps
      }
      foreach file $filelist {
	file delete $file
      }
    }
    
    pack .serie.exit .serie.file .serie.text .serie.text2  .serie.edit_ad .serie.edit_b .serie.xdvi .serie.ps .serie.print .serie.clear -fill x 
  } else {raise .serie}
}
button .faxe -text $faxen($sprache) -command {
  generate_texfile
  translate_latex $filename
  translate_dvips $filename
  catch "exec gs -q -dNOPAUSE -sDEVICE=faxg3 -sOutputFile=$filename.g3 $filename.ps quit.ps"
  catch "exec $fax_command $faxnummer $filename.g3"
}

button .clear -text $aufl($sprache) -command {
  set filelist [list ${filename}.text~ ${filename}.text.bak ${filename}.ps \
      ${filename}.dvi ${filename}.log ${filename}.aux ${filename}.out \
      ${filename}.g3]
  foreach file $filelist {
    if [file exists $file] {
      file delete $file
    }
  }
}

checkb .unterschrift  Unterschrift(leer) $sigl($sprache)

pack .left -side left
pack .right -fill y -expand y
pack .adresse_ -in .left -padx 3 -pady 3
pack .adresse_red .adresse_gru .adresse_anlage -in .left -padx 3 -pady 3

pack .adresse_file .adresse_an .adresse_n .adresse_a .adresse_o .adresse_fax .adresse_pv .adresse_vert .adresse_iz .adresse_uz .adresse_bet -in .adresse_  -anchor w -fill x

pack .exit .config .edit_b .ispell .view .latex .xdvi .print .umschlag .do_it .faxe .clear .unterschrift -fill x -in .right  
if !($cmdline) read_file_config
enable_entries

proc reconfigure {args} {
  uplevel #0 {
#    puts "Debug Output an Ralf:"
#    puts $absender_liste
#    puts $absender_index
    set abs_nummer [lsearch $absender_liste $absender_index ]
    get_absender_info; enable_conf_entries
    set briefstyle $CLASS($abs_nummer)
    .conf.absender_t.e0 configure -textvariable TITEL($abs_nummer)
    .conf.absender_n.e0 configure -textvariable A_NAME($abs_nummer) 
    .conf.absender_a.e0 configure -textvariable A_ADRESSE($abs_nummer) 
    .conf.absender_z.e0 configure -textvariable A_ZUSATZ($abs_nummer)
    .conf.absender_o.e0 configure -textvariable A_ORT($abs_nummer)
    .conf.absender_tel.e0 configure -textvariable TELEPHON($abs_nummer) 
    .conf.absender_f.e0 configure -textvariable TELEFAX($abs_nummer) 
    .conf.absender_http.e0 configure -textvariable HTTP($abs_nummer) 
    .conf.absender_logo.e0 configure -textvariable LOGO($abs_nummer) 
    .conf.absender_email.e0 configure  -textvariable EMAIL($abs_nummer)
    .conf.absender_BLZ.e0 configure -textvariable BLZ($abs_nummer)
    .conf.absender_Konto.e0 configure  -textvariable KONTO($abs_nummer)
    .conf.absender_bank.e0 configure  -textvariable BANK($abs_nummer) 
    update idletasks
  }
}