Alpha Video Training
Results 1 to 6 of 6

Thread: Unexpected list processing results in Xdialog

  1. #1
    Member
    Real Name
    Bill Murray
    Join Date
    Jun 2009
    Location
    Great Falls, VA
    Posts
    42

    Default Unexpected list processing results in Xdialog

    I'm getting an unexpected result processing a simple list.

    I create a CR LF list, let a user pick more than 1 choice, then convert the result to a comma delimited list. The last result chosen always becomes the first entry in the comma delimited list (at least in my tests). This is not something that is happening as a result of the CRLF_TO_COMMA() function, which preserves the original order.

    Here's the code that demonstrates this. Am I doing something wrong?

    Code:
    dim vIncludeTypes as c
    
    DELETE a_vIncludeTypes		
    DIM a_vIncludeTypes[17] as c
    dim temp_list as c 
    
    temp_list = <<%list%
    All
    Bank
    AccountsReceivable
    OtherCurrentAsset
    FixedAsset
    OtherAsset
    AccountsPayable
    CreditCard
    OtherCurrentLiability
    LongTermLiability
    Equity
    Income
    CostofGoodsSold
    Expense
    OtherIncome
    OtherExpense
    NonPosting
    %list%
    a_vIncludeTypes.initialize(temp_list)
    
    dim temp_comma1 as c
    temp_comma1 = crlf_to_comma(temp_list)
    msgbox("1st Results",temp_comma1+CRLF(2)+"NOTE THE ORDER OF ITEMS IS PRESERVED")
    
    ok_button_label = "&OK"
    cancel_button_label = "&Cancel"
    
    varC_result = ui_dlg_box("Choose several and note the order",<<%dlg%
    Account Types To Include :| [%M%.40,5vIncludeTypes^#a_vIncludeTypes];
    <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>;
    %dlg%)
    
    dim temp_comma2 as c
    temp_comma2 = crlf_to_comma(vIncludeTypes)
    
    msgbox("2nd Results",temp_comma2+CRLF(2)+"NOTE THE ORDER OF ITEMS IS NOT PRESERVED")

  2. #2
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,311

    Default Re: Unexpected list processing results in Xdialog

    Bill, I see the same results here and agree they seem unexpected. The multi-select list box is producing a cr-lf delimited list that does not maintain the relative "position" of selected items, either by the order in which they are selected or by the order in which they are listed in the source list / array. All selected values are returned in the their original sort sequence except for the final selected value which is put at the beginning of the returned list.

    While this usually makes no difference I can see where it might be confusing to users.

    I recommend you forward your script to Alpha with a formal bug report. (Use the Send Bug Report option on the help menu in Alpha Five). It seems to me the multi-select list box should either:

    a) return the items in the order they were selected; or

    b) return the items in the order they appeared originally in the source list / array

    What's happening now is a mish mash of both... and it's confusing.

  3. #3
    Member
    Real Name
    Bill Murray
    Join Date
    Jun 2009
    Location
    Great Falls, VA
    Posts
    42

    Default Re: Unexpected list processing results in Xdialog

    Thanks, Tom. I'll do that.

    For some applications, I could resort the comma delimited list, but this is one where the order isn't sortable without a lot of work.

  4. #4
    Alpha Software Employee Selwyn Rabins's Avatar
    Real Name
    Selwyn Rabins
    Join Date
    Mar 2000
    Location
    Boston, MA
    Posts
    5,302

    Default Re: Unexpected list processing results in Xdialog

    Quote Originally Posted by Bill Murray View Post
    Thanks, Tom. I'll do that.

    For some applications, I could resort the comma delimited list, but this is one where the order isn't sortable without a lot of work.

    IT is not a bug. the xdialog listbox does not always makes the last entry selected the top of the list. This is intentional. It allows you to know what entry in the list has focus.

    The solution to your problem, howwever is trivial.

    To convert the list returned by the listbox into the order you want, just add this code before you do your crlf_to_comma()



    DIM ORDERlIST AS C
    ORDERlIST = word_in_common(TEMP_LIST,vIncludeTypes,CRLF())


    this will sort 'vIncludeTypes' into the order defined by 'temp_list'

  5. #5
    Member
    Real Name
    Bill Murray
    Join Date
    Jun 2009
    Location
    Great Falls, VA
    Posts
    42

    Default Re: Unexpected list processing results in Xdialog

    Thanks for the very prompt response, Selwyn, both here & via email.

    You're 100% right: that simple code addition solved my problem. The "focus" issue has no importance for me, but I can imagine it might for others.

  6. #6
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,311

    Default Re: Unexpected list processing results in Xdialog

    Selwyn, thanks for the information and the solution.

    Your description of the standard behavior of the control and the solution in cases like Bill's would be a useful addition to the documentation of the multi-select list box control in Alpha's help file.

Similar Threads

  1. Xdialog variable results question
    By grayfox5 in forum Alpha Five Version 9 - Desktop Applications
    Replies: 1
    Last Post: 11-18-2009, 05:56 PM
  2. Display List Box Results
    By kyosadls in forum Alpha Five Version 9 - Desktop Applications
    Replies: 20
    Last Post: 05-13-2009, 08:55 AM
  3. How to Populate List box from sql query results?
    By christobal in forum Alpha Five Version 8
    Replies: 0
    Last Post: 09-04-2007, 07:26 AM
  4. lookup - drop down list box results not correct
    By Rick Valenzuela in forum Alpha Five Version 6
    Replies: 3
    Last Post: 03-31-2005, 10:28 AM
  5. Xdialog results to a variable
    By crimmelcp in forum Alpha Five Version 5
    Replies: 1
    Last Post: 05-22-2004, 08:24 PM

Bookmarks

Posting Permissions

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