Tcl/Tk Example
Learn more about Tcl/Tk with this basic example.
proc PlotCombo {fileName amount} {
set output ""
set counter 0
hwi GetSessionHandle ::PlotCombo::sess;
::PlotCombo::sess GetProjectHandle ::PlotCombo::proj;
::PlotCombo::sess GetDataFileHandle ::PlotCombo::data $fileName;
if {[string is double -strict $amount] == 0} {
puts "The inputted amount is not a valid number. Please input a valid number."
::PlotCombo::sess ReleaseHandle
::PlotCombo::proj ReleaseHandle
::PlotCombo::data ReleaseHandle
} else {
if {[::PlotCombo::data IsValid] == false} {
if {[::PlotCombo::data IsFilePresent] == false} {
puts "This file is not a real file. Please insert a real file."
::PlotCombo::sess ReleaseHandle
::PlotCombo::proj ReleaseHandle
::PlotCombo::data ReleaseHandle
} else {
puts "This file is the wrong file type for this function."
::PlotCombo::sess ReleaseHandle
::PlotCombo::proj ReleaseHandle
::PlotCombo::data ReleaseHandle
}
} else {
foreach value [::PlotCombo::data GetDataTypeList false] {
foreach request [::PlotCombo::data GetRequestList $value false] {
foreach component [::PlotCombo::data GetComponentList $value false] {
set pn [::PlotCombo::proj AddPage]
::PlotCombo::proj GetPageHandle ::PlotCombo::p1 $pn
::PlotCombo::p1 GetWindowHandle ::PlotCombo::w1 1
::PlotCombo::w1 SetClientType Plot
::PlotCombo::w1 GetClientHandle ::PlotCombo::plot
set cn [::PlotCombo::plot AddCurve]
::PlotCombo::plot GetCurveHandle ::PlotCombo::c1 $cn
::PlotCombo::c1 GetVectorHandle ::PlotCombo::xv x
::PlotCombo::xv SetType File
::PlotCombo::xv SetFilename $fileName
::PlotCombo::c1 GetVectorHandle ::PlotCombo::yv y
::PlotCombo::yv SetType File
::PlotCombo::yv SetFilename $fileName
::PlotCombo::yv SetDataType $value
::PlotCombo::yv SetRequest $request
::PlotCombo::yv SetComponent $component
::PlotCombo::plot Recalculate
::PlotCombo::plot Autoscale
::PlotCombo::plot Draw
::PlotCombo::c1 AddCursor
::PlotCombo::c1 GetCursorHandle ::PlotCombo::cur 1
::PlotCombo::cur FindGlobalMax y
set maxY [::PlotCombo::cur GetY]
::PlotCombo::cur FindGlobalMin y
set minY [::PlotCombo::cur GetY]
set diff [expr abs($maxY-$minY)]
set counter [expr $counter+1]
if {$diff > $amount} {
append output "page $counter: $diff \n"
}
::PlotCombo::p1 ReleaseHandle
::PlotCombo::w1 ReleaseHandle
::PlotCombo::plot ReleaseHandle
::PlotCombo::c1 ReleaseHandle
::PlotCombo::xv ReleaseHandle
::PlotCombo::yv ReleaseHandle
::PlotCombo::cur ReleaseHandle
}
}
}
::PlotCombo::proj CutPage 1 false
::PlotCombo::proj GetPageHandle ::PlotCombo::page [::PlotCombo::proj AddPage]
::PlotCombo::page GetWindowHandle ::PlotCombo::win 1
::PlotCombo::win SetClientType TextEditor
::PlotCombo::win GetClientHandle ::PlotCombo::txt
if {$output==""} {
::PlotCombo::txt SetRawText "Pages that have plots with a difference between their min and max points greater than $amount:\n
There are no plots with a difference greater than $amount."
} else {
::PlotCombo::txt SetRawText "Pages that have plots with a difference between their min and max points greater than $amount:\n
$output"
}
set numb [::PlotCombo::proj GetNumberOfPages]
::PlotCombo::proj SetActivePage $numb
::PlotCombo::sess ReleaseHandle
::PlotCombo::proj ReleaseHandle
::PlotCombo::data ReleaseHandle
::PlotCombo::page ReleaseHandle
::PlotCombo::txt ReleaseHandle
::PlotCombo::win ReleaseHandle
}
}
}