Issues getting my market orders in LavishScript and C#

uruiamme

Member
Hi there, I appologize for all of the code posts about to happen, but here's my story.

I attempted, using snippets copied from these forums to get market orders using ISXEVE, and ran into a few problems.

First, I don't know how to apparently assign return values of functions to variables in my main loop with lavishscript.

The following works (copied from another post, without much modification), and seems to find the correct number of orders, but can't really be used in any well designed way; but rather only as a test.
Code:
function myOrders()
{
    EVE:ClearMarketOrderCache
    variable index:myorder Orders
    variable iterator it        
    echo "Updating/Fetching My Orders..."
    Me:UpdateMyOrders
    wait 10    
    while !${Me:GetMyOrders[Orders]}
    {
        wait 10
    }
    echo Found ${Orders.Used} Orders
    echo "Finished collecting my orders."
    Orders:GetIterator[it]
    if ${it:First(exists)}
    { 
            if (${it.Value.IsSellOrder})
            {
                echo === SELL Order ===
            }
            elseif (${it.Value.IsBuyOrder})
            {
                echo === BUY Order ===
            }
            echo ID: ${it.Value.ID}
        echo "First Exists"
        while ${it:Next(exists)}
        {
            echo "Another Exists"
        }
    }
    else
    {
        echo "None Exist"
    }
    return ${Orders}
}


function main()
{
echo "Starting Market Updater"
call myOrders
}
When I started cleaning that up, by the placing the portion I wanted in a function in a function, and the analytical (albeit not very, yet) part into main, by changing it to the following I get 0 orders in main.
Code:
function myOrders()
{
    EVE:ClearMarketOrderCache
    variable index:myorder Orders        
    echo "Updating/Fetching My Orders..."
    Me:UpdateMyOrders
    wait 10    
    while !${Me:GetMyOrders[Orders]}
    {
        wait 10
    }
    echo "Finished collecting my orders."
    return ${Orders}
}


function main()
{
echo "Starting Market Updater"
call myOrders
variable iterator it
variable index:myorder AllMyOrders
AllMyOrders:Set[${Return}]
echo Found ${AllMyOrders.Used} Orders
AllMyOrders:GetIterator[it]
if ${it:First(exists)}
    { 
            if (${it.Value.IsSellOrder})
            {
                echo === SELL Order ===
            }
            elseif (${it.Value.IsBuyOrder})
            {
                echo === BUY Order ===
            }
            echo ID: ${it.Value.ID}
        echo "First Exists"
        while ${it:Next(exists)}
        {
            echo "Another Exists"
        }
    }
    else
    {
        echo "None Exist"
    }
}
Then, for kicks I changed it to the following, where I attempt define the variable in main, and pass it to the myOrders function since I didn't know how to get the return back... and it also didn't work (I have to admit, I'm a noob, and didn't research this one well, so I'm not sure if I need to declare the variable type in the function definition, or how I would do that, because when I tried it the way it seemed logical "function myOrders(index:myorder OrdersObj)" it didn't work).... this one was kindof a last attempt before switching to .Net to try there since there wasn't really anyone active on IRC to ask. This one fails to run at my function call in main... also fails if I pass "call myOrders(${AllMyOrders})", but I kinda expected that since I want to pass the object itself (I think?)
Code:
function myOrders(OrdersObj)
{
    EVE:ClearMarketOrderCache
    echo "Updating/Fetching My Orders..."
    Me:UpdateMyOrders
    wait 10        
    while !${Me:GetMyOrders[OrdersObj]}
    {
        wait 10
    }
    echo Found ${OrdersObj.Used} Orders
    echo "Finished collecting my orders."
    return
}


function main()
{
echo Starting Market Updater
variable index:myorder AllMyOrders
call myOrders(${AllMyOrders})
echo AllMyOrders.Used
variable iterator it
AllMyOrders:GetIterator[it]
    if ${it:First(exists)}
    { 
            if (${it.Value.IsSellOrder})
            {
                echo === SELL Order ===
            }
            elseif (${it.Value.IsBuyOrder})
            {
                echo === BUY Order ===
            }
            echo ID: ${it.Value.ID}
        
        echo "First Exists"
        while ${it:Next(exists)}
        {
            echo "Another Exists"
        }
    }
    else
    {
        echo "None Exist"
    }


}
So, I gave up on LavishScript, which I'm very unfamiliar with, and I feel isn't documented in a way that works well for me; I do work best off examples, and there aren't many examples on here where people are working with the market portions of ISXEVE (understandably so)... And on to C#.
Code:
        private void button1_Click(object sender, EventArgs e)
        {
            EVE.ISXEVE.EVE eve = new EVE.ISXEVE.EVE();
            Me me = new Me();
            List<MyOrder> OrdersList = new List<MyOrder>();
            List<String> SellOrderItemNames = new List<string>();
            List<String> BuyOrderItemNames = new List<string>();
            using (new FrameLock(true))
            {
                eve.ClearMarketOrderCache();
            }
            Thread.Sleep(5000);
            using (new FrameLock(true))
            {
                me.UpdateMyOrders();
            }
            Thread.Sleep(5000);
            using (new FrameLock(true))
            {
                OrdersList = me.GetMyOrders();
            }
            if (OrdersList != null)
            {
                MessageBox.Show(OrdersList.Count.ToString());
            }
            else
            {
                MessageBox.Show("OrdersList is null");
            }
            /*
            foreach (MyOrder o in OrdersList)
            {
                if (o.IsBuyOrder)
                {
                    BuyOrderItemNames.Add(o.Name);
                }
                else
                {
                    if (o.IsSellOrder)
                    {
                        SellOrderItemNames.Add(o.Name);
                    }
                }
            }
            SellOrdersList.DataSource = SellOrderItemNames;
            BuyOrdersList.DataSource = BuyOrderItemNames;
            */
        }
So, in this last one, I was attempting to basically have a form with a button, which when clicked gets all of my market orders and populates two listboxes. Every way I tried to get my market orders (and I tried many others than the one listed), GetMyOrders always seems to return null. Can anyone help me out on either the LavishScript or .Net side (I'd love it more on the .net side, but I have no aversion to learning LavishScript, which I'm imagining there's more expertise in on this forum based on other posts I read)? If anyone has an example of either of these, I'd really appreciate you sending it to me (not looking to highjack your script and dominate the market, I just want mine to do what I do manually when I manually trigger it; instead of me taking 20min to update my orders, I'd love to spend that 20min on my other account doing faction warfare or some other such fun thing... also, I just want to be more familiar with how ISXEVE works)

Anyway, I look forward to getting to know more here, and hope my frustration and hacking away at this hasn't come off as negative toward the products or community, this looks like a fun thing to play around with :)
 

Teht

ComBot Author
I believe I've answered the lavishscript questions here, but he's still looking for help with .net...
 

uruiamme

Member
Yes, the information supplied was a great help, and showed me how to do what I wanted all in main, but I still am not really familiar with passing variables back and forth between functions, and if that's possible, I'd love to see how still.

The pursuit of working this in .NET is more appealing though, because well, there's more ultimate flexibility in what can be done with .NET, not to mention more community support for it than LavishScript... I can't just see examples on Stackoverflow for Lavish after all. So, if anyone has examples of market operations in .NET, I'd love to see them. Like I said, I know why there aren't tons of examples posted, and I don't want to write some beastly script to dominate the market (that'd get me banned, and ruin the fun anyway), so if you'd rather just post (or PM me) snippets of interacting with the functions themselves (namely the ones relevant to the above post, but any others you'd be willing to share would be awesome too), I'd be incredibly happy, and you'd have my eternal gratitude.
 

pr517

Active Member
You will be using the Return top-level object (TLO) to retrieve the returned value from the last function called. Treat it as from whatever data type the function is defined. In the example, below, it is an integer.

Code:
function:int myFunc()
{
   return 123
}

function main()
{
   call myFunc
   if ( ${Return} == 123 )
      echo Maybe the wiki isn't such a poor reference.
}
 

pr517

Active Member
Here is the only other sentence from that Return TLO wiki page that I have yet to quote, though I did paraphrase and provide an example to reinforce the point in my prior post:
"The object type is defined by the function called, and will be mutablestring if not specified."

In your second code, you have "function myOrders" which means it is by default a mutablestring type and not an index:myorder type. My example was an integer type (function:int).
 

uruiamme

Member
I've actually read the wiki entry, and failed to put that together... in fact, I failed to remember altogether that this was c like in that you needed to declare functions as types if you want to return from them (probably because it doesn't crash out... because it defaults to mutable string)... Thanks for spelling it out, that's what I needed... FWIW I actually have gotten past that whole part and am writing this as a single function because I couldn't recognize that, and am on to why GetMarketOrders is returning nothing for me, but thanks so much :)

Edit: Also, apparently I didn't see/read/process your second sentence... sorry, it's been a long day. Thanks for being patient.
 
Last edited:

CyberTech

Second-in-Command
Staff member
I've actually read the wiki entry, and failed to put that together... in fact, I failed to remember altogether that this was c like in that you needed to declare functions as types if you want to return from them (probably because it doesn't crash out... because it defaults to mutable string)... Thanks for spelling it out, that's what I needed... FWIW I actually have gotten past that whole part and am writing this as a single function because I couldn't recognize that, and am on to why GetMarketOrders is returning nothing for me, but thanks so much :)

Edit: Also, apparently I didn't see/read/process your second sentence... sorry, it's been a long day. Thanks for being patient.
functions,. methods, and members in LS can only return simple datatypes -- int, float, string, etc. No containers, no script objects. Create a script defined object, move your functions inside it, and have them populate an object-scope index.
 
Top Bottom