Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Timing issue?: Field data OK, but other dynamic attributes (form objects) based on calc. fields not 100% displayed correctly.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Timing issue?: Field data OK, but other dynamic attributes (form objects) based on calc. fields not 100% displayed correctly.

    They're USUALLY displayed correctly (not ALWAYS) and it's driving me insane lol.....
    I've tried everything I can think of and struggled with this problem (on the side-burner) since last winter.....
    All tables are indexed properly etc. (dbf's) ~ This occurs occasionally with a seemingly "unanticipated yet predictable frequency."
    (Open the form and access the same record data twice... One time it happens, and the next time it doesn't.)
    The objects which SOMETIMES don't always display 100% correctly (with the proper attributes, color etc.) are dynamically based on "calculated summary fields".
    Ironically, ALL the data in ALL the fields both on the form and in the browses (based on these SAME calculated summary fields) is ALWAYS "to the penny" correct....

    These "attribute miss-draws" are almost random.....
    Some of the objects attributes (on this same form) occasionally without any recognizable pattern fail to display properly (color/font attributes etc.) And if/when they don't display properly: All I have to do is move up/down in the browse and it's fixed. (It doesn't appear to be related to a "first/last object in browse with initial focus" issue either. ~ I'm familiar with that "anomaly.")

    Regardless: Whether these objects show or don't show the dynamic attributes properly: Every bit of data (field and browse cells) on this form are correctly calculated and displayed! (Again, based on the exact same calculated field data.) ~ So what is going on?

    FWIW: The form updates all the data and the display quickly. ("Lightening fast" if I had to describe it!) ~ Especially given there are at present ~2000 child/indexed records from which these calculated fields are generated) So with the exception of this anomaly, the form appears to be working efficiently....

    I've gone as far as to write a function that reassigns the correct attributes using the same calculated fields data (attached it to a button "onPush" event) which confirms both the data and logic is good.
    I've attached this function to every event imaginable but it's like putting the cart in front of the horse I think. The only way I have achieve correct screen painting s to add WAIT_UNTIL(.T.=.F.,1,1), and I've also tried several other XB "wait function" variations to no avail. (Using the "WAIT_UNTIL" solution, I fear that as the data set grows, the wait must grow also or fail. ~ One thought I had was some other wait condition other than waiting a fixed period of time, or until .T. = .F. lol.....)

    I've also tried all the other XBASIC_WAIT_UNTIL() type functions. I can find... I've looked for object properties/methods etc, but found nothing. (Even browse through all the a5_ and a5. methods etc.) Ironically, I do know that if this was field data, it would be relatively easy to correct with a refresh command. (Which reminds me of one other significant consideration): With the IW session properly set, it's impossible to correctly refresh/repaint the display attributes using any "refresh/repaint type" xBasic commands I'm aware of. (unlike field data/RTF fields which are/is easy to correct) So it appears as if the object attributes (unlike the field values) are not always getting/seeing the correct/finalized calculated field data. From the IW, the only way to correct the display data is to call the function I wrote which sets each field attribute individually.

    At present (not liking the "WAIT_UNTIL(.T.=F.1,1) which requires a "fixed one second period of waiting" (which may fail with growing data sets) I've resorted to calling the function on an "onTimer" event set to trigger every 2 seconds. (FWIW: At present with 2,000 detail records the WAIT_UNTIL solution seems to work.)

    Because of the actual data displaying correctly, this doesn't appear to be a table size .dbf issue....
    I've been dealing with this oddity for months. None of the normal stuff seems to address this problem.....
    Is there some way to force Alpha to "flag" these dynamic attribute fields as "dirty" before calling a repaint/refresh/redraw function etc? ~ If so, I can't find it.

    PS:
    After asking for help here/writing this..... I'm wondering whether some type of form based fetch commands (on the underlying child table) could possibly address this too? Spent countless hours (on the side) trying everything else I could think of.
    Last edited by SNusa; 01-26-2016, 03:35 PM.
    Robert T. ~ "I enjoy manipulating data... just not my data."
    It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
    RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

    #2
    Re: Timing issue?: Field data OK, but other dynamic attributes (form objects) based on calc. fields not 100% displayed correc

    If the calc fields are in the table, presumably you know that table calc fields are only recalculated when the table is changed and saved.
    Having summary fields on a form that have to re-summarize every time you fetch a record sounds like a heck of a load!!
    Cole Custom Programming - Terrell, Texas
    972 524 8714
    [email protected]

    ____________________
    "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

    Comment


      #3
      Re: Timing issue?: Field data OK, but other dynamic attributes (form objects) based on calc. fields not 100% displayed correc

      Hi Martin....
      No, the calc fields are "static" when this happens.... Nothing is changing with the stored data in the tables. Only the child record (not the parent record) changes which forces the recalc. of the calculated form fields.

      The actual data in the fields and browse records (derived from these calculated fields) are all good. It's only the dynamic properties (like border, button fill color and text color) that are not respecting the new values that are calculated when moving to a different record. (This "color coding" of objects is for visual cues to the user that certain records have qualified for user intervention.)

      It's almost like the RTF field refresh issue.... Sometimes RTF fields (which I seldom use) are not updated with new values and you have to force a refresh on the field.
      But there is no refresh/repaint/recalc/resynch function/method I can find that does the same thing for these objects properties. (Or a wait function to make sure all the recalc's have finished calculating before the objects dynamic properties are updated.) It seems that once these fields "decide they have the correct values to work with, the properties are updated and that's that." And the only way to correct it is to move to another record and back to "try again." Besides that..... THE ONLY way I have found to guarantee ALL the colors etc. are displayed/drawn correctly (for all the objects) is to use a function that reads the data back out of the fields (which are correct) and reassign the objects color properties. (As mentioned above, moving off and back to another child record USUALLY fixes this too. (So I could possibly force a down/up on the browse, but there's not always multiple records in the browse either.)

      Notes:
      These color attributes (and fields which are totaling correctly) are based a calculated form field which is derived from a calculated field. (see below)
      The problem only occurs maybe 20% of the time. And when it does, it doesn't effect all the dynamic objects, only some of them! (and not all of the properties either!)
      When I first realized this was an issue I was using the a5 built-in dynamic conditional object builder. I then wrote a gobal function to draw the fields (based on the calc. field data) and tried that on numerous different events etc instead. The same problem occurred unless I added the wait function. Although the function works fine when manually triggered, turns out the results were actually worse when placing it in the different events to automate it's usage. Adding the WAIT_UNTIL(.T.=.F.,1,1) function was necessary to get it "as good as the other way." And ultimately that's why I'm thinking it's a timing issue ..... The function works fine 100% of the time for 100% of the objects and their properties whenever it is manually triggered with a button onPush, and it works with the onTimer event too. (Presumably because it's set to at least a second, and it runs "perpetually". ~ if it doesn't have the right data the first time, it does have it a second later)

      FORM CALC FIELDS:
      Code:
      [COLOR="#0000CD"]cn_CombinedFobYearlyProgPoints[/COLOR] = total(calc->cn_FobYearProgPoints,grp->customers_tbl,grp->keyfobs_tbl) 'CALC FIELD #1
      
      [COLOR="#FF0000"]cn_Award3Distance[/COLOR] = ([COLOR="#0000CD"]calc->cn_CombinedFobYearlyProgPoints[/COLOR] - session_variables(this.sessionhandle()).vp_ProgArray[vp_ProgArray.find(val(session_variables(this.sessionhandle()).vc_Year),"Ryear")].award3qual) 'CALC FIELD #2 (derived from CALC FIELD #1 above
      I know that second calc field is a "whopper" in terms of it's "concatenated complexity" but it sure does the trick!
      (It took quite a while for me to figure out how to extract that "threshold data." ~ Because both the array size and the actual years in the Ryear field differ at times.)

      Number in red is displayed correctly in all the fields, but this same value (cn_CombinedFobYearlyProgPoints) is also the basis upon which the dynamic color properties (attributes) of buttons on the form are conditionally displayed.
      Last edited by SNusa; 01-27-2016, 01:14 PM.
      Robert T. ~ "I enjoy manipulating data... just not my data."
      It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
      RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

      Comment


        #4
        Re: Timing issue?: Field data OK, but other dynamic attributes (form objects) based on calc. fields not 100% displayed correc

        Should have first specified: The problem I'm having is with "Calculated Values" (on forms).... Not "Calculated Fields" (in tables)

        Unlike RTF fields and dynamic object attributes: I'm beginning to wonder whether data in fields (which includes data in browse cells) is "constantly looking" for changes and responding/updating accordingly. If this is the case, I would thing there should be a way to flag a specific object's dynamic content as dirty which could/would in turn force an update of all the objects dynamic properties (based on new data)

        I had been looking into calculated field functions/methods but found little......
        I came across calculated_fields_reset() (in the XBE I think), but can't find any documentation on it.
        Nor could I find any function/method to force a "resync" (set dirty?, recalc?) of an objects dynamic properties which might be used with a refresh or repaint etc.....
        ~And maybe even the RTF fields (when based on calculated field data) can't be "force refreshed"/also has this same issue? I haven't tried that.

        And just maybe I can force an update somehow (of the second calculated field) via combining a CALCULATED_FIELD_SET() Function with a CALCULATED_FIELD_GET()?
        (which might trigger a refresh of the objects dynamic properties?)
        That didn't work.....
        You can read the value of the calculated value with CALCULATED_FIELD_GET() but CALCULATED_FIELD_SET() doesn't set a value, it actually creates a calculated field....
        Last edited by SNusa; 01-27-2016, 06:12 PM.
        Robert T. ~ "I enjoy manipulating data... just not my data."
        It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
        RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

        Comment


          #5
          Re: Timing issue?: Field data OK, but other dynamic attributes (form objects) based on calc. fields not 100% displayed correc

          So Rob, if the values are correct, but the colour and borders are going wonky, would Conditional Objects be better?

          Any chance of a small sample Db and Form showing the problem?
          See our Hybrid Option here;
          https://hybridapps.example-software.com/


          Apologies to anyone I haven't managed to upset yet.
          You are held in a queue and I will get to you soon.

          Comment


            #6
            Re: Timing issue?: Field data OK, but other dynamic attributes (form objects) based on calc. fields not 100% displayed correc

            Hi Ted;
            I'll see what I can "pack up" to send you lol.... And yes, maybe conditional objects might have been a viable solution. (Xbasic makes every object "conditional", so I've never used them lol.) I'm spending one more day on this... I'm 90% sure the problem is the calculated fields and an a5 internal timing. (The a5 "engine" seems to assume the calculations are done before they actually are, and then uses that incorrect partial summary value for processing the objects dynamic properties.) Adding the WAIT_UNTIL(.T.=.F.,1,1) puts a band-aid on it. (As does the form OnTimer event which is always "looking" at the values and repeatedly updating the object properties while the form is in focus.) Presently, I'm coding a work around for "first record in browse event triggering anomaly" that persists in the desktop browse object. (Yep, I'm a perfectionist at times, AAArrrggghhh!)
            Last edited by SNusa; 01-29-2016, 01:04 AM.
            Robert T. ~ "I enjoy manipulating data... just not my data."
            It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
            RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

            Comment


              #7
              Re: Timing issue?: Field data OK, but other dynamic attributes (form objects) based on calc. fields not 100% displayed correc

              What appears to be missing is an <object>.dynamic_property_refresh() method. None of the object "refresh" (or resynch methods for that matter) have any influence on objects properties which are dynamically set with calculated form values that change. Once the are set, that's it. (Unlike calculated fields in a table which can be "tricked into causing a field refresh on a form via a table enter_begin and enter_end. ~ For more info on this, search for "object events" in the new help system.)

              Moving forward: I have some info to share (when using calculated values) which may be helpful to others.....
              When dealing with actual data fields, they can always be updated successfully by attaching the <parentform>.resynch() method to the appropriate events. (no big surprises here)
              However: if you have a two calculated values (both defined using the xy button) and the second one is dependent upon the first value...... You may have to use <parentform>.resynch() twice!
              (Place two lines of <form>.resynch() codes one right below/after the other one. Apparently, the second time you "resynch()", the second calculated field receives the correct/finalized amount from the first one.)

              Optionally/alternatively, you you might want to use <object>.REFRESH_LAYOUT().
              Note: The help documentation is rather confusing as it implies this command does not resynch. However, watching the script recorder indicates that .refresh_layout() is the same thing as .resynch()!

              RTF fields are similar, in that they can also be "refreshed" following a ".resynch()" (method as described above). ~ Either individually, or all at the same time by using <parentform>.Refresh_Fields().

              Now for the bad news (with a solution):
              Unless I've missed something, dynamically assigned object properties can/do suffer from a timing issue. And if they don't resolve properly (ie: you're using dbsum() on tables with thousands of records etc....) You will likely run into problems as the the a5 engine resolves these properties before the calculations have fully competed. (And yes, conditional objects also suffer from this same timing problems. ~ Actually they fared just as poorly, and in some ways, actually worse/less predictable.)

              The only solution I could find to guarantee dynamically calculated object properties are displayed correctly was:
              To write a function (which assigns these property attributes based on calculations), and then call the function using the layout's "onTimer" event. (Which runs in the background every few seconds etc....) ~ Fortunately this problem typically won't result in field data being incorrect if the form designed properly.) And you can "get around this" so as long as you don't mind a background process playing "catch-up" (continually running in the background) as it updates the object properties every few seconds.

              Of course you can also choose to NOT use any dynamically displayed object attributes based on changing values etc. But I'm a big believer in "visual display cues." (Especially on "busy data screens" in a retail environments. So I spent a considerable amount of time on this.) Also (because the two were closely related), I think I found a workaround for the browse events which fail to always "fire" as expected. (Kind of amazed I have the browse working this nicely!)

              PS: If you're using calculated values within layouts, it's extremely beneficial to reference as many fields as possible via their .text properties as opposed to their .value properties. Convert, or do whatever you must when reusing the data once you've accessed it via the calculated (xy) value. Because when you access a field on a form via it's .value property (a field that is based on a calculated value..... It needlessly seems to recalculate the value! Aside from slowing down the page, too many of these will break things. On a positive note: I am literally amazed at the speeds I have achieved, given all the table summary operations in use on my form. I've presently got 6,000+ records that are being filtered &/or subtotaled 8 different ways (dbsum, total etc.) via calculated values. ~ And it literally happens in a flash! (One second or less even when the filtered sets are 1/2 of the data/3000 records!)
              Last edited by SNusa; 02-04-2016, 04:03 AM.
              Robert T. ~ "I enjoy manipulating data... just not my data."
              It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
              RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

              Comment


                #8
                Re: Timing issue?: Field data OK, but other dynamic attributes (form objects) based on calc. fields not 100% displayed correc

                I have never had any issues with form calc fields
                I always just formcalc1.refresh(), formcalc2.refresh(), formcalc3.refresh
                you could put the refresh commands in the onfetch event of the form
                Cole Custom Programming - Terrell, Texas
                972 524 8714
                [email protected]

                ____________________
                "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

                Comment


                  #9
                  Re: Timing issue?: Field data OK, but other dynamic attributes (form objects) based on calc. fields not 100% displayed correc

                  I have had some issues with calc fields in the past. Usually had a ton of them and were depending on other caslc fields up to 5-6 deep.
                  Having said that, I have not had problems in recent versions. I don't know if some of it got better or because I took the heavy lifting to scripts and functions showing the results in variables on the form rather than calculated fields.
                  Dave Mason
                  [email protected]
                  Skype is dave.mason46

                  Comment


                    #10
                    Re: Timing issue?: Field data OK, but other dynamic attributes (form objects) based on calc. fields not 100% displayed correc

                    Hi guys;
                    First
                    @MartinCole: What I wish I could find (similar to the refresh you suggested) is a method like <form>.Refresh_Dynamic_Properties(). (Or <Object>.Dynamic_Property_Flag_Dirty and/or <Object>.Dynamic_Property_Reprocess() method.) ." ~ Rerefresh, resynch etc. does not check to see whether the underlying values used to dynamically assign object attributes are correct/"clean." (a way to force a5 to recheck an objects dynamic property value and see if they are based on correct values after they are drawn on screen.)

                    @DaveM: I'm working with calculated VALUES, not fields. (wording mistake I made in my initial post) More about this below, and why they can't be in functions for this usage. (Due to requirements, I actually have these calculated summary values placed in unbound fields in browses.)

                    I can use resynch, refresh, and repaint, refresh_layout, refresh_fields etc... trying to redraw these dynamically assigned object attributes until I'm blue in the face and nothing happens. ~ But manually assigning these same object properties (via a function or even via the IW window) using the same exact variables and code does update the display as expected.

                    Yes, it's very odd. There's a lot going on in this one form. And much of the data within the child table (which contains about 6000 records at present) is summed several different ways. (Multiple programs, multiple years, combined totals and a master summary etc.) I think this is just pushing/stressing the a5 .dbf a little. (DBF's because I wanted to make this a highly portable and package-able/easy-install desktop component.) Honestly: Until recently, I was concerned that the overhead of the large .dbf's might be too demanding on alpha's internal ".dbf engine." (Particularly because of the summary requirements.) But a5 seems to handle the load with a vengeance! (I'm sure a high end PC with SSd's is making a difference too!)

                    The calculated fields along with the refresh methods etc. work fine for displaying actual data in fields and in browses, but not RELIABLY for dynamically assigning object properties based on these calculated field totals. When I'm trying to use that calculated value data (based on dbsum's of large tables) to color/assign button attributes, button edges, and button background colors etc. is when the problem surfaces.) But because much of these calculated values are being displayed right within a browse... Taking the heavy lifting to a function is not feasibly feasible. (Calculated VALUES, not Fields.) Although the system seems very efficient, I think the problem lies in just too many buttons (12 buttons one per month) which have several properties dependent upon the calculated DBSUM summary fields. In the split second it takes to process the calculated fields, you can actually see the object properties change but not all of the buttons change "all the way" so I have to clean up afterwards.

                    PS: To give everyone an "idea" of how efficient this form is/is not functioning... I suspect this layout will continue to work reasonably with with child table sizes beyond 25,000 records. Also, interestingly enough, out of all the dynamically assigned (x12 buttons) attributes (border, fill, font, text color & text displayed): Text displayed in these buttons is always right. it's the coloring that isn't! I will spend more time with conditional objects down the road in combination with some of the tricks I've used to see whether I can get them working better. (I didn't do a lot of testing with them.)
                    Last edited by SNusa; 02-04-2016, 07:59 PM.
                    Robert T. ~ "I enjoy manipulating data... just not my data."
                    It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
                    RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

                    Comment


                      #11
                      Re: Timing issue?: Field data OK, but other dynamic attributes (form objects) based on calc. fields not 100% displayed correc

                      Robert,
                      Not trying to beat on you at all or start a pure old argument.
                      Can you possibly give an example of a calculation that HAS to be done in a calc field. The reason I ask is that I have clients that have record counts from 10,000 to 950,000 with very explicit calculations that have to be to a penny exact with hundreds of calculations to get there. Almost all of these are done in functions by way of scripts.

                      An example may help me(and others) understand so we can help you better to get past the issue.

                      After thought: Do you have calc fields with abnomally long character counts, like over 1024 spaces, letters and numbers? I don't remember off hand the max before stuff gets dropped.
                      Last edited by DaveM; 02-04-2016, 11:48 PM.
                      Dave Mason
                      [email protected]
                      Skype is dave.mason46

                      Comment


                        #12
                        Re: Timing issue?: Field data OK, but other dynamic attributes (form objects) based on calc. fields not 100% displayed correc

                        As for the calc. values: They are not long (see below) and the only thing that is strange is the way the 3'rd calculated values uses an array search function to "find" the correct array value right within the calculated value expression. (It searches an array whis is "pre-loaded" on form init, and has session level scope. ~ See 3'rd calc. value below) Layout is essentially comprised of 3 tables. (And the middle table browse has 3 calc. field columns derived from calculated & indexed dbsums right in the browse fields.)..... I'm not re-using any of these subtotaled values from fields (inside or outside the browse) in the calculated value expressions either. (This form's middle browse also subtotals these columns below/outside the browse.) All calculated values are derived "internally" in the correct sequence.

                        Here are the 3 "related" calculated values presumably responsible for the "anomaly." It's the third one (in red) which is what the values of the "dynamic button attributes" are based upon which calculates fine, but not immediately. (In essence, I am totaling the values of a dbsum calculated field (much like one would use the value of an invoice subtotal), and then using that value (the middle expression below) in the 3'rd calculated value. It's the 3'rd value (in red) that is causing the problem. I am subtracting the correct array values (found in the array) from this total value and either it's <= 0, or it's > 0.... (The condition upon which the buttons' dynamic properties/attributes are set.) The second calculated value totals correctly without intervention. And does the third one. But you can't count on these values being "ready" (in time) for the dynamic object properties to properly evaluate/use the expression & condition (cn_Award1Distance >= 0 etc.) to assign the object's dynamic properties correctly all of the time. (That takes a function placed within the on_Timer event.) Again, if it weren't for the coloring issue, none of this would be necessary.

                        Code:
                        [COLOR="#0000FF"]cn_FobYearProgPoints[/COLOR] = dbsum("points_tbl","C_Kper__",alltrim(Keyfobs_tbl->Keyfob)+chr(47)+Var->vc_ProgramID+chr(47)+Var->vc_Year,"POINTS")
                        cn_CombinedFobYearlyProgPoints = total(calc->[COLOR="#0000FF"]cn_FobYearProgPoints[/COLOR],grp->customers_tbl,grp->keyfobs_tbl)
                        [COLOR="#FF0000"]cn_Award1Distance[/COLOR] = (calc->[COLOR="#0000FF"]cn_CombinedFobYearlyProgPoints[/COLOR]-session_variables(this.sessionhandle()).vp_ProgArray[vp_ProgArray.find(val(session_variables(this.sessionhandle()).vc_Year),"Ryear")].award1qual)
                        On a very interesting note: One of the browses has a button which opens up a modal form. This form also uses the same data (of the calling form) to dynamically assign attributes to fields and also buttons. I'm getting this data directly from the .text properties (fields on the calling form which display the values of the 3'rd calculated field.) ~ I use val(<object>.text) property having learned (while working within the original form) that using a the .value property of a form field derived from a calculated value (in some instances such as while while displaying dynamic data in a RTF object using the calculated value in the equation) results in a tremendous amount of overhead when all the calc. fields were being "re-calc'ed" unnecessarily. (It even broke the browse on large subtotals. ~ Made it act similar to when the parent only browse setting is not used on browse settings..... ghosting data in cells etc.) So apparently, the .value property causes a total "recalc" of calculated values at times, at least when you're working within the calling form itself/or when it has focus.) These FIELD totals are/were always right on both forms without needing the onTimer function running. So the ONLY purpose of the function is to enforce proper color coding...... Now back to my main point (sorry I got sidetracked): This modal form had full access to the correct calculated field values too, without ever needing the function running in the background. (When I disabled and/or set the onTimer event to run every 5 minutes, I could still open up this modal second form from the browse button and the object attributes were displayed correctly on the second form. And since these object attributes were based on the data in the underlying/calling form...... That's when I realized the function only was needed for dynamic attributes, and not for any of the field values. (And that it must either be a timing issue and/or field values are handled "internally" by the a5 engine far differently/with much greater attention) as object properties.

                        Anyways, without the "catch-up" function cleaning up the display "after the fact.": I'm left looking at two layouts both based on the exact same data from the exact same calculated values (all this data is only calculated once and then used again on a different layout (modal) via accessing object values (.text) and also session scope data from layout one via [x = session_variables(obj(vp_WindowSessionFocus.sc_RewardsMain_frmInstanceName).SESSIONHANDLE()).vc_Yearcalculated etc. on the second/modal layout screen]: And this second layout (modal) that opens up afterwards via form.viewqueried() is showing all the right data. (Another clue as to how dynamic object properties don't get the same treatment as actual field data.)

                        And that makes sense..... But there still should be some built in <Object>.Dynamic_Property_Reprocess() method to (re-assess) All I'd have to do is place this code where the other "refresh methods" are needed. ~ This gives me another idea. I wonder if I could write a function (not to run in the onTimer event) to check each object in a form, and look for a dynamic property attribute. (And if the object's "properties property" is set to dynamic..... I could try something like "<object>.dynamic.property = <object>.dynamic.property" or anything else to force a "re-draw?") Fortunately the "redraw overhead" is not sever running ever two seconds, because my "repaint function" first check to see if it is on "tab 2", and if not, it doesn't do anything else. (Actually I could also build a counter in, and make sure it stops "recalcing" (or maybe even set the onTimer form property itself to 0 after x amount of recalc.) ~ Just not the cleanest way.
                        Last edited by SNusa; 02-07-2016, 04:51 PM.
                        Robert T. ~ "I enjoy manipulating data... just not my data."
                        It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
                        RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

                        Comment


                          #13
                          Re: Timing issue?: Field data OK, but other dynamic attributes (form objects) based on calc. fields not 100% displayed correc

                          Robert,
                          Using scripts and functions - I sometimes use a script to call as many functions in order as necessary just to receive one value into a variable or field on a form/browse.
                          I have one script that runs 17 functions that need to be run in a certain order and returns 7 variables as answers that are shown on a form/browse.
                          The reason is that calculated fields in a form seemed to not always run in the order I needed and did not always wait for one to complete before another started.
                          V12 may work better, not sure. I started doing it this way back in v7.
                          I am pretty sure many others do this as well?
                          Dave Mason
                          [email protected]
                          Skype is dave.mason46

                          Comment


                            #14
                            Re: Timing issue?: Field data OK, but other dynamic attributes (form objects) based on calc. fields not 100% displayed correc

                            Interesting Dave.... Is this how you would go about using your method in a child browse? (And is this even what you are suggesting? Otherwise I am confused.)

                            1.) Add an unbound field to the browse.
                            2.) Edit the "Display Format", so as to assign/display a global function as the value to display, similar to this (for my needs): [ dbsum_fnc(this:Keyfob.text,vc_year) ] right there when defining ?
                            Note: Without the usage of the calculated fields, passing "this:Keyfob.text" to the global function above would be necessary to pass the value of each browse record. (Which is required for calculating the summary on that record in the browse.)

                            I can't think of any other way to attach a function's value to a browse, or how one might otherwise get around using calculated values. This got me thinking about something else slightly related: When Alpha is displaying calculated values in a browse, does it ONLY query the totals/values on the visible records? (And does it query the rest as you scroll down past the visible ones on the screen? ~ If so, that certainly explains the Get_Viewport_Row() function.) And this would also make a lot of sense with regards to overhead concerns. (Similar in nature to the way alpha DAO accesses X amount of SQL records.) Which reminds me...

                            Browse navigation via code: I thought I had found a way to obtain the count of records being displayed in a browse (child table) via: vp_Browse.Fetch_last() followed by a vp_Browse.GetViewport_Row(). Turns out that this only returns the number of rows visible in the layout. I know that this number is also obtainable from COMPUTE_FIELD_STATISTICS(<browse>.<field>), but that returns a lot of extra statistical data/overhead. Maybe it's not possible, but I would think there would be some way of getting Just the total count. If so, I can't find it.
                            Last edited by SNusa; 02-08-2016, 02:55 PM.
                            Robert T. ~ "I enjoy manipulating data... just not my data."
                            It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
                            RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

                            Comment


                              #15
                              Re: Timing issue?: Field data OK, but other dynamic attributes (form objects) based on calc. fields not 100% displayed correc

                              Field in table
                              variable
                              run function to gat variable value - fill the field with the variable value and it displays wherever you want browse/ form/ report.
                              Passing values to your udf is same as passing to alpha function, just depends how you build the UDF
                              2016-02-08_1801.png
                              Dave Mason
                              [email protected]
                              Skype is dave.mason46

                              Comment

                              Working...
                              X