Go to the source code of this file.
Modules | |
module | import::math::bigfloat |
Functions/Subroutines | |
ret | addButtonTwo (type commande) |
ret | addButtonOne (type commande) |
ret | drawButtons () |
ret | initStack () |
ret | Push () |
ret | toStr (type n) |
ret | drawStack (type args) |
ret | init () |
ret | _save () |
ret | ShowFile (type filename, type buttonText) |
ret | _help (type args) |
ret | _del () |
ret | _swap () |
ret | _dup () |
ret | pop (type varname) |
ret | push (type x) |
ret | _exit () |
ret _del | ( | ) |
Definition at line 251 of file bigfloat.demo.tcl.
ret _dup | ( | ) |
Definition at line 266 of file bigfloat.demo.tcl.
ret _exit | ( | ) |
Definition at line 287 of file bigfloat.demo.tcl.
ret _help | ( | type | args | ) |
Definition at line 246 of file bigfloat.demo.tcl.
ret _save | ( | ) |
Definition at line 207 of file bigfloat.demo.tcl.
00210 { 00211 set fichier [tk_getSaveFile -filetypes {{{Text Files} {.txt}}} -title "Save the stack as ..."] 00212 if {$fichier == ""} { 00213 error "You should give a name to the file. Aborting saving operation. Sorry." 00214 } 00215 if {[lindex [split $fichier .] end]!="txt"} { 00216 append fichier .txt 00217 } 00218 if {[catch {set file [open $fichier w]}]} { 00219 error "Write impossible on file : '$fichier'" 00220 } 00221 foreach valeur $::stack { 00222 puts $file [::math::bigfloat::tostr $valeur]
ret _swap | ( | ) |
Definition at line 259 of file bigfloat.demo.tcl.
ret addButtonOne | ( | type | commande | ) |
Definition at line 70 of file bigfloat.demo.tcl.
References pop().
00073 { 00074 addButton $commande 00075 proc _$commande {} "if {\[catch {pop a} msg\]} {tk_messageBox -message \$msg;return} 00076 if {\[catch {set result \[$commande \$a\]} msg\]} {push \$a 00077 tk_messageBox -message \$msg
ret addButtonTwo | ( | type | commande | ) |
Definition at line 56 of file bigfloat.demo.tcl.
00059 { 00060 addButton $commande 00061 proc _$commande {} "if {\[catch {pop a} msg\]} {tk_messageBox -message \$msg;return} 00062 if {\[catch {pop b} msg\]} {push \$a 00063 tk_messageBox -message \$msg;return} 00064 if {\[catch {set result \[$commande \$a \$b\]} msg\]} { 00065 push \$b 00066 push \$a 00067 tk_messageBox -message \$msg
ret drawButtons | ( | ) |
Definition at line 80 of file bigfloat.demo.tcl.
00083 { 00084 global nbButtons 00085 set nbLines [expr {int(sqrt($nbButtons))}] 00086 for {set i 0} {$i<$nbButtons} {incr i} { 00087 set col [expr {$i%$nbLines}] 00088 set line [expr {$i/$nbLines}] 00089 set commande $::buttons($i,command) 00090 set texte $::buttons($i,texte) 00091 button .functions.$commande -text $texte -command $commande -width 10 00092 grid .functions.$commande -column $col -row $line -in .functions
ret drawStack | ( | type | args | ) |
Definition at line 126 of file bigfloat.demo.tcl.
ret init | ( | ) |
Definition at line 137 of file bigfloat.demo.tcl.
00140 { 00141 wm title . "BigFloatDemo 1.2" 00142 # the stack (for RPN) 00143 frame .stack 00144 pack .stack 00145 initStack 00146 # the commands for input 00147 set c [frame .commands] 00148 pack $c -padx 10 -pady 10 00149 set ::bignum 1.00 00150 entry $c.bignum -textvariable ::bignum -width 16 00151 pack $c.bignum -in $c -side left 00152 label $c.labelZero -text "append zeros" 00153 pack $c.labelZero -in $c -side left 00154 set ::zeros 0 00155 entry $c.zeros -textvariable ::zeros -width 4 00156 pack $c.zeros -in $c -side left 00157 button $c.fenter -text "Push" -command Push 00158 pack $c.fenter -in $c -side left 00159 # the functions for numbers 00160 frame .functions 00161 pack .functions 00162 set f .functions 00163 # chaque fonction est associée, d'une part, 00164 # à un bouton portant un libellé, et d'autre part 00165 # à une commande Tcl 00166 # ici nous associons le bouton "add" à la commande "add" 00167 addButtonTwo add 00168 # toutes ces commandes se trouvent à la fin de ce fichier 00169 addButtonTwo sub 00170 addButtonTwo mul 00171 addButtonTwo div 00172 addButtonTwo mod 00173 addButtonOne opp 00174 addButtonOne abs 00175 addButtonOne round 00176 addButtonOne ceil 00177 addButtonOne floor 00178 addButtonTwo pow 00179 addButtonOne sqrt 00180 addButtonOne log 00181 addButtonOne exp 00182 addButtonOne cos 00183 addButtonOne sin 00184 addButtonOne tan 00185 addButtonOne acos 00186 addButtonOne asin 00187 addButtonOne atan 00188 addButtonOne cotan 00189 addButtonOne cosh 00190 addButtonOne sinh 00191 addButtonOne tanh 00192 addButtonOne pi 00193 addButtonOne rad2deg 00194 addButtonOne deg2rad 00195 addButtonOne int2float 00196 addButton del 00197 addButton swap 00198 addButton dup 00199 addButton help 00200 addButton save 00201 addButton exit
ret initStack | ( | ) |
Definition at line 94 of file bigfloat.demo.tcl.
ret pop | ( | type | varname | ) |
Definition at line 272 of file bigfloat.demo.tcl.
Referenced by addButtonOne().
00275 { 00276 if {[llength $::stack]==0} { 00277 error "too few arguments in the stack" 00278 } 00279 upvar $varname out 00280 set out [lindex $::stack end]
ret push | ( | type | x | ) |
Definition at line 283 of file bigfloat.demo.tcl.
ret Push | ( | ) |
Definition at line 104 of file bigfloat.demo.tcl.
ret ShowFile | ( | type | filename, | |
type | buttonText | |||
) |
Definition at line 224 of file bigfloat.demo.tcl.
00227 { 00228 if {[catch {toplevel .help}]} { 00229 tk_messageBox -message "Unable to create the window ; please close the current help window" 00230 return 00231 } 00232 frame .help.licence 00233 text .help.licence.t -yscrollcommand {.help.licence.s set} 00234 scrollbar .help.licence.s -command {.help.licence.t yview} 00235 grid .help.licence.t .help.licence.s -sticky nsew 00236 grid columnconfigure .help.licence 0 -weight 1 00237 grid rowconfigure .help.licence 0 -weight 1 00238 00239 pack .help.licence -in .help 00240 set fd [open $filename] 00241 .help.licence.t insert 0.0 [read $fd] 00242 close $fd 00243 .help.licence.t configure -state disabled 00244 button .help.bouton -text $buttonText -command {destroy .help;raise .}
ret toStr | ( | type | n | ) |
Definition at line 115 of file bigfloat.demo.tcl.