[scilab-Users] variables from TCL in Scilab

marcin.wozniczka Gazeta.pl marcin.wozniczka at gazeta.pl
Tue Mar 23 15:51:25 CET 2010


I have only *ans = T*
When I put name of scliab variable in Scilab Console after I ran this proces
I have only information
*xa*
*  !--error 4 *
*Undefined variable: xa*
*
*
I sent you my scilab function:
*function []=liczSL()*
*  global('wlxa','wlya','wlxb','wlyb','wla','wlb')*
*  xa=evstr(TCL_GetVar("wlxa"));*
*  ya=evstr(TCL_GetVar("wlya"));*
*  xb=evstr(TCL_GetVar("wlxb"));*
*  yb=evstr(TCL_GetVar("wlyb"));*
*  a=evstr(TCL_GetVar("wla"));*
*  b=evstr(TCL_GetVar("wlb"));*
*    c = sqrt( (xa-xb)*(xa-xb) + (ya-yb)*(ya-yb) );*
*    Ca = b*b+c*c-a*a;*
*    Cb = c*c+a*a-b*b; *
*    Cc = a*a+b*b-c*c; *
*    P = sqrt( Ca*Cb+Ca*Cc+Cb*Cc );*
*    at = Ca+Cb;*
*    xc = ( Cb*xa + Ca*xb + P*(ya-yb) )/at;*
*    yc = ( Cb*ya + Ca*yb + P*(xb-xa) )/at;*
*endfunction*
*
*
*
*
And this is my scilab program:
*wcl=['toplevel .wcl'*
*'wm title .wcl ""Wcięcie Liniowe""'*
*'wm geometry .wcl 370x270'*
*'wm minsize .wcl 370 270'*
*'wm maxsize .wcl 370 270'*
* *
*'frame .wcl.menubar -relief raised -bd 1'*
*'pack .wcl.menubar -fill x'*
*'menubutton .wcl.menubar.plik -text File -underline 0 -menu
.wcl.menubar.plik.menu'*
*'menubutton .wcl.menubar.edycja -text Edit -underline 0 -men
.wcl.menubar.edycja.menu'*
*'menubutton .wcl.menubar.licz -text Calc -underline 0 -menu
.wcl.menubar.licz.menu'*
*'menubutton .wcl.menubar.wyczysc -text Clean -underline 0 -menu
.wcl.menubar.wyczysc.menu'*
*'pack .wcl.menubar.plik .wcl.menubar.edycja .wcl.menubar.licz
.wcl.menubar.wyczysc -side left'*
*'menubutton .wcl.menubar.pomoc -text Help -underline 0 -menu
.wcl.menubar.plik.pomoc'*
*'pack .wcl.menubar.pomoc -side right'*
*
*
*'menu .wcl.menubar.plik.menu'*
*'.wcl.menubar.plik.menu add command -label Save -command ""SaveFile""'*
*'.wcl.menubar.plik.menu add command -label ""Save As..."" -command
""SaveAsFile""'*
*'.wcl.menubar.plik.menu add command -label Print -command ""Print""'*
*'.wcl.menubar.plik.menu add command -label Close -command {destroy .wcl}'*
*'menu .wcl.menubar.licz.menu'*
*'.wcl.menubar.licz.menu add command -label Calc -command {calcwl}'*
*'.wcl.menubar.licz.menu add command -label Calc1 -command {calcSL}'*
*
*
*'pack [label .wcl.dane] -pady 7'*
*'grid [label .wcl.dane.tpl1 -text ""Right Point""] -row 1 -column 0 -sticky
e'*
*'grid [label .wcl.dane.tpl2 -text ""Left Point""] -row 2 -column 0 -sticky
e'*
*'grid [label .wcl.dane.nrl -text ""Point"" -width 8] -column 1 -row 0
-sticky we -padx 2 -pady 1'*
*'grid [label .wcl.dane.tlx -text ""X"" -width 12] -column 2 -row 0 -sticky
we -padx 1 -pady 1'*
*'grid [label .wcl.dane.tly -text ""Y"" -width 12] -column 3 -row 0 -sticky
we -padx 1 -pady 1'*
*'grid [entry .wcl.dane.nrla -width 8 -justify right -textvariable nrla
-validate key -vcmd {expr {[string is double %P] && ![string match ""0*""
%P] && [string len %P] <=7}}] -row 1 -column 1 -pady 1 -padx 1'*
*'set ::nrla """"'*
*'grid [entry .wcl.dane.wlxa -width 12 -justify right -textvariable wlxa
-validate key -vcmd {expr {[string is double %P] && [string len %P] <= 11}}]
-row 1 -column 2 -pady 1 -padx 1'*
*'set ::wlxa """"'*
*'grid [entry .wcl.dane.wlya -width 12 -justify right -textvariable wlya
-validate key -vcmd {expr {[string is double %P] && [string len %P] <= 11}}]
-row 1 -column 3 -pady 1 -padx 1'*
*'set ::wlya """"'*
*'grid [entry .wcl.dane.nrlb -width 8 -justify right -textvariable nrlb
-validate key -vcmd {expr {[string is double %P] && ![string match ""0*""
%P] && [string len %P] <=7}}] -row 2 -column 1 -pady 1 -padx 1'*
*'set ::nrlb """"'*
*'grid [entry .wcl.dane.wlxb -width 12 -justify right -textvariable wlxb
-validate key -vcmd {expr {[string is double %P] && [string len %P] <= 11}}]
-row 2 -column 2 -pady 1 -padx 1'*
*'set ::wlxb """"'*
*'grid [entry .wcl.dane.wlyb -width 12 -justify right -textvariable wlyb
-validate key -vcmd {expr {[string is double %P] && [string len %P] <= 11}}]
-row 2 -column 3 -pady 1 -padx 1'*
*'set ::wlyb """"'*
*
*
*'grid [label .wcl.dane.bok] -row 3 -column 1 -columnspan 3 -pady 8'*
*'grid [label .wcl.dane.bok.ta -text ""Left arm ""] -column 0 -row 0 -sticky
e'*
*'grid [label .wcl.dane.bok.tb -text ""Right arm ""] -column 0 -row 1
-sticky e'*
*'grid [label .wcl.dane.bok.tm1 -text ""m""] -column 2 -row 0 -sticky w'*
*'grid [label .wcl.dane.bok.tm2 -text ""m""] -column 2 -row 1 -sticky w'*
*'grid [entry .wcl.dane.bok.wla -width 7 -justify right -textvariable wla
-validate key -vcmd {expr {[string is double %P] && ![string match ""0*""
%P] && [string len %P] <=7}}] -row 0 -column 1 -sticky we -pady 2'*
*'set ::wla """"'*
*'grid [entry .wcl.dane.bok.wlb -width 7 -justify right -textvariable wlb
-validate key -vcmd {expr {[string is double %P] && ![string match ""0*""
%P] && [string len %P] <=7}}] -row 1 -column 1 -sticky we -pady 2'*
*'set ::wlb """"'*
*'grid [label .wcl.dane.tplw -text ""Punkt wcinany""] -row 5 -column 0
-sticky e'*
*'grid [label .wcl.dane.nrp -text ""Nr"" -width 8] -column 1 -row 4 -padx 2
-pady 1'*
*'grid [label .wcl.dane.labxp -text ""X"" -width 12] -column 2 -row 4 -padx
1 -pady 1'*
*'grid [label .wcl.dane.labyp -text ""Y"" -width 12] -column 3 -row 4 -padx
1 -pady 1'*
*'grid [entry .wcl.dane.nrlp -width 8 -justify right -textvariable nrp
-validate key -vcmd {expr {[string is double %P] && ![string match ""0*""
%P] && [string len %P] <=7}}] -row 5 -column 1 -pady 1 -padx 1'*
*'set ::nrp """"'*
*'grid [entry .wcl.dane.wlxp -width 12 -justify right -state readonly
-textvariable wlxp] -row 5 -column 2 -pady 1'*
*'set ::wlxp """"'*
*'grid [entry .wcl.dane.wlyp -width 12 -justify right -state readonly
-textvariable wlyp] -row 5 -column 3 -pady 1'*
*'set ::wlyp """"'*
*
*
*'proc calcwl {} {'*
*  'if {[catch {'*
*    'set c [expr {double (sqrt((($::wlxa-$::wlxb)*($::wlxa-$::wlxb)) +
(($::wlya-$::wlyb)*($::wlya-$::wlyb))))}]'*
*    'set Ca [expr {double (($::wlb*$::wlb) + ($c*$c) - ($::wla*$::wla))}]'*
*    'set Cb [expr {double (($::wla*$::wla) + ($c*$c) - ($::wlb*$::wlb))}]'*
*    'set Cc [expr {double (($::wlb*$::wlb) + ($::wla*$::wla) - ($c*$c))}]'*
*    'set P [expr {double (sqrt($Ca*$Cb+$Ca*$Cc+$Cb*$Cc))}]'*
*    'set at [expr {double ($Ca+$Cb)}]'*
*    'set ::wlxp [format ""%0.2f"" [expr {double ((($Cb*$::wlxa +
$Ca*$::wlxb + $P*($::wlya-$::wlyb))/$at))}]]'*
*    'set ::wlyp [format ""%0.2f"" [expr {double ((($Cb*$::wlya +
$Ca*$::wlyb + $P*($::wlxb-$::wlxa))/$at))}]]'*
*  '}]!=0} {'*
*    'set ::wlxp ""Błąd""'*
*    'set ::wlyp ""Błąd""'*
*  '}'*
*'}'*
*  ** *
*'proc calcSL {} {'*
*'ScilabEval liczSL()' *
*'}'];*
*
*
*mputl(wcl,TMPDIR+'/wcl.tcl')*
*TCL_EvalFile(TMPDIR+'/wcl.tcl');*


proc Calc - counting everything in TCL
proc Calc1 -counting it using Scilab function

Marcin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20100323/b6a5fc85/attachment.htm>


More information about the users mailing list