C# question

taximania

Well-Known Member
Licensed User
Longtime User
Say I have this.

public void Load()
{
msg = MessageStore.Inbox.NumberOfItems;
}

How can I do this to it, so I don't need a sub for every different store ?

public void Load(string s)
{
msg = MessageStore.s.NumberOfItems;
}

TIA
 

agraham

Expert
Licensed User
Longtime User
You don't say what types are involved and poking round in your dll I can't see anything with a NumItems property and can't directly map that sample fragment onto your code. My best guess is that you want to replace the four LoadXxxMsg methods with one and specify things like "OutboxFolder" as a String.

The easiest thing is probably to do a switch to set an instance of IMAPIFolder to the required folder and then do the common stuff on that. Treat this as psuedo code - there are probably mistakes as I've just dashed it off and there is no error checking for a bad string value.
B4X:
public void LoadMsg(string folder)
{
  folder = folder.ToLower()

  IMAPIFolder f;
  switch (s)
   {
        ....
        case "outbox":
        f =  stores[StoreNum].OutboxFolder; break;
        ....
   }
    this.MsgNum2 = (int) stores[this.StoreNum].OutboxFolder.NumSubItems;
    int num = 0;
    int numSubItems = (int) f.NumSubItems;
    while (num < numSubItems)
    {
        msg = f.GetNextMessages(MsgNum2);
        num++;
    }
}
 

taximania

Well-Known Member
Licensed User
Longtime User
Sorry AGraham, my example was psudo code :-( Oops.
I never intended anyone to spend time on it. Or this post.
Happy New Year mate, hope it's good for you

I considered using Case etc. I'd still need 4 seperate Case statements ?
The code in my dll works fine.
I just felt a bit hypocritical of telling other forum users about the
255 Buttonx_Click events when Control and Sender are available.

I'll give your code some perusing tomorrow.

Best regards Barry.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…