Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat's stored in that Tcl variable?
    text
    copied!<p>Pursuant to the advice given in <a href="https://stackoverflow.com/questions/385156/how-do-i-retrofit-a-gui-to-an-existing-c-program">this question</a> I have written a little gui to take the options for a command line C program and pass them on to said C program which is already set up to process them. It displays just like I wanted.</p> <p>However, I would like to verify that the values stored in the variables are correct. <strong>Getting the values to print out is giving me a lot of grief</strong> (I can't test <em>in vivo</em> right now due to some hardware issues). What am I missing?</p> <ol> <li>Prepending the variable name with '$' gives me '$variableName' rather than the <em>value</em> of the variable. </li> <li>Adding these variables to an array and calling <code>array get arr</code> is supposed to print the index and the array value; I get variable names.</li> <li>I tried <em>pathName</em> <code>cget</code> <em>option</em>, but apparently <code>-value</code> isn't an option, and leaving off the option doesn't give me a list of valid options. </li> </ol> <p>Here's all the code with the various things that didn't work (from option #1, which is the most straightforward way; the others were just me trying workarounds). They all produce errors along the lines of: "can't read "::": no such variable" or "can't read "colorimetric": no such variable".</p> <pre><code>#!/opt/ActiveTcl-8.5/bin/wish8.5 wm title . "Gretag" ttk::frame .f -borderwidth 5 -relief sunken -padding "5 10" # next line part of the "puts" tests at the bottom global colorimetric ttk::label .f.dataLabel -text "Data Type" ttk::label .f.colorimetricLabel -text "Colorimetric" ttk::checkbutton .f.colorimetric -onvalue "-c" -offvalue "" -command getFilename1 ttk::label .f.spectralLabel -text "Spectral" ttk::checkbutton .f.spectral -onvalue "-s" -offvalue "" -command getFilename2 ttk::label .f.gretagNumLabel -text "Gretag #" ttk::label .f.gretagLabel0 -text "1" ttk::radiobutton .f.gretagRadio0 -variable gretagNum -value "/dev/ttyS0" ttk::label .f.gretagLabel1 -text "2" ttk::radiobutton .f.gretagRadio1 -variable gretagNum -value "/dev/ttyS1" ttk::label .f.gretagLabel2 -text "3" ttk::radiobutton .f.gretagRadio2 -variable gretagNum -value "/dev/ttyS2" ttk::label .f.gretagLabel3 -text "4" ttk::radiobutton .f.gretagRadio3 -variable gretagNum -value "/dev/ttyS3" ttk::label .f.gretagLabel4 -text "5" ttk::radiobutton .f.gretagRadio4 -variable gretagNum -value "/dev/ttyS4" ttk::label .f.sampleSize -text "Sample Size" ttk::label .f.samplex -text "X" ttk::label .f.sampley -text "Y" ttk::entry .f.x -textvariable x -width 5 ttk::entry .f.y -textvariable y -width 5 ttk::label .f.filterLabel -text "Filter Type" ttk::label .f.filterLabel0 -text "D50" ttk::radiobutton .f.filterRadio0 -variable filter -value "-d50" ttk::label .f.filterLabel1 -text "D65" ttk::radiobutton .f.filterRadio1 -variable filter -value "-d65" ttk::label .f.filterLabel2 -text "Unfiltered" ttk::radiobutton .f.filterRadio2 -variable filter -value "-U" ttk::label .f.filterLabel3 -text "Polarized" ttk::radiobutton .f.filterRadio3 -variable filter -value "-p" ttk::label .f.baudLabel -text "Baud Rate" ttk::label .f.baudLabel0 -text "4800" ttk::radiobutton .f.baudRadio0 -variable baud -value "B4800" ttk::label .f.baudLabel1 -text "9600" ttk::radiobutton .f.baudRadio1 -variable baud -value "B9600" ttk::label .f.baudLabel2 -text "19200" ttk::radiobutton .f.baudRadio2 -variable baud -value "B19200" ttk::label .f.baudLabel3 -text "38400" ttk::radiobutton .f.baudRadio3 -variable baud -value "B38400" ttk::label .f.baudLabel4 -text "57600" ttk::radiobutton .f.baudRadio4 -variable baud -value "B57600" ttk::button .f.submitBtn -text "Submit" -command finish grid columnconfigure . 0 -weight 1 grid rowconfigure . 0 -weight 1 grid .f -column 0 -row 0 -columnspan 11 -rowspan 5 grid .f.dataLabel -column 0 -row 0 -sticky we grid .f.colorimetricLabel -column 1 -row 0 -sticky e grid .f.colorimetric -column 2 -row 0 -sticky w grid .f.spectralLabel -column 3 -row 0 -sticky e grid .f.spectral -column 4 -row 0 -sticky w grid .f.gretagNumLabel -column 0 -row 1 -sticky we grid .f.gretagLabel0 -column 1 -row 1 -sticky e grid .f.gretagRadio0 -column 2 -row 1 -sticky w grid .f.gretagLabel1 -column 3 -row 1 -sticky e grid .f.gretagRadio1 -column 4 -row 1 -sticky w grid .f.gretagLabel2 -column 5 -row 1 -sticky e grid .f.gretagRadio2 -column 6 -row 1 -sticky w grid .f.gretagLabel3 -column 7 -row 1 -sticky e grid .f.gretagRadio3 -column 8 -row 1 -sticky w grid .f.gretagLabel4 -column 9 -row 1 -sticky e grid .f.gretagRadio4 -column 10 -row 1 -sticky w grid .f.sampleSize -column 0 -row 2 -sticky we grid .f.samplex -column 1 -row 2 -sticky e grid .f.x -column 2 -row 2 -sticky w grid .f.sampley -column 3 -row 2 -sticky e grid .f.y -column 4 -row 2 -sticky w grid .f.filterLabel -column 0 -row 3 -sticky we grid .f.filterLabel0 -column 1 -row 3 -sticky e grid .f.filterRadio0 -column 2 -row 3 -sticky w grid .f.filterLabel1 -column 3 -row 3 -sticky e grid .f.filterRadio1 -column 4 -row 3 -sticky w grid .f.filterLabel2 -column 5 -row 3 -sticky e grid .f.filterRadio2 -column 6 -row 3 -sticky w grid .f.filterLabel3 -column 7 -row 3 -sticky e grid .f.filterRadio3 -column 8 -row 3 -sticky w grid .f.baudLabel -column 0 -row 4 -sticky we grid .f.baudLabel0 -column 1 -row 4 -sticky e grid .f.baudRadio0 -column 2 -row 4 -sticky w grid .f.baudLabel1 -column 3 -row 4 -sticky e grid .f.baudRadio1 -column 4 -row 4 -sticky w grid .f.baudLabel2 -column 5 -row 4 -sticky e grid .f.baudRadio2 -column 6 -row 4 -sticky w grid .f.baudLabel3 -column 7 -row 4 -sticky e grid .f.baudRadio3 -column 8 -row 4 -sticky w grid .f.baudLabel4 -column 9 -row 4 -sticky e grid .f.baudRadio4 -column 10 -row 4 -sticky w grid .f.submitBtn -column 1 -row 5 -columnspan 7 -sticky we foreach w [winfo children .f] {grid configure $w -padx 5 -pady 5} focus .f.colorimetric .f.colorimetric state selected .f.filterRadio1 state selected .f.baudRadio1 state selected bind . &lt;Return&gt; {finish} proc getFilename1 {} { set filename1 [tk_getSaveFile] } proc getFilename2 {} { set filename2 [tk_getSaveFile] } proc finish {} { .f.x insert 0 "-x" .f.y insert 0 "-y" # Pick one # puts $colorimetric # puts colorimetric # puts "$colorimetric" # puts $::colorimetric # puts .f.colorimetric # puts $.f.colorimetric # puts $::.f.colorimetric # puts "$::colorimetric" exec ./gretag .f.colorimetric filename1 .f.spectral filename2 .f.gretagNum .f.x .f.y .f.filter .f.baud } </code></pre> <hr> <p><strong>Edit:</strong> I've posted all the code rather than just part, and in the next to last line are the various syntaxes from option #1 that I've tried in order to view the values of the variables before they're passed to the next program. None of these are working and I don't understand why or how to fix it. I'm hoping another set of eyes will catch what's wrong.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload