what would be the eqivalent of thsi blitz3d to bli
BlitzMax Forums/BlitzMax Beginners Area/what would be the eqivalent of thsi blitz3d to bli
| ||
levdat$=ReadFile("config.cfg") If fileType(levdat$)=1 levelsetname$=ReadString$(levdat) level=ReadByte(levdat) CloseFile(levdat) endif levdat$=WriteFile("config.cfg") WriteString(levdat$,levelsetname$) WriteByte(levdat$,level) CloseFile(levdat) is it something to do with streams now? |
| ||
Correct, thats a TStream thing ;-) Although, the code above definitely never worked ... thats a thing to guarantee. FileType assumes a path, readfile returns an int handle (not a string) local levdat:TStream=ReadFile("config.cfg") local level:int local levelsetname:string If levdat <> null levelsetname=ReadString$(levdat) level=ReadByte(levdat) CloseFile(levdat) endif levdat=WriteFile("config.cfg") WriteString(levdat,levelsetname$) WriteByte(levdat,level) CloseFile(levdat) |
| ||
yeah youre right i kinda quickly hacked a piece of code that does work and kinda shorthanded it a bit too much, sorry about that but appreciate the help......the day will come and i'll remember that..... |
| ||
Method loadlev() Local levdat:TStream=ReadFile("config.cfg") Local level:Int Local levelsetname:String If levdat <> Null levelsetname=ReadString$(levdat) level=ReadByte(levdat) CloseFile(levdat) EndIf End Method Method savelev() Local levdat:TStream=ReadFile("config.cfg") Local level:Int Local levelsetname:String levdat=WriteFile("config.cfg") WriteString(levdat,levelsetname$) WriteByte(levdat,level) CloseFile(levdat) End Method would this be correct if it was inside an object, and even though on the method savelev() i would still use Local levdat:TStream=ReadFile("config.cfg") not Local levdat:TStream=WriteFile("config.cfg") |
| ||
You would use WriteFile and check if levdat <> null afterwards to make sure it was opened. the level and levelsetname should not be needed as locals anymore. That data should be stored on your object as you otherwise will always store levelsetname which is "" and level which is 0 ^^ |