注册 登录
编程论坛 VFP论坛

对象名无效的错误应该怎么排除

sam_jiang 发布于 2022-04-17 19:03, 1061 次点击
只有本站会员才能查看附件,请 登录

这个对象名无效的错误应该怎么排除?

附上我的代码:
程序代码:
LPARAMETERS cPropertyName, eNewValue, nVisiblity, cDescription
NODEFAULT
lexist=.f.
***判断增加的属性是否存在,如果存在则修改属性值,不存在则添加属性***
IF this.propertys.count>0
    FOR i=1 TO this.propertys.count
        IF this.propertys(i)==cpropertyname
            lexist=.t.
            IF TYPE("enewvalue")=="C"
                enewvalue=STREXTRACT(enewvalue,'"','"')
            ENDIF     
            this.&cpropertyname=enewvalue
        ENDIF
    ENDFOR  
ENDIF
   
*IF lexist=.f.
*    [color=#0000FF]IF VARTYPE(this.&cpropertyname)#"U"[/color]
*        cpropertyname[color=#808080]=cpropertyname+"1"[/color]
*    ENDIF
*    DODEFAUL(cpropertyname,enewvalue)
*    this.propertys.[color=#0000FF]add(cpropertyname) &&往element属性集里添加属性[/color]
*ENDIF     
IF lexist=.f.
    IF VARTYPE(this.&cpropertyname)=="U"
        DODEFAUL(cpropertyname,enewvalue)
    ELSE
        this.&cpropertyname=enewvalue
    ENDIF
    this.propertys.add(cpropertyname) &&往element属性集里添加属性
ENDIF     
2 回复
#2
hu9jj2022-04-18 08:56
修改对象名,避免与VFP类同名。
#3
sam_jiang2022-04-21 18:17
我自己排除了,是因为解析出来的enewvalue 包含引号",剔除引号就可以了,和vfp类同名没有问题。
代码如下:
程序代码:
LPARAMETERS cPropertyName, eNewValue, nVisiblity, cDescription
NODEFAULT
lexist=.f.
***判断增加的属性是否存在,如果存在则修改属性值,不存在则添加属性***
***下面三行代码单独提出来就排除了,哈哈哈
IF TYPE("enewvalue")=="C"
    enewvalue=STREXTRACT(enewvalue,'"','"')
ENDIF

IF this.propertys.count>0
    FOR i=1 TO this.propertys.count
        IF this.propertys(i)==cpropertyname
            lexist=.t.
            this.&cpropertyname=enewvalue
        ENDIF
    ENDFOR  
ENDIF
   
*IF lexist=.f.
*    [color=#0000FF]IF VARTYPE(this.&cpropertyname)#"U"[/color]
*        cpropertyname[color=#808080]=cpropertyname+"1"[/color]
*    ENDIF
*    DODEFAUL(cpropertyname,enewvalue)
*    this.propertys.[color=#0000FF]add(cpropertyname) &&往element属性集里添加属性[/color]
*ENDIF     
IF lexist=.f.
    IF VARTYPE(this.&cpropertyname)=="U"
        DODEFAUL(cpropertyname,enewvalue)
    ELSE
        this.&cpropertyname=enewvalue
    ENDIF
    this.propertys.add(cpropertyname) &&往element属性集里添加属性
ENDIF     
1