PB的blob类型在使用时应该特别注意的地方(坑)

Powerbuilder

坑1:blob转成number时要用对类型转换函数

long biWidth

Fileseek(filebmp,biWidth_offset,FromBeginning!)
FileReadEx(filebmp,bread,biWidth_len)
//blob赋值给long
biWidth = long(bread) //这里可以

int biBitCount

Fileseek(filebmp,biBitCount_offset,FromBeginning!)
FileReadEx(filebmp,bread,biBitCount_len)
biBitCount = integer(bread) //这里用long搞了半天都是0.正常是1.用integer正常了。

坑2:char转blob注意encoding编码

如果用

string swrite

swrite = char(27)+char(42)

filewrite(fileprint,swrite) //这样写在linemode的时候的确可以正常发送给打印机。哪怕它是双字节的。(可能文件默认是以encodingansi的模式打开的??没搞懂)

如果

blob bwrite

bwrite = blob(char(27)+char(42))这样写入就是双字节了。

bwrite = blob(char(27)+char(42),encodingansi!)就需要加encoding了。

坑3:blobedit必须准确指定类型。如

blobedit(bbyte,1,biWidth/256) //坑
blobedit(bbyte,1,byte(biWidth/256)) //正确

坑4:连续用了blob的串接后,blob越来越长。

for

for。。。

bwrite = bwrite + bbyte

bwrite = bwrite + bbyte

bwrite = bwrite + bbyte

next

filewrite(fileprint,bwrite) //写出特别大的文件来。8k的bmp打印点阵864k

next

我加了一个初始化

blob blobnull

for 。。。

bwrite = blobnull //加了这个后正常

for。。。

bwrite = bwrite + bbyte

bwrite = bwrite + bbyte

bwrite = bwrite + bbyte

next

filewrite(fileprint,bwrite)

next