- May 20, 2008
Here are two BTMs, create.btm to create the binary key and read.btm to read it.
The create seems to always work okay. Every once in a while, the read will have the same size. But, usually, the read will either be of a different/larger size with some junk chars at the end or TCC will close. When I put pauses between the steps, it seems the issue may be with bsize, though the handle is valid.
C:\>ver TCC 23.00.21 x64 Windows 10 [Version 10.0.17134.112]
CREATE.BTM @echo off setlocal set key=btest unqlite /db:"test.db" /rwc set size=%@random[10,100] REM Handle off by one poke error with @inc set bhandle=%@balloc[%@inc[%size]] set result=%@bpokestr[%bhandle,0,a,%@repeat[x,%size]] unqlite /kvb %key %bhandle %size set result=%@bfree[%bhandle] unqlite /c echo Binary key '%key' created of size %size
READ.BTM @echo off setlocal set db=test.db set key=btest set result=%@unqopen[rwc,%db] REM Size unknown - let unqreadb expand buffer set bhandle=%@balloc set result=%@unqreadb[%db,%key,%bhandle] set size=%@bsize[%bhandle] set value=%@bpeekstr[%bhandle,0,a,%size] set result=%@bfree[%bhandle] set result=%@unqclose[%db] echo Binary key '%key' read of size %size echo Value: %value