New call-to-action
Results 1 to 4 of 4

Thread: Use variable in Xdialog?

  1. #1
    Real Name
    Bill Warner
    Join Date
    Apr 2000

    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:


    (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
    Central Virginia/ North Carolina Border

    Default RE: Use variable in Xdialog?


    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;;

    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 ..


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

    Default RE: Use variable in Xdialog?


    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
    ... more code

    Or you can do this

    lines = "20"

    dlg_code = ""%dlg%
    ...some xdialog code
    ... more code

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

    to run the 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.


  4. #4
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Join Date
    Mar 2006
    Los Angeles

    Default Re: Use variable in Xdialog?

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

    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


Posting Permissions

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