当前位置: 代码迷 >> PB >> blob(布尔型)的赋值有关问题
  详细解决方案

blob(布尔型)的赋值有关问题

热度:359   发布时间:2016-04-29 10:33:33.0
blob(布尔型)的赋值问题
在窗口里有一图片控件(p_1),一个载入图片按钮,一个清空图片按钮。
定义了图片用blob型写入变量:blob photo1

载入图片按钮:
。。。
FOR i = 1 to loops
bytes_read = FileRead(li_FileNum, Emp_pic)
photo1 = photo1 + Emp_pic
NEXT
p_1.SetPicture(photo1)

请问我点清空图片按钮时,如何清空blob型变量?把刚载入的图片变量(photo1)清空。



------解决方案--------------------
set null

Description 

Sets a variable to NULL. The variable can be any datatype except for an array, structure, or autoinstantiated object. 

Syntax 

SetNull ( anyvariable )

Argument Description
anyvariable The variable you want to set to NULL
Return value 

Integer. Returns 1 if it succeeds and -1 if an error occurs. If any argument's value is NULL, SetNull returns NULL.

Usage 

Use SetNull to set a variable to NULL before writing it to the database. Note that PowerBuilder does not initialize variables to NULL; it initializes variables to the default initial value for the datatype unless you specify a value when you declare the variable.
If you assign a value to a variable whose datatype is Any and then set the variable to NULL, the datatype of the NULL value is still the datatype of the assigned value. You cannot untype an Any variable with the SetNull function.
------解决方案--------------------
setnull(photot1) 后,因为 photo1 = photo1 + Emp_pic 在运算时,有参数值为 null 结果也为 null 的关系.
所以,最后 photo1 仍为 null
  相关解决方案