Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2004
    Posts
    113

    Combobox problems? doh!

    Ok sorry about this noob question but it's been a long time since I used apms.

    I have a combo box with 15 items and the item data is numbered 1,2,3 etc.

    this code is not working for me:

    result = ComboBox.GetSelected("ComboBox1");
    data = ComboBox.GetItemData("ComboBox1", result);

    if data == 1 then
    result = Dialog.Message("Notice", "Your message here1.", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    elseif == 2 then
    result = Dialog.Message("Notice", "Your message here2.", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    end
    Any idea why it's not working? - obviously i have missed out 3-15 but you get the gist.

  2. #2
    Join Date
    May 2006
    Posts
    5,380
    maybe ?

    Code:
    result = ComboBox.GetSelected("ComboBox1");
    data = ComboBox.GetItemData("ComboBox1", result);
    
    if data == 1 then
    result = Dialog.Message("Notice", "Your message here1.", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    elseif data == 2 then
    result = Dialog.Message("Notice", "Your message here2.", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    end
    Open your eyes to Narcissism, Don't let her destroy your life!!

  3. #3
    Join Date
    Oct 2009
    Location
    127.0.0.1
    Posts
    279
    well unless your data is numbers, you would want

    Code:
    result = ComboBox.GetSelected("ComboBox1");
    data = ComboBox.GetItemData("ComboBox1", result);
    
    if result == 1 then
    result = Dialog.Message("Notice", "Your message here1.", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    elseif  result == 2 then
    result = Dialog.Message("Notice", "Your message here2.", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    end
    If your data is numbers you need:

    Code:
    result = ComboBox.GetSelected("ComboBox1");
    data = ComboBox.GetItemData("ComboBox1", result);
    
    if result == "1" then
    result = Dialog.Message("Notice", "Your message here1.", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    elseif  result ==  "2" then
    result = Dialog.Message("Notice", "Your message here2.", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    end
    AMS returns the data as a string, it doesn't know it's a number. You can use the String.ToNumber() function as well.
    There are 10 types of people in the world: those who understand binary, and those who don't.

  4. #4
    Join Date
    May 2006
    Posts
    5,380
    Doh, how did i miss that, im slipping!

    this WILL work (apply some lua)
    Code:
    result = ComboBox.GetSelected("ComboBox1");
    data = tonumber(ComboBox.GetItemData("ComboBox1", result));
    
    if data == 1 then
    result = Dialog.Message("Notice", "Your message here1.", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    elseif  data == 2 then
    result = Dialog.Message("Notice", "Your message here2.", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    end
    Open your eyes to Narcissism, Don't let her destroy your life!!

  5. #5
    Join Date
    Jun 2004
    Posts
    113
    Thanks for the information guys, I'll give those a try.

    Cheers.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts