问个极其简单又复杂的问题,我头都绕晕了,关于变量名中是否能代入变量?
我有一个循环:While $n <18
$dq=IniRead("zck.ini","zck","x"&$n,"")
Select
case $n=1
$dx1=$dq
case $n=2
$dx2=$dq
#cs
........
#ce
EndSelect
$n=$n+1
WEnd
我的问题是:如果While $n <18的循环数很大的情况下,那不是select命令中的case行也很多?能不能简单到把我需要赋值的DX1-----DX17这些变量中的1----17用变量$n来代入?意思就是变量名中是否能代入变量???
修改后的代码为(读取预置的三组数据,每组共17个):
Func dqyz();读取预置
dim $dx
dim $dy
dim $s
dim $dqn = 1
While $dqn < 18
$dx[$dqn] = IniRead("zck.ini", "zck", "dx" & $dqn, "")
$dy[$dqn] = IniRead("zck.ini", "zck", "dy" & $dqn, "")
$s[$dqn] = IniRead("zck.ini", "zck", "s" & $dqn, "")
$dqn = $dqn + 1
WEnd
EndFunc ;==>dqyz
[ 本帖最后由 ahphsautoit 于 2009-4-16 10:30 编辑 ] 用数组吧
Dim dx=0
While $n <18
ReDim dx[$n]
$dq=IniRead("zck.ini","zck","x"&$n,"")
$dx[$n]=$dq
$n=$n+1
WEnd 这种情况得用数组 晕!我知道数组,也用得来数组啊,怎么没有想到啊???
呵呵,感谢以上两位朋友! 用Eval可以解决
页:
[1]