Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 692
  • Last Modified:

Does Powerbuilder has CHIDIST (in excel) function?

Hi,
   I would like to use the excel function named CHIDIST (chi-square distribution statistical function) in Powerbuilder. Unfortunately I can't find powerbuilder have this kind of build-in function. Does any one know how to write our own CHIDIST function in Power Builder? Thanks in advance. I appreaciate your advice very much. Thanks again.
0
cindylsn
Asked:
cindylsn
  • 4
  • 3
  • 2
  • +1
1 Solution
 
Vikas_DixitCommented:
I don't think PB has a similar function...
I you are already using excell in your app, may be you can call this excell function in PB through OLE...

--VIkas
0
 
cindylsnAuthor Commented:
I don't use excel in my application... :O( wish that I can write a CHIDIST function in Powerbuilder.
0
 
diasroshanCommented:
hi,
it might be difficult to write a CHIDIST function in powerbuilder...but what u can do is ..if u know visual basic (CHIDIST function is readily available) u can write a code in visual basic ,make a .dll and call it in powerbuilder....
let me know if u need more help...

Cheers,
Rosh
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
cindylsnAuthor Commented:
hi Rosh,
 Thanks for the idea. Unfortunately I know nothing abt VB. Can someone help me in writting the .dll file with CHIDIST function so that I can use that in my PB application. appreciate ur help very much. thanks
0
 
namasi_navaretnamCommented:
Here is the piece of code that will do the trick.

oleobject lole_object
long ll_result
string ls_value

lole_object = create oleobject
ll_result = lole_object.ConnectToNewObject( "excel.application")
lole_object.application.visible = false

ls_Value = String(lole_object.Application.WorksheetFunction.CHIDIST(10, 20))
MessageBox("debug", ls_value)

If IsValid(lole_object) then destroy lole_object

Regards

Namasi Navaretnam
0
 
cindylsnAuthor Commented:
hi Namasi,
 Thanks for the sample code. This is what I did right now. But I prefer using a dll rather than create the OLE object connect and destroy it for each record. the query returns me more than 100,000 of records and each record need to calculate for CHIDIST. this is time comsuming.
0
 
diasroshanCommented:
hi cindylsn,
well if u can lend me some time i can attempt to write a dll in vb and possibly mail the code to u...

Cheers,
Rosh
0
 
cindylsnAuthor Commented:
well ok.. hope to see ur reply soon. thanks
0
 
diasroshanCommented:
hi  cindylsn,

the code put in my namasi will serve ur purpose ....
...the time consuming problem u have written abt does not arise..
i tried it with a dw of mine which returns 5000 rows and it was cool breeze...
...with the only exception that all my 5000 records return at one go....
..so i did the following.....

oleobject lole_object
long ll_result, i, ll_val1, ll_val2
string ls_value, ls_val[]
Decimal{2} ld_result
 
lole_object = create oleobject
ll_result = lole_object.ConnectToNewObject( "excel.application")
lole_object.application.visible = false

//dw_1 returns 5000+ rows
For i = 1 to dw_1.RowCount()
      ll_val1 = dw_1.Object.val1[i]
      ll_val2 = dw_1.Object.val2[i]
      ls_Value = String(lole_object.Application.WorksheetFunction.CHIDIST(ll_val1, ll_val2))
      ls_val[i] = ls_value   // take it into an array
      //or,
       ld_result = Dec(ls_value)
       dw_1.Object.result[i] = ld_result
Next
If IsValid(lole_object) then destroy lole_object

but if ur datawindow returns one row at a time then u have a problem with time....

if the above suggestion helps well and good if u still have a problem let me know exaclty what u want the dll to return....

Cheers...
Rosh





0
 
Vikas_DixitCommented:
Hi,

This is as I have suggested... You will need MS Excell to be installed with your app for this code to work...

Regards,
VIkas
0
 
namasi_navaretnamCommented:
Yes. Execution time should not be issue as you will need to connect to excel only once.

Regards-
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 4
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now