2
幾個問題:爲變量賦值給一個函數
我可以指定一個變量(regvalue)的函數(read_phy),如下的TCL?
$regvalue = read_phy $phy 19
我在Perl程序中有以下行。我試圖找出應該是TCL相當於:
while((read_phy($phy, 18) >> 15) ne 0) { usleep(10000); };
read_phy
(TCL函數)看起來是這樣的:
proc read_phy {phy register} {
$value = exec ./read_phy.pl $phy $register
string trim $value;
if { $::DEBUG } {
puts [format "Read PHY %s register %s = 0x%0.8X" $phy $register $value]
}
if { $::DEBUG } {
puts [format "Read PHY %s register %s = 0x%0.8X" $phy $register $value]
}
set hex $value
return ($value);
}
read_phy看起來像什麼(源代碼)?你已經嘗試了什麼? – octopusgrabbus
read_phy(tcl函數)如下所示:proc read_phy {phy register} { \t $ value = exec ./read_phy.pl $ phy $ register \t string trim $ value; 如果{$ :: DEBUG} { 看跌期權[格式 「讀取PHY%S寄存器%S = 0X%0.8X」 $ $ PHY寄存器$值] } 如果{$ :: DEBUG} { 看跌期權[格式「讀PHY%寄存器%s = 0x%0.8X」$ phy $ register $ value] } set hex $ value \t return($ value); } – user3565150
這聽起來像是在問函數式編程問題,函數arities。如果沒有,那麼我不理解你的問題。 – octopusgrabbus