Jump to content

Need Help getting an Array from COM Object


Recommended Posts

Hi guys, trying to figure this out but getting know where, hope some one can help me out.

getBalance(exchangeId:integer): Balance

Parameters

exchangeId: 1=UK server, 2=Australian server

Description

Returns current balance in a Balance object.

Balance

Field Description

availBalance:double current balance available to bet with

balance:double total balance including ignoring current exposure

exposure:double current exposure of outstanding bets.

Local $BAcom = ObjCreate("BettingAssistantCom.Application.ComClass")
$balance = $BAcom.getBalance(1).availBalance
MsgBox(0, "", $balance)

this works fine. now for the problem.

getPrices(): Price()

Description

Returns last refreshed prices for all selections in currently displayed market in an array of Price object.

Price

Field Description

Selection:string name of selection

backOdds3:double 3rd best available price offered by layers

backOdds2:double 2nd best available price offered by layers

backOdds1:double best available price offered by layers

i've tried a buntch of combinations with the WITH statement, but just cant get it to work. hellllllp! :P

Link to comment
Share on other sites

someone managed to do it in C# with he following

"Hi, I cracked it. I still couldnt get to the data with prices[0].---, but I dont think Im supposed anyway. As in your help section it says getPrices(): Price()

Description

Returns last refreshed prices for all selections in currently displayed market in an array of Price object. Id forgot about the price object and was thinking to much about getprices. Anyway this is what I have done, If anyones using a more efficient method please let me know.

I created an array list the added the getprices, the looed through the array for the Price object.

private ArrayList prices = new ArrayList();

prices.AddRange(ba.getPrices()); (addrange instead off add, Add puts everthing into one element)

foreach (BettingAssistantCom.Application.Price data in prices)

{

double x = data.backMoney3;

}

Turned out to be easy in the end. As you can tell Im new to programming."

Link to comment
Share on other sites

I can't offer any insight.

Please remember that this is an approximately global community, you might have to wait 24 hours before the party who could help you has had a chance to read your post.

Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines.

Link to comment
Share on other sites

here is another example i found in C

CODE
using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using BettingAssistantCom.Application;

namespace BA_COM_Test_C

{

public partial class Form1 : Form

{

private ComClass ba;

public delegate void pricesUpdatedDeleg();

public Form1()

{

InitializeComponent();

ba = new ComClass();

}

private void button1_Click(object sender, EventArgs e)

{

BettingAssistantCom.Application.Balance bal;

Object[] sports;

Object[] events;

double diff;

String result;

bal = (Balance)ba.getBalance(1);

AvailableBalance.Text = "Available balance:" + bal.availBalance.ToString();

Balance.Text = "Balance:" + bal.balance.ToString();

Exposure.Text = "Exposure:" + bal.exposure.ToString();

sports = ba.getSports();

foreach (BfSport sport in sports) {

if (sport.sport == "Horse Racing - Todays Card") {

events = ba.getEvents(sport.sportId);

foreach (BfEvent evnt in events) {

System.TimeSpan TS = new System.TimeSpan(evnt.startTime.Ticks - DateTime.Now.Ticks);

diff = TS.TotalSeconds;

if (diff >= 0 && evnt.eventName.IndexOf("(") == -1) {

result = ba.openMarket(evnt.eventId, evnt.exchangeId);

eventName.Text = evnt.eventName + "(" + evnt.startTime + ")";

ba.pricesUpdated += new pricesUpdatedDelegate(ba_pricesUpdated);

break;

}

}

}

}

ba.refreshRate = 1;

}

public void ba_pricesUpdated()

{

pricesUpdatedDeleg deleg = new pricesUpdatedDeleg(this.pricesUpdated);

this.Invoke(deleg);

}

public void pricesUpdated()

{

Object[] prices;

listBox1.Items.Clear();

prices = ba.getPrices();

foreach (Price priceItem in prices)

{

listBox1.Items.Add(priceItem.selection.PadRight(50,' ') + "\t" + priceItem.backOdds1);

}

}

}

}

the helpfile can be found here:

http://www.gruss-software.co.uk/Betting_As...ssistantCom.htm

Edited by laffo16
Link to comment
Share on other sites

well got some workin code for excel visual basic

CODE
Dim WithEvents ba As BettingAssistantCom.ComClass

' this event is fired on each refresh which is an ideal time to call getPrices

Private Sub ba_pricesUpdated()

prices = ba.getPrices

i = 4

For Each priceItem In prices

i = i + 1

Cells(i, 1).Value = priceItem.Selection

Cells(i, 2).Value = priceItem.backOdds1

Cells(i, 3).Value = priceItem.layOdds1

Cells(i, 4).Value = priceItem.lastMatched

Cells(i, 5).Value = priceItem.totalMatched

Next

End Sub

Private Sub CommandButton1_Click()

If ba Is Nothing Then

Set ba = New BettingAssistantCom.ComClass

End If

End Sub

the autoit code below returns Error $Element^.^Selection, varible must be of type Object.

Local $BAcom = ObjCreate("BettingAssistantCom.Application.ComClass")
$prices = $BAcom.getPrices
For $Element In $prices
    MsgBox(0, "", $Element.Selection)
Next

hope someone can help me soon ive been stuck on this all day lol :P

Link to comment
Share on other sites

After you do an ObjCreate, check immediately after to see if you did in fact instantiate an object with IsObj

for example:

$oA = ObjCreate("BettingAssistantCom.Application.ComClass")

If IsObj($oA) Then ConsoleWrite("$oA is and object" & @CR)

$oB = ObjCreate("BettingAssistantCom.ComClass")

If IsObj($oB) Then ConsoleWrite("$oB is and object" & @CR)

$oC = ObjCreate("BettingAssistantCom")

If IsObj($oC) Then ConsoleWrite("$oC is and object" & @CR)

Dale

Edited by DaleHohm

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

well the code below works fine

Local $BAcom = ObjCreate("BettingAssistantCom.Application.ComClass")
$balance = $BAcom.getBalance(1).availBalance
MsgBox(0, "", $balance)

would this mean the dll is registered? i found their is a "BettingAssistantCom.dll" & "BettingAssistantCom.tlb" file, so i jumped into dos and tried to reg it just incase it might help but i got a error in return "BettingAssistantCom.dll was loaded, but the DllRegisterServer entry point was not found, file can not be registered"

Link to comment
Share on other sites

im baffled, thanks the response guys, got it now just wish would have found it sooner. i dont understand how IsObj() makes the thing work as i thought that function simply returned a value.

Local $BAcom = ObjCreate("BettingAssistantCom.Application.ComClass")

MsgBox(0, "", IsObj($BAcom)) ; for some strange reason, adding this line makes it work?

$prices = $BAcom.getPrices
For $Element In $prices
    MsgBox(0, "", $Element.Selection)
NextoÝ÷ Ù©òײ0Ƨëm+-£
+­­q©ex&²èÆZ%-ªëÊ+p¢¹,naÂ+a¢¼"¶.¶Ø^ªê-ªê-jÉh¬È£¬¡¸é­ë×ÖÙ¨­ë^²Ø§©Ýø§vØZµ«%yê]zV²ÊÞªè«yÖµêÎn0«y«^¡ö©®wÓI¢ÇÛkç¡×zZ0jëh×6While 1
    If IsObj($BAcom) = 1 Then ExitLoop
WEndoÝ÷ Ù»­×hzÉíÂäÛzk4ß @ryÊ&zƧ9¸ÞrÛ-­¨ Ö°k&!¢»]zV²ÊÞªè«yÖÞ~Þrí{¢.¬¶*'±©ò¢wv¥yØ­j`¢Ø­²h¥zêëk-÷ß}÷jëh×6While 1
    $prices = $BAcom.getPrices()
    If UBound($prices) > 1 Then
        ExitLoop
    EndIf
WEnd

keeps checking $prices until $BAcom.getPrices() responses with data. wohooo

Edited by laffo16
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...