现在的位置: 首页 > 综合 > 正文

【PB】获取DW.DS的参数名、类型、参数的值

2013年08月10日 ⁄ 综合 ⁄ 共 1696字 ⁄ 字号 评论关闭
public function integer of_dwgetarguments (ref powerobject apo_aux, ref string as_argnames[], ref string as_argdatatypes[], ref string as_argvalues[]);
//====================================================================
// 事件: n_dwget_argument.of_dwgetarguments()
//--------------------------------------------------------------------
// 描述: 获取DW.DS的参数名、类型、参数的值
//--------------------------------------------------------------------
// 参数:
//  reference powerobject apo_aux           DW or DS
//  reference string      as_argnames[]     名称
//  reference string      as_argdatatypes[] 类型
//  reference string      as_argvalues[]    值
//--------------------------------------------------------------------
//====================================================================

string       ls_dwargs, ls_dwargswithtype[], ls_args[], ls_types[]
long         ll_a, ll_args, ll_pos, ll_index

// Comprobamos los argumentos.
if IsNull(apo_aux) or not IsValid(apo_aux) then
   return -1
end if

// Obtenemos el string con los argumentos del dw o ds.
ls_dwargs = apo_aux.DYNAMIC Describe ( "DataWindow.Table.Arguments" ) 

// Separamos los argumentos utilizando la un array y obtenemos el número total.
ll_args = of_ParseToArray ( ls_dwargs, "~n", ls_dwargswithtype ) 

// Ahora separamos el nombre del argumento de su tipo y además obtenemos el valor.

For ll_a = 1 to ll_args
   ll_pos = PosA ( ls_dwargswithtype[ll_a], "~t", 1 )

   If ll_pos > 0 Then
      ll_index = UpperBound(as_argnames) + 1
      as_argNames[ll_index]      = LeftA ( ls_dwargswithtype[ll_a], ll_pos - 1 ) 
      as_argDataTypes[ll_index] = MidA ( ls_dwargswithtype[ll_a], ll_pos + 1 ) 
      
      // Cargamos el valor correspondiente. Si es de tipo array ponemos cadena vacía.
      If rightA(as_argDataTypes[ll_index], 4) = 'list' Then
         as_argValues[ll_index] = ''
      Else
         as_argValues[ll_index] = apo_aux.DYNAMIC Describe("evaluate('" + as_argNames[UpperBound(as_argnames)] + "',1)") 
      End If
   End If 
 
Next
Return UpperBound ( as_argnames )
end function 

抱歉!评论已关闭.