Solved

Does Powerbuilder has CHIDIST (in excel) function?

Posted on 2004-03-24
11
646 Views
Last Modified: 2013-12-26
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
Comment
Question by:cindylsn
  • 4
  • 3
  • 2
  • +1
11 Comments
 
LVL 8

Expert Comment

by:Vikas_Dixit
ID: 10667065
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
 

Author Comment

by:cindylsn
ID: 10673205
I don't use excel in my application... :O( wish that I can write a CHIDIST function in Powerbuilder.
0
 
LVL 18

Expert Comment

by:diasroshan
ID: 10674407
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
 

Author Comment

by:cindylsn
ID: 10683374
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
 
LVL 15

Expert Comment

by:namasi_navaretnam
ID: 10683694
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Author Comment

by:cindylsn
ID: 10683817
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
 
LVL 18

Expert Comment

by:diasroshan
ID: 10684232
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
 

Author Comment

by:cindylsn
ID: 10684319
well ok.. hope to see ur reply soon. thanks
0
 
LVL 18

Accepted Solution

by:
diasroshan earned 125 total points
ID: 10684457
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
 
LVL 8

Expert Comment

by:Vikas_Dixit
ID: 10688761
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
 
LVL 15

Expert Comment

by:namasi_navaretnam
ID: 10689518
Yes. Execution time should not be issue as you will need to connect to excel only once.

Regards-
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now