f_getfromdw.srf 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. $PBExportHeader$f_getfromdw.srf
  2. $PBExportComments$从数据窗口取数函数--自定义函数
  3. global type f_getfromdw from function_object
  4. end type
  5. forward prototypes
  6. global function string f_getfromdw (string dw_get, string column_get, string cond_get, integer record_get)
  7. end prototypes
  8. global function string f_getfromdw (string dw_get, string column_get, string cond_get, integer record_get);//从前台数据窗口定位取一个数据,dw_get=数据窗口的tag,column_get=字段英文名,cond_get=取数定位条件
  9. int ll_row,li
  10. string ls_tag2,ls_tag3,ls_return
  11. datawindow ldw_now,ldw_dw2,ldw_dw3
  12. if trim(cond_get)='' then cond_get='1=1'
  13. if isvalid(w_rpt_edit) then
  14. ldw_dw2=w_rpt_edit.istr_rpt.userdw2
  15. ldw_dw3=w_rpt_edit.istr_rpt.userdw3
  16. elseif isvalid(w_rpt_preview) then
  17. //ldw_dw2=w_rpt_preview.istr_rpt.userdw2
  18. //ldw_dw3=w_rpt_preview.istr_rpt.userdw3
  19. end if
  20. if isvalid(ldw_dw2) then
  21. ls_tag2=ldw_dw2.tag
  22. if ls_tag2='' then ls_tag2=ldw_dw2.dataobject
  23. end if
  24. if isvalid(ldw_dw3) then
  25. ls_tag3=ldw_dw3.tag
  26. if ls_tag3='' then ls_tag3=ldw_dw3.dataobject
  27. end if
  28. choose case dw_get
  29. case ls_tag2
  30. ldw_now=ldw_dw2
  31. case ls_tag3
  32. ldw_now=ldw_dw3
  33. end choose
  34. if isvalid(ldw_now) then
  35. for li=1 to record_get
  36. ll_row=ldw_now.find(cond_get,ll_row+1,ldw_now.rowcount()+1)
  37. if ll_row=0 then exit
  38. next
  39. if ll_row>0 then
  40. ls_return=ldw_now.Describe("Evaluate('"+column_get+"',"+string(ll_row)+")")
  41. end if
  42. else
  43. ls_return='前台取数出错'
  44. end if
  45. return ls_return
  46. end function