Solved

Does Powerbuilder has CHIDIST (in excel) function?

Posted on 2004-03-24
11
675 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 

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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
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 NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

630 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