例如 incr 指令的使用, 變數需先建立才能為變數進行加法運算. 此時可使用 info exists 先確認此變數是否存在, 再續程式.
if { ![ info exists counter ] } {
set counter 0
} else {
incr counter
}
if { ![ info exists counter ] } {
set counter 0
} else {
incr counter
}
set appPath [ file normalize [ info script ] ]
if { [file type $appPath ] == "link" } {
set appPath [ file readlink $appPath ]
}
puts $appPath
set var_mac 001A6A00001F
set var_incr 000000000001
set var_mac2 [ format %X [ expr "0x$var_mac + 0x$var_incr" ] ]
puts $var_mac2
set mac_next "001A$var_mac2"
puts "Next MAC Address is $mac_next"
set num 3
switch $num {
" 1 " { puts "Monday" }
" 2 " { puts "Tuesday" }
" 3 " { puts "Wednesday" }
" 4 " { puts "Thursday" }
" 5 " { puts "Friday" }
" 6 " { puts "Saturday" }
" 7 " { puts "Sunday" }
" default " { puts "Wrong Value" }
}
file mkdir "directory_name"
file delete "directory_name"
file delete -force "directory_name"
file delete "file_name"
file copy source-filename target-filename
file copy -force source-filename target-filename
file rename source-filename target-filename
file exists filename
file isdirectory filename
file isfile filename
file size filename
file type filename
set a "M28SPLL1024X40R2011VTES35D121BSIRLQF"
set result [regexp -all -inline {[0-9]+} $a]
puts [concat [lrange $result 1 end-2] [lindex $result end]]
abstract | continue | for | new | switch |
assert*** | default | goto* | package | synchronized |
boolean | do | if | private | this |
break | double | implements | protected | throw |
byte | else | import | public | throws |
case | enum**** | instanceof | return | transient |
catch | extends | int | short | try |
char | final | interface | static | void |
class | finally | long | strictfp** | volatile |
const* | float | native | super | while |
Path1: rxtx-2.1-7-bins-r2/Windows/i368-mingw32/
- rxtxParallel.dll
- rxtxSerial.dll
Path2: rxtx-2.1-7-bins-r2/03- Copy there
- RXTXComm.jar
2 files rxtxParallel.dll & rxtxSerial.dll to [ C:\Program Files\Java\jdk1.7.0_45\jre\bin ]
1 file RXTXComm.jar to [ C:\Program Files\Java\jdk1.7.0_45\jre\lib\ext\ ]