BaanV的table field变量的生命周期

     BaanV没有类的概念,其代码结构类似parscal,意大利面式的,table的field变量不同于普通变量,其生命周期从定义开始一直到该session关闭为结束.

     测试:debug run script1的read.warehouse,其中call tcdup.dll0001.hello

script 1:

function extern read.warehouse()

{

        table     ttcmcs003

        domain tccwar cwar

 

        select tcmcs003.*

        from   tcmcs003

        where tcmcs003.cwar='RM'

        selectdo

               cwar=tcmcs003.cwar 

                |* 此时变量cwar及tcmcs003.cwar都为RM

               tcdup.dll0001.hello()

        endselect

}

 

tcdupdll001:

function extern tcdup.dll0001.hello()

{

        domain tccwar cwar

        domain ttcmcs003

         |* 此时变量cwar=""

         |* tcmcs003.cwar=RM

        select tcmcs003.*

        from   tcmcs003

        where tcmcs003.cwar='FG'

        selectdo

              cwar=tcmcs003.cwar

        endselect

}

 

另,table field 变量不会因下一个select不到record而重新置空,如:

tcmcs003有cwar="RM"的data:

 

select tcmcs003.cwar

from   tcmcs003

where tcmcs003.cwar="RM"

selectdo

          cwar=tcmcs003.cwar

endselect

|*紧接我们又做如下select,该select查无data

select tcmcs003.cwar

from   tcmcs003

where tcmcs003.cwar="haha"

selectdo

          cwar=tcmcs003.cwar

endselect 

 

|* 但select后,tcmcs003.cwar仍会保持"RM"的值

你可能感兴趣的:(table)