The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
ERROR: ./launch_full_backup.sh[18]: Syntax error at line 28 : `else' is not expected. villenan Shell Programming and Scripting 2 08-30-2009 06:36 AM
nim mksysb error :/usr/bin/savevg[33]: 1016,07: syntax error astjen AIX 9 10-03-2008 11:44 AM
why is this code generating syntax error?pls help wrapster Shell Programming and Scripting 3 05-21-2008 02:01 PM
awk Shell Script error : "Syntax Error : `Split' unexpected Herry UNIX for Dummies Questions & Answers 2 03-17-2008 11:16 AM
Need explanation for the syntax(code) chandhar Shell Programming and Scripting 1 03-21-2007 04:59 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 09-30-2009
milindb milindb is offline
Registered User
  
 

Join Date: Jul 2009
Posts: 19
Question Syntax error in tcl/tk code

Hi All,
I have written a code in tcl which is supposed to open an GUI in which numbers will be entered & after performing selected operation it wil show a result.

Code:
 
#!/usr/local/bin/wish
#package require Tk
#global opr 
proc DoOperation {} {
global opr
set fstno [ .entno1 get]
set scdno [ .entno2 get]
set result [expr {$fstno  $opr  $scdno}] 
.entres insert 0 $result
}
proc AddOpr {} {
set opr +
}
proc SubOpr {} {
set opr -
}
proc MulOpr {} {
set opr *
}
proc DivOpr {} {
set opr /
}
 
###Creation on widgets
wm title . "Wants to create Calculator"
frame .frm
label .labno1 -text "Enter First Number Here: "
label .labno2 -text "Enter Second number Here: "
label .labres -text "Result is : "
entry .entno1
entry .entno2
entry .entres
button .butadd -text "+" -width 4 -command "AddOpr"
button .butneg -text "-" -width 4 -command "SubOpr"
button .butmul -text "*" -width 4 -command "MulOpr"
button .butdiv -text "/" -width 4 -command "DivOpr"
button .butcalc -text "CALCULATE" -command "DoOperation" 
button .butext -text "EXIT" -command {exit}
###setting widgets 
#grid .but1 
grid .labno1 -in .frm -row 1 -column 1 -sticky w 
grid .labno2 -in .frm -row 2 -column 1 -sticky w
grid .labres -in .frm -row 3 -column 1 -sticky w
grid .entno1 -in .frm -row 1 -column 2 -sticky e
grid .entno2 -in .frm -row 2 -column 2 -sticky e
grid .entres -in .frm -row 3 -column 2 -sticky e
grid .butadd -in .frm -row 4 -column 1 -padx "0 65" -pady "5 5" 
grid .butneg -in .frm -row 4 -column 1 -padx "65 0" -pady "5 5" ;# -columnspan 2
grid .butmul -in .frm -row 4 -column 2 -padx "0 65" -pady "5 5";# -columnspan 2
grid .butdiv -in .frm -row 4 -column 2 -padx "65 0" -pady  "5 5"
grid .butcalc -in .frm -row 5 -column 1 -columnspan 1 -pady  "5 5"
grid .butext -in .frm -row 5 -column 2 -columnspan 2 -pady  "5 5"
pack .frm
Error I am getting is-
Code:
 
syntax error in expression "$fstno  $opr  $scdno": extra tokens at end of expression
syntax error in expression "$fstno  $opr  $scdno": extra tokens at end of expression
    while executing
"expr {$fstno  $opr  $scdno}"
    (procedure "DoOperation" line 5)
This is the first program I have created after completing my basic training of TCL/Tk so pls forgive me for silly mistakes.

Help appreciated in resolving this error.
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:55 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0