[英]Gnuplot: break out of loop on keypressed
在 GnuPlot 5.2 腳本中,是否可以在按下(某些)鍵時跳出循環?
do for [m=1:6] {
do for [i=1:3] {
do for [fr=0:25] {
splot 'ex.plt' using 2:3:4 w l lt 1, sprintf("'exm%d.%d'",m,fr) using 1:2:3 w l lt 3
set view 69.867, 100.267, 2.503
pause 0.05
break # however: conditionally, on key pressed
}
}
}
# break to here
檢查help bind
。 也許,你正在尋找這樣的東西。 當按下x
時,循環將停止。
代碼:
### key bind
reset session
bind "x" "Stop = 1"
Stop = 0
do for [i=1:1000] {
plot sin(i/20.*x)
print i
pause 0.25
if (Stop) {Stop = i; break}
}
if (Stop) { print sprintf("Stopped after %d iterations", Stop) }
else { print "Time is over..." }
### end of code
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.