String to byte ptr ?
BlitzMax Forums/BlitzMax Programming/String to byte ptr ?
| ||
Hi :) I have try to convert an old bmax source code with the new version 1.10 but the program crash on this line B.Stream=BASS_StreamCreateFile(0,File,0,0,B.MusicFlag|BASS_MP3_SETPOS) Error : "Unable to convert from string to byte ptr" I think that the FILE arg is the cause (it's a string) but i don't know how solve this problem ? me and the pointer ... But the BASS DLL function calling nee byte ptr : Global BASS_StreamCreateFile(mem:Int, file:Byte Ptr, offset:Int, length:Int, flags:Int)"Win32" = GetProcAddress(DllHandle,"BASS_StreamCreateFile") |
| ||
filax, try this. Local file$ = "c:test\test.exe" Local file_str_pointer:Byte Ptr = Byte Ptr file$ |
| ||
Hi Kev Your source generate the same error ! i don't know why ! |
| ||
the small example compiles fine here, try. Local file:String = "c:test\test.exe" Local file_str_pointer:Byte Ptr = Byte Ptr file |
| ||
The solution is : ToCString() Local File_Pointer:Byte Ptr=File.ToCString() B.Stream=BASS_MusicLoad(0, File_Pointer, 0, 0,B.MusicFlag,0) |
| ||
hey filax i dont see the new beta 1.11? is it not available yet? |
| ||
In another section. |
| ||
i dont filax, but thanks. |
| ||
filax, you're not supposed to let people know that area exists. =] |
| ||
Sure but ... it's not armaggeddon :) people cannot go there. |
| ||
...but people will now *want* to go there! |
| ||
Hi, Ok, shouldn't really be talking about this here but a heads up wont hurt... The next release of Max will no longer automatically convert strings to Byte Ptr's - you need to explicitly call ToCString... Local p:Byte Ptr=mystring.ToCString() ...do stuff with p... MemFree p ...Note the MemFree after you've finished with the Byte Ptr. The reason for this is that with automatic GC you can't predict when such 'automatic cstrings' may be reclaimed, so I decided to take them out of the GC loop altogether. |
| ||
Ok mark thanks ! to clarify. Sorry for ... shut !! But i did not think that this problem of programming was specific to the beta 1.11, if not, I would have posted aillor, afflicts for the mistake. |