Alpha Video Training
Results 1 to 3 of 3

Thread: Are UDF's Practically Useless in Calculated Fields?

  1. #1
    Member
    Real Name
    Steve Andrews
    Join Date
    Jan 2004
    Location
    Mahwah, NJ
    Posts
    644

    Default Are UDF's Practically Useless in Calculated Fields?

    I've seen many cases where complex, nested calculated fields (CF) do a lot of processing for a report. These same CFs get used in other reports, requiring duplication. For years, I have preferred to do the calculations in a UDF and access that from the reports. This way, the code is localized so that if rules change, I only need to make the change in one place. It also reduces the number of CFs.

    Since upgrading to V10, however, I've noticed an oddity. The UDF is well tested and runs stand-alone fine. However, while the CF which calls the UDF may work well, another one which uses that CF may show an error (that it cannot find a certain field). The line which shows up on the CF viewer happens to be a line within the UDF! It appears that when you call a UDF from a CF, all of the code from that UDF is substituted for that CF wherever it is used. This may be an optimization technique employed by Alpha - rather than using holders of values, just keep substituting entire expressions.

    The errors seem to be scope-related. But I've dimmed variables locally, placed "var->" onto them, etc. with no luck. My next try will be to use a variable for that initial call to the UDF and to make the call in the OnDetail script. Has anyone else run into this behavior? Is there any setting to turn this supposed optimization off? Thank you.

    Steve

  2. #2
    "Certified" Alphaholic DaveM's Avatar
    Real Name
    Dave Mason
    Join Date
    Jul 2000
    Location
    Hudson, FL
    Posts
    6,026

    Default Re: Are UDF's Practically Useless in Calculated Fields?

    Steve,

    I use udfs in calculated fields all the time and some are quite complex. For instance the pymt() functions in alpha are not correct to the car industry, so I had to write my own. These are used extensively in calculated fields. These udf's have to do some major, major math. The calculated fields have to be used in other calculated fields as well.
    Dave Mason
    dave@aldausa.com
    Skype is dave.mason46

  3. #3
    Volunteer Moderator
    Real Name
    Alan Buchholz
    Join Date
    Oct 2000
    Location
    Delavan, Wisconsin
    Posts
    9,628

    Default Re: Are UDF's Practically Useless in Calculated Fields?

    An example would help.
    Al Buchholz
    Bookwood Systems, LTD
    Weekly QReportBuilder Webinars Thursday 1 pm CST

    Occam's Razor - KISS
    Normalize till it hurts - De-normalize till it works.
    Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
    When we triage a problem it is much easier to read sample systems than to read a mind.

Similar Threads

  1. Scrolling completely useless
    By Don McElroy in forum Alpha Five Version 10 - Desktop Applications
    Replies: 23
    Last Post: 01-19-2013, 11:22 PM
  2. How to use DetailView fields in UDF?
    By eritovs in forum Application Server Version 10 - Web/Browser Applications
    Replies: 6
    Last Post: 10-27-2010, 06:37 AM
  3. Delete Useless Expressions?
    By dsears36 in forum Alpha Five Version 7
    Replies: 5
    Last Post: 03-22-2007, 05:26 PM
  4. Useless Dialog (aka Today's Humor)
    By George Pelkofer in forum Alpha Five Version 5
    Replies: 3
    Last Post: 03-02-2004, 10:17 AM
  5. Calculated Fields vs. Calculated Field Rule
    By Rhett Scott in forum Alpha Five Version 4
    Replies: 12
    Last Post: 07-07-2002, 05:58 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
  •