Hi Ian, thank you for your help, i download your matrix utils, and am currently being held back by my lack of knowledge and commonsense.
I've learned what Select(Case/Endcase)Endselect is used for but i seem to not understand what its doing.
What i am trying to do is this:
Read the values of the file before i open for writing.
Add those values to my array.
Then use my save function i have already written to save all objects in my array.
I think my problem is , the case statement checks to see if *one* of the values fits, then moves on.
here is my save function:
Function SaveOrientation(obj)
ax(obj)=object angle x(obj)
ay(obj)=object angle y(obj)
az(obj)=object angle z(obj)
px(obj)=object position x(obj)
py(obj)=object position y(obj)
pz(obj)=object position z(obj)
sx#(obj)=object size x(obj,1)
sy#(obj)=object size y(obj,1)
sz#(obj)=object size z(obj,1)
if obj=l
open to write 1,filename$+datatype$
if file open(1)=1
Write string 1,"Total Objects:"+str$(l)
for writestring=1 to l
write string 1,"Object "+str$(obj)
write string 1,"Rotation:"+str$(ax(obj))+","+str$(ay(obj))+","+str$(az(obj))
write string 1,"Position:"+str$(px(obj))+","+str$(py(obj))+","+str$(pz(obj))
write string 1,"Size:"+str$(sx#(obj))+","+str$(sy#(obj))+","+str$(sz#(obj))
write string 1,""
dec obj
next writestring
endif:endif
close file 1
Endfunction
Here is my Read function:
Function readfile(file$)
inc obj `to increase it from the current obj
open to read 2,file$
read string 2,storagestring$
split string storagestring$,":"
if obj<l+oldL
select get split word$(1)
case "Total Objects"
oldL=val(get split word$(1))
endcase
case "Rotation"
split string word$,","
ax(obj)=val(get split word$(1))
ay(obj)=val(get split word$(2))
ax(obj)=val(get split word$(3))
endcase
case "Position"
split string word$,","
px(obj)=val(get split word$(1))
py(obj)=val(get split word$(2))
pz(obj)=val(get split word$(3))
endcase
case "Size"
split string word$,","
sx#(obj)=val(get split word$(1))
sy#(obj)=val(get split word$(2))
sz#(obj)=val(get split word$(3))
endcase
endselect
inc obj
else
endif
close file 2
Endfunction
here is all of the code together:
Rem Project: Dark Basic Pro Project
Rem Created: Monday, November 22, 2010
Rem ***** Main Source File *****
Global filename$="Orientation"
Global datatype$=".txt"
dim ax(l)
dim ay(l)
dim az(l)
dim px(l)
dim py(l)
dim pz(l)
dim sx#(l)
dim sy#(l)
dim sz#(l)
`if file exist(filename$+datatype$)=1
`delete file filename$+datatype$
` endif
global l=5
readfile("Orientation.txt")
wait key
for n = 1 to l
make object cube n,1
position object n,rnd(50),rnd(50),rnd(50)
rotate object n,rnd(360),rnd(360),rnd(360)
scale object n,rnd(100)+50,rnd(100)+50,rnd(100)+50
saveOrientation(n)
next n
end
Function SaveOrientation(obj)
ax(obj)=object angle x(obj)
ay(obj)=object angle y(obj)
az(obj)=object angle z(obj)
px(obj)=object position x(obj)
py(obj)=object position y(obj)
pz(obj)=object position z(obj)
sx#(obj)=object size x(obj,1)
sy#(obj)=object size y(obj,1)
sz#(obj)=object size z(obj,1)
if obj=l
open to write 1,filename$+datatype$
if file open(1)=1
Write string 1,"Total Objects:"+str$(l)
for writestring=1 to l
write string 1,"Object "+str$(obj)
write string 1,"Rotation:"+str$(ax(obj))+","+str$(ay(obj))+","+str$(az(obj))
write string 1,"Position:"+str$(px(obj))+","+str$(py(obj))+","+str$(pz(obj))
write string 1,"Size:"+str$(sx#(obj))+","+str$(sy#(obj))+","+str$(sz#(obj))
write string 1,""
dec obj
next writestring
endif:endif
close file 1
Endfunction
Function readfile(file$)
inc obj `to increase it from the current obj
open to read 2,file$
read string 2,storagestring$
split string storagestring$,":"
if obj<l+oldL
select get split word$(1)
case "Total Objects"
oldL=val(get split word$(1))
endcase
case "Rotation"
split string word$,","
ax(obj)=val(get split word$(1))
ay(obj)=val(get split word$(2))
ax(obj)=val(get split word$(3))
endcase
case "Position"
split string word$,","
px(obj)=val(get split word$(1))
py(obj)=val(get split word$(2))
pz(obj)=val(get split word$(3))
endcase
case "Size"
split string word$,","
sx#(obj)=val(get split word$(1))
sy#(obj)=val(get split word$(2))
sz#(obj)=val(get split word$(3))
endcase
endselect
inc obj
else
endif
close file 2
Endfunction
Im sorry if im blatantly asking you for code. But it is much appreciated.