Alpha Video Training
Results 1 to 2 of 2

Thread: Xdialog results to a variable

  1. #1
    "Certified" Alphaholic
    Real Name
    Charlie Crimmel
    Join Date
    Apr 2000
    Location
    West Virginia
    Posts
    1,695

    Default Xdialog results to a variable

    Jerry:
    I am trying to write the results of the xdialog selected column to a variable and use trace writeln to view
    Then I want to fill a memo field in a table with the selected items

    Any help would be appreciated

    Charlie Crimmel



    'Date Created: 18-Aug-2002 08:21:19 AM
    'Last Updated: 22-May-2004 08:10:18 AM
    'Created By :
    'Updated By :
    'The following example displays a dialog with two list boxes,
    'Available Cities' and 'Selected Cities'.
    'The buttons on the dialog allow the user to select from the list of available cities and
    'place them in the selected cities list. The Up and Down buttons allow the user to change the
    'order of the cities in the list.
    'The script makes extensive use of dialog box events.

    dim global var-"list1 as c
    dim global var-"vmarketid as n
    dim global var-"vmarket as c
    var-"list1=""
    var-"vmarketid=0
    var-"vmarket=""

    list1 = "Boston,New York,Chicago,London,Cape Town,Sydney,Toronto,Los Angeles,Tokyo,Johannesburg,Bulawayo,"
    list1 = stritran(list1,",",crlf())
    dim a_list1[100] as c
    a_list1.initialize(list1)
    a_list1.sort("ab")
    dim a_list2[100] as c
    dim list1_selected as n
    dim list2_selected as n
    list1_selected = 1
    list2_selected = 1
    flag_add = .t.
    flag_remove = .f.

    ui_dlg_box("Market Sectors",""%a%
    {region0}
    Select the market sectors you would like to add to this record.;
    Choose the sectors in the order in which you would like to import them.;
    {region1}
    {lf};
    {region2}
    Available Market Sectors;
    [.25,15list1_selected^#a_list1];
    {endregion2}|
    {region20}{sp};{endregion20}|
    {region3}
    {lf};
    {lf};
    {lf};
    "15Add?flag_add";
    "15Add all?flag_add" ;
    "15Remove?flag_remove";
    "15Remove all?flag_remove"
    {endregion3}|
    {region20}{sp};{endregion20}|
    {region4}
    Selected Market Sectors;
    [.25,15list2_selected^#a_list2] ;
    {text=20text1};
    {text=20text_prev};
    "10Up?flag_remove" "10Down?flag_remove"
    {endregion4}

    {endregion1}
    {endregion0}
    |
    {region5}
    "15&OK";
    "15&Cancel"
    {endregion5}
    %a%,""%b%


    if a_dlg_button = "Add" then

    a_dlg_button = ""
    if list1_selected " 0 then
    first_empty_on_list2 = a_list2.first_empty()
    a_list2[first_empty_on_list2] = a_list1[list1_selected]
    a_list1.delete(list1_selected,1)
    list2_selected = first_empty_on_list2
    'after adding an entry, move the focus up to previous city,
    'unless you were already on the first city.
    if a_list1[list1_selected] = "" .and. list1_selected " 1 then
    list1_selected = list1_selected-1
    else
    list1_selected = list1_selected
    end if

    'turn on the Remove flags
    flag_remove = .t.

    'if there are no more entries in list1, turn off Add flags
    if a_list1[list1_selected] = "" then
    flag_add = .f.
    end if
    end if

    end if

    if a_dlg_button = "Remove" then
    a_dlg_button = ""
    if list2_selected " 0 then
    first_empty_on_list1 = a_list1.first_empty()
    value_to_remove = a_list2[list2_selected]
    a_list1[first_empty_on_list1] = a_list2[list2_selected]
    a_list2.delete(list2_selected,1)
    a_list1.sort("ab")
    list1_selected = a_list1.find(value_to_remove)
    if list2_selected " 1 then
    list2_selected = list2_selected-1
    else
    list2_selected = 1
    end if
    if a_list2[list2_selected] = "" then
    flag_remove = .f.
    end if
    flag_add = .t.
    end if
    end if

    if a_dlg_button = "Up" then

    a_dlg_button = ""
    if list2_selected "" 1 then
    a_list2.move(list2_selected,list2_selected-1)
    list2_selected = list2_selected - 1
    end if
    End if

    if a_dlg_button = "Down" then
    a_dlg_button = ""
    if list2_selected " a_list2.first_empty()-1 then
    a_list2.move(list2_selected,list2_selected+1)
    list2_selected = list2_selected + 1
    end if

    end if

    If a_dlg_button = "Add all" then
    a_dlg_button = ""
    tempstring = a_list2.dump("r")+a_list1.dump("r")
    a_list2.clear()
    a_list2.initialize(tempstring)
    a_list1.clear()
    list2_selected = 1
    flag_remove = .t.
    flag_add = .f.

    end if

    If a_dlg_button = "Remove all" then
    a_dlg_button = ""
    tempstring = a_list1.dump("r")+a_list2.dump("r")
    a_list2.clear()
    a_list1.initialize(tempstring)
    list1_selected = 1
    a_list1.sort("ab")
    flag_remove = .f.
    flag_add = .t.
    end if
    %b%)

  2. #2
    Member
    Real Name
    Trevor Sayers
    Join Date
    Jan 2004
    Posts
    118

    Default RE: Xdialog results to a variable

    Hi Charlie,

    not sure why you want to use trace writeln.

    If you pop the following line after the end of your code...

    ui_msg_box("Items selected",alltrim(a_list2.dump()))

    ...you'll get a dialog box showing you what was selected. You can set your memo field to the same value...
    ie to...
    alltrim(a_list2.dump())

    Regards,
    Trevor


    PS you probably know, but if you change your delimiters
    from
    ""%a% ... %a%
    and
    ""%b% ... %b%

    to
    ""%dlg% ... %dlg%
    and especially
    ""%code% ... %code%
    ...for your code, A5 can format your code for you so it's easier to read.

Similar Threads

  1. Use variable in Xdialog?
    By Bill Warner in forum Alpha Five Version 5
    Replies: 3
    Last Post: 11-04-2014, 07:17 PM
  2. Use variable in Xdialog?
    By Bill Warner in forum Alpha Five Version 6
    Replies: 6
    Last Post: 12-04-2004, 02:08 PM
  3. Extract xdialog variable
    By Peter.Greulich in forum Alpha Five Version 5
    Replies: 11
    Last Post: 05-04-2004, 07:54 AM
  4. Text (and/or variable) on toolbar with Xdialog
    By Tom Mills in forum Alpha Five Version 5
    Replies: 16
    Last Post: 03-07-2003, 11:52 AM
  5. Using multi-select Xdialog variable
    By Scott Emerick in forum Alpha Five Version 5
    Replies: 4
    Last Post: 11-27-2002, 05:29 AM

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
  •