Solved

Does Powerbuilder has CHIDIST (in excel) function?

Posted on 2004-03-24
11
655 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
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 perform CRUD operations on a MySql database.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

809 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