Need help with bank stream.

BlitzMax Forums/BlitzMax Beginners Area/Need help with bank stream.

Caton(Posted May) [#1]
Bank = Cipher.Decrypt(LoadBank("test.bin"),"test#052")
CreateBankStream(bank)
file=ReadStream("test.bin")
If file Then
DebugLog ReadString(file,3)
CloseFile(file)
EndIf


Am I missing something?


TomToad(Posted May) [#2]
I'm not sure what you are trying to do, but this code makes more sense.
SuperStrict
Local Bank:TBank = Cipher.Decrypt(LoadBank("test.bin"),"test#052")
Local File:TStream = CreateBankStream(bank)
If file Then
     DebugLog ReadString(file,3)
     CloseFile(file)
EndIf


You are returning the result from Cipher.Decrypt into Bank, then creating a stream from the result, but then you open a new stream to the original file instead of the decrypted bank and read from that.

Also, since I cannot see what other code is here, I don't know if Bank and file are being declared anywhere. If not, then your code will use BlitzBasic style handles instead of using BlitzMax objects. This can be done, but it is slower, and can be the cause of memory leaks and other bugs. Using Superstrict requires that you declare the object type like in my example.