No it doesn't. If use val() it returns 0 if value was 0.5 or 5 if it was 5.5. I checked some functions from "string to float" threads but they return the same.
Here is my function, to read attributes from .dat file (i used .txt before but it is the same result):
function GetUnitsList()
set dir "Objects\Units\"
List$="ListOfUnits.txt"
text 140,10,"List of units:"
If File Exist(List$)
open to read 1, List$
i=1
repeat
Read String 1, A$
If A$<>""
ListOfUnitTypes(i)=A$
text 140, 20+20*i,A$
UnitTypesNumber=i
text 200, 20+20*i,str$(i)
inc i
endif
until A$=""
Close File 1
for i=1 to UnitTypesNumber
if ListOfUnitTypes(i)<>""
set dir ListOfUnitTypes(i)+"\"
File$=ListOfUnitTypes(i)+".dat"
if File Exist(File$)
open to read 1, File$
Read String 1, A$: If A$<>"" then ListOfUnits(i).Name=A$
Read String 1, A$: A=Val(A$): If A<>0 then ListOfUnits(i).MaxHp=A
Read String 1, A$: A=Val(A$): If A<>0 then ListOfUnits(i).Dmg=A
Read String 1, A$: A=Val(A$): If A<>0 then ListOfUnits(i).Def=A
Read String 1, A$: A=Val(A$): If A<>0 then ListOfUnits(i).MaxSpeed=A
Read String 1, A$: A=Val(A$): If A<>0 then ListOfUnits(i).RotationSpeed=A
Read String 1, A$: A=Val(A$): If A<>0 then ListOfUnits(i).ProjectileType=A
Read String 1, A$: A=Val(A$): If A<>0 then ListOfUnits(i).ReloadTime=A
Read String 1, A$: A=Val(A$): If A<>0 then ListOfUnits(i).Visibility=A
Read String 1, A$: A=Val(A$): If A<>0 then ListOfUnits(i).Range=A
Read String 1, A$: A=Val(A$): If A<>0 then ListOfUnits(i).CostMoney=A
Read String 1, A$: A=Val(A$): If A<>0 then ListOfUnits(i).CostMaterials=A
Read String 1, A$: A=Val(A$): If A<>0 then ListOfUnits(i).CanHeal=A
Read String 1, A$: If A$<>"" then ListOfUnits(i).Object=A$
text 100*i,200,ListOfUnits(i).Name
text 100*i,220,str$(ListOfUnits(i).maxHp)
text 100*i,240,str$(ListOfUnits(i).Dmg)
text 100*i,260,str$(ListOfUnits(i).Def)
text 100*i,280,str$(ListOfUnits(i).maxSpeed)
text 100*i,300,str$(ListOfUnits(i).Rotationspeed)
text 100*i,320,str$(ListOfUnits(i).projectiletype)
text 100*i,340,str$(ListOfUnits(i).reloadtime)
text 100*i,360,str$(ListOfUnits(i).visibility)
text 100*i,380,str$(ListOfUnits(i).range)
text 100*i,400,str$(ListOfUnits(i).costmoney)
text 100*i,420,str$(ListOfUnits(i).costmaterials)
text 100*i,440,str$(ListOfUnits(i).canheal)
ListOfUnits(i).Image=110+2*i-1
if File Exist(ListOfUnits(i).Name+".bmp")
Load Image ListOfUnits(i).Name+".bmp",ListOfUnits(i).Image
else
ReturnCriticalError("System file Objects\Units\"+ListOfUnits(i).Name+".bmp doesn't exist")
endif
ListOfUnits(i).ImageA=110+2*i
if File Exist(ListOfUnits(i).Name+"A.bmp")
Load Image ListOfUnits(i).Name+"A.bmp",ListOfUnits(i).ImageA
else
ReturnCriticalError("System file Objects\Units\"+ListOfUnits(i).Name+"A.bmp doesn't exist")
endif
Close File 1
else
ReturnCriticalError("System file Objects\Units\"+ListOfUnitTypes(i)+"\"+File$+" doesn't exist")
endif
sync
set dir ".."
endif
next i
else
ReturnCriticalError("System file Objects\ListOfUnits.txt doesn't exist")
endif
set dir ".."
set dir ".."
sync
endfunction
Join The dark Side! We have cookies