Alpha Video Training
Results 1 to 4 of 4

Thread: Use variable in Xdialog?

  1. #1
    Member
    Real Name
    Bill Warner
    Join Date
    Apr 2000
    Posts
    905

    Default Use variable in Xdialog?

    I have function (as an xdialog) that displays a list of choices. In the line the defines the width and number of rows:

    [%hv%.41,10chc^#in_list!lst_*];

    (where there are 10 rows in this example), I would like to replace the 10 with a variable, so I could prompt for the number of rows when running the function. (When developing an app, I start out with a few reports, and get more and more as time goes on. It would be nice to change the length of the list by simply changing the parameter in the function).

    Can this be done??

  2. #2
    "Certified" Alphaholic Scott Emerick's Avatar
    Real Name
    Scott Emerick
    Join Date
    Dec 2000
    Location
    Central Virginia/ North Carolina Border
    Posts
    2,154

    Default RE: Use variable in Xdialog?

    Bill,

    Yes you can by creating the dialog code before you actually run UI_DLG_Box()

    With out knowing your whole script I can only give you the edited version of it, but its something like this:

    DIM dlg as C
    DIM dlg_title as C
    DIM rows as N

    dlg_title = "Bills Dlg List Example"
    rows = 20 'gives you 20 rows in your list box
    Dlg = ""%str%
    ;
    This is Bills list box;;
    %str%

    dlg = Dlg + chr(13) + "[%hv%.41," + rows + "chc^#in_list!lst_*];;;" + ""*12,1OK!OK" "12,1Cancel!CANCEL""

    Bills_dlg = ui_dlg_box(dlg_title,dlg)

    Hope this helps ..

    Scott

  3. #3
    Former Alpha Employee JerryBrightbill's Avatar
    Real Name
    Jerry Brightbill
    Join Date
    Apr 2000
    Posts
    5,171

    Default RE: Use variable in Xdialog?

    Bill

    There are two simple ways. While you can't use a variable directly in the code, dlg code is just a text string. You can use include to add text to the dlg code or stritran() to replace the text in the dlg code. Either of the following will work

    lines = "20"
    line = "[%hv%.41,"+lines+"chc^#in_list!lst_*];"


    dlg_code = ""%dlg%
    ...some xdialog code
    {include=line}
    ... more code
    %dlg%

    Or you can do this

    lines = "20"

    dlg_code = ""%dlg%
    ...some xdialog code
    [%hv%.41,__line__chc^#in_list!lst_*];
    ... more code
    %dlg%

    dlg_code = stritran(dlg_code,"__line__",lines)

    to run the code

    ui_dlg_box("title",dlg_code)

    Scott's method is essentially the same, however I like to use stritran() since it is easy to create dlg code with multiple "variables" and replace then with real values using multiple stritran() lines. I can also create one dlg code string and then run it more than once with different variable values or create the code first and then get the variable value later in the script.

    I have run some tests and there doesn't appear to be any difference in speed between any of the methods shown.

    Jerry

  4. #4
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,590

    Default Re: Use variable in Xdialog?

    I am bumping this because it was so hard to find! And 10 yrs old no less...
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

Similar Threads

  1. Show/hide variable in XDialog
    By Jay Talbott in forum Alpha Five Version 5
    Replies: 2
    Last Post: 07-12-2005, 02:00 AM
  2. Use variable in Xdialog?
    By Bill Warner in forum Alpha Five Version 6
    Replies: 6
    Last Post: 12-04-2004, 01:08 PM
  3. Xdialog results to a variable
    By crimmelcp in forum Alpha Five Version 5
    Replies: 1
    Last Post: 05-22-2004, 07:24 PM
  4. Extract xdialog variable
    By Peter.Greulich in forum Alpha Five Version 5
    Replies: 11
    Last Post: 05-04-2004, 06:54 AM
  5. Text (and/or variable) on toolbar with Xdialog
    By Tom Mills in forum Alpha Five Version 5
    Replies: 16
    Last Post: 03-07-2003, 10:52 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
  •