Alpha Video Training
Results 1 to 6 of 6

Thread: UDF Variables

  1. #1
    VAR davej's Avatar
    Real Name
    Dave Jampole
    Join Date
    Apr 2000
    Location
    Haughton, LA ( just east of Shreveport, Louisiana)
    Posts
    2,524

    Default UDF Variables

    This is my first UDF. I wanted to display a list of variables (global, session & local) during the design and testing of an application. This function (aptly named Variables) lists all variables to help resolve confusion or to just satisfy curiosity.

    I have placed it on the Form View System Toolbar, but it could equally be placed on a specific form.

    '-----start UDF Variables
    'Date Created: 11-Feb-2005 10:13:18 AM
    'Last Updated: 11-Feb-2005 10:13:18 AM
    'Created By : Dave Jampole
    'Updated By : Dave Jampole
    FUNCTION Variables AS C ( )
    dim g as P
    dim s as P
    dim l as P
    dim listg as C
    dim lists as C
    dim listl as C
    dim to_showg as C
    dim to_shows as C
    dim to_showl as C

    ' get pointers to global, session & local variables
    g = global_variables()
    s = session_variables()
    l = local_variables()
    ' build CR-LF delimited lists of global, session & local variables
    listg = variables_enum(g)
    lists = variables_enum(s)
    listl = variables_enum(l)
    ' build lists containing variable name, type, and value
    to_showg = *for_each(var, " "+var + "|" + typeof(eval(var)) + "|" + eval(var), listg)
    to_shows = *for_each(var, " "+var + "|" + typeof(eval(var)) + "|" + eval(var), lists)
    to_showl = *for_each(var, " "+var + "|" + typeof(eval(var)) + "|" + eval(var), listl)
    ' combines global, session & local variables into one list
    to_show ="Global Variables"+CRLF()+to_showg+CRLF()+ "Session Variables"+CRLF()+to_shows+CRLF()+ "Local Variables"+CRLF()+to_showl+CRLF()

    ' show the list
    ui_msg_box("Variables",to_show)
    END FUNCTION

    '-----end UDF Variables

    If anyone sees how or where this can be improved, I'd appreciate it.

    Dave

  2. #2
    VAR davej's Avatar
    Real Name
    Dave Jampole
    Join Date
    Apr 2000
    Location
    Haughton, LA ( just east of Shreveport, Louisiana)
    Posts
    2,524

    Default RE: UDF Variables

    Here's a slight modification to the UDF Variables. Thanks to Steve Workings for the formatting and dialog box display:

    'Date Created: 11-Feb-2005 10:13:18 AM
    'Last Updated: 11-Feb-2005 11:08:55 AM
    'Created By : Dave Jampole
    'Updated By : Dave Jampole
    'Dialog box display & column formatting: Steve Workings
    FUNCTION Variables AS C ( )
    dim g as P
    dim s as P
    dim l as P
    dim listg as C
    dim lists as C
    dim listl as C
    dim to_showg as C
    dim to_shows as C
    dim to_showl as C

    ' get pointers to global, session & local variables
    g = global_variables()
    s = session_variables()
    l = local_variables()
    ' build CR-LF delimited lists of global, session & local variables
    listg = variables_enum(g)
    lists = variables_enum(s)
    listl = variables_enum(l)
    ' build lists containing variable name, type, and value
    to_showg = *for_each(var, " "+var +"{T=1.9}"+ typeof(eval(var)) +"{T=2.1}"+ eval(var), lists)
    to_showl = *for_each(var, " "+var +"{T=1.9}"+ typeof(eval(var)) +"{T=2.1}"+ eval(var), listl)
    ' combines global, session & local variables into one list
    to_show ="Global Variables"+CRLF()+to_showg+CRLF()+ "Session Variables"+CRLF()+to_shows+CRLF()+ "Local Variables"+CRLF()+to_showl+CRLF()

    ' show the list
    'ui_msg_box("Variables",to_show)
    ui_dlg_box("Global, Session & Local Variables",""%dlg%
    [%O={@@}%.95,40one_var^#to_show];
    {ymargin=2,2}
    {xmargin=2,2}
    ;
    "*15&OK"
    %dlg%)
    END FUNCTION

  3. #3
    "Certified" Alphaholic
    Real Name
    Cal Locklin
    Join Date
    Mar 2000
    Location
    S.E. Michigan
    Posts
    5,763

    Default RE: UDF Variables

    I ran into a lot of long CRLF() strings in my variables so
    I've attached a revision that cleans up the output display and allows a choice of showing the full crlf string or just the first line.

    It also allows you to export the list to a text file but the alignment of columns isn't very good unless you set your default .txt file viewer to something better than Notepad and set your tabs manually.

    Some of the lines of code got rather long so I attached it as a txt file to avoid wrapping issues.

    Cal Locklin
    www.aimsdc.net

  4. #4
    VAR davej's Avatar
    Real Name
    Dave Jampole
    Join Date
    Apr 2000
    Location
    Haughton, LA ( just east of Shreveport, Louisiana)
    Posts
    2,524

    Default RE: UDF Variables

    Cal,

    Thanks, your mod looks good. I'll try to disect it to get my head around what and how you did it.

    Dave

  5. #5
    Member Jerry Gray's Avatar
    Real Name
    Jerry Gray
    Join Date
    Aug 2004
    Location
    Biloxi, MS
    Posts
    482

    Default RE: UDF Variables

    Thanks guys, I will use it frequently.

    Jerry Gray

  6. #6
    VAR davej's Avatar
    Real Name
    Dave Jampole
    Join Date
    Apr 2000
    Location
    Haughton, LA ( just east of Shreveport, Louisiana)
    Posts
    2,524

    Default RE: UDF Variables

    We gotta' quit working these ungodly hours!

Similar Threads

  1. Variables
    By Al Lenkner in forum Alpha Five Version 6
    Replies: 2
    Last Post: 09-16-2004, 11:41 AM
  2. variables
    By Ian_Edwards in forum Alpha Five Version 6
    Replies: 6
    Last Post: 08-13-2004, 06:51 AM
  3. Dot variables
    By John Marrone in forum Alpha Five Version 5
    Replies: 7
    Last Post: 11-07-2003, 01:00 AM
  4. A5 Variables vs A4
    By tadraw in forum Alpha Five Version 5
    Replies: 2
    Last Post: 05-24-2003, 09:05 AM
  5. Variables variables global, session or layout?
    By Greg Fong in forum Alpha Five Version 4
    Replies: 4
    Last Post: 07-11-2001, 03:54 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
  •