[Closed] Box creator
The code:
FS = openFile “C:\medlemmar2.txt”
do(
tnLine = readLine FS
tnData = filterString tnLine “,”
newBox = Box name:tnData[2] pos:[tnData[4],tnData[5],0] length:0.9 height:0.9 height:tnData[6]
)while( not EOF FS)
the error:
[size=3]<File:C:\medlemmar2.txt>
[/size]– Error occurred in anonymous codeblock
– Frame:
– Unable to convert: “575” to type: Float
OK
Can sombody tellme whats wrong???
Use readValue not readLine – read line reads each line as a string – you would therefore have to convert the string into a float.
while not Eof infile do
(
array = readValue infile
b = box()
b.length = array[1] etc etc…
)
Right now, I’m pretty sure you’re trying to assign a string to a float value. Therefor, make sure you convert it to float before assigning it to the object’s position.
For example, you can either do:
pos:[(execute tnData[4]), (execute tnData[5]), 0]
or
pos:[(tnData[4] as float), (tnData[5] as float),0]
Using execute in a script like this would be pretty bad, good for having to rebuild ui or a system that can only be evaluted by execute, but not reading a file.
It WORKS!!!
the solution:
FS = openFile “C:\medlemmar.txt”
do(
tnLine = readLine FS
tnData = filterString tnLine “,”
x=tndata[4]
x=x as float
y=tndata[5]
y=y as float
h=tndata[6]
h=h as float
h=h/100
Box name:tnData[2] isSelected:on
move $ [x,y,0]
$.length =0.9
$.width =0.9
$.height = h
)while( not EOF FS)
Thank you all for your help
I am so happy