Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Wed 01 Oct 2014, 10:30
All times are UTC - 4
 Forum index » House Training » Users ( For the regulars )
How do I run this tcl program?(solved)
Moderators: Flash, Ian, JohnMurga
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 1 of 1 Posts_count  
Author Message
chrisperry


Joined: 02 Sep 2005
Posts: 50
Location: Georgetown, Ky

PostPosted: Thu 22 Sep 2005, 22:43    Post_subject:  How do I run this tcl program?(solved)  

i copied a tcl program to mess around with,
the question is how do i make it run?
i can run other tcl aps just by clicking on them.
i am running 1.0.4

package require Tk
wm title . Calculator
grid [entry .e -textvar e -just right] -columnspan 5
bind .e <Return> =
set n 0
foreach row {
{7 8 9 + -}
{4 5 6 * /}
{1 2 3 ( )}
{C 0 . = }
} {
foreach key $row {
switch -- $key {
= {set cmd =}
C {set cmd {set clear 1; set e ""}}
default {set cmd "hit $key"}
}
lappend keys [button .[incr n] -text $key -command $cmd]
}
eval grid $keys -sticky we ;#-padx 1 -pady 1
set keys [list]
}
grid .$n -columnspan 2 ;# make last key (=) double wide
proc = {} {
regsub { =.+} $::e "" ::e ;# maybe clear previous result
if [catch {lappend ::e = [set ::res [expr 1.0*$::e]]}] {
.e config -fg red
}
.e xview end
set ::clear 1
}
proc hit {key} {
if $::clear {
set ::e ""
if ![regexp {[0-9().]} $key] {set ::e $::res}
.e config -fg black
.e icursor end
set ::clear 0
}
.e insert end $key
}
set clear 0
focus .e ;# allow keyboard input
wm resizable . 0 0
[Rob Hegt] - By adding the below 'fix' proc and changing the line doing the expr to the one given below, it is no longer necessary to add a . in case of a division.

proc fix {str} {
if {[string first "." "$str"] < 0} {
if {[string first "/" "$str"] > -1} {
set str "$str."
}
}
return "$str"
}
...

if [catch {lappend ::e = [set ::res [expr [fix $::e]]]}] {

Edited_time_total
Back to top
View user's profile Send_private_message 
Ian
Official Dog Handler


Joined: 04 May 2005
Posts: 1237
Location: Queensland

PostPosted: Thu 22 Sep 2005, 23:44    Post_subject:  

Open it in an editor like Beaver.

At the start of the script enter #!/usr/bin/wish and save the script.

That is Shift key + 3 (to give #) Shift key+1(to give the !) Hash Bang, then the path to 'wish' which will run the script.

Ensure that it is executable (you can do that in rox by right clicking on the program and selecting permissions and setting executable/readable to yes).
Back to top
View user's profile Send_private_message 
chrisperry


Joined: 02 Sep 2005
Posts: 50
Location: Georgetown, Ky

PostPosted: Fri 23 Sep 2005, 13:29    Post_subject: thank you  

thanks for your help
works great
chris
Back to top
View user's profile Send_private_message 
Display_posts:   Sort by:   
Page 1 of 1 Posts_count  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » House Training » Users ( For the regulars )
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0427s ][ Queries: 11 (0.0060s) ][ GZIP on ]