i am trying to write a simple script a rollout with 6 spinners x y z t1 t2 t3
I want to set the valuses by reading a text file (containing 6 lines- a number in each line) so the first line of text file which is a number will be assigned to the value of x and then 2nd line of text goes to y and then the sixth line of text value goes to t3.
I appreciate your help on this.
Thanks.
Forum topic · Scripts Wanted
read text file
By cuatcside · 2020-06-16
Description
Comments (2)
.
miauu · 2020-06-16
(
global rol_
try(destroyDialog rol_)catch()
rollout rol_ ""
(
spinner spn_1 "1" range:[1,100,2]
spinner spn_2 "2" range:[1,100,2]
spinner spn_3 "3" range:[1,100,2]
spinner spn_4 "4" range:[1,100,2]
spinner spn_5 "5" range:[1,100,2]
spinner spn_6 "6" range:[1,100,2]
button btn_readTxt "Read TXT"
on btn_readTxt pressed do
(
txtFile = getOpenFileName()
if txtFile != undefined do
(
inFile = openFile txtFile
dataArr = #()
while not eof inFile do
(
str = readLine inFile
append dataArr (str as float)
)
close inFile
if dataArr.count >= 6 do
(
spn_1.value = dataArr[1]
spn_2.value = dataArr[2]
spn_3.value = dataArr[3]
spn_4.value = dataArr[4]
spn_5.value = dataArr[5]
spn_6.value = dataArr[6]
)
)
)
)
createdialog rol_
)
cuatcside · 2020-06-18
Awesome. I really appreciate it.
Thanks.