Very Hot Topic (More than 25 Replies) Unbound Field & On Form Change (Read 3132 times)
SpencerWulwick
Senior Member
Members
*****
Offline



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Unbound Field & On Form Change
Dec 30th, 2005 at 4:00am
Print Post Print Post  
Hi -

In  Version 1.1.3, according to the Change Log, "Unbound LEs no longer trigger Form changed warnings on closing" and that, indeed, is a blessing.

Are they; however, still creating a "form change" condition?

For example, I have a date of birth and age LE.  The date of birth is bound to a field and the Age LE is not ... it is a calculated LE on form entry (and in a few other instances); however all it does is calculate the age.

The on form entry programming is: 
Code
Select All
If not @isblank(Birthdate) then

     Age = @YEAR(@DATE)-@YEAR(BirthDate) - ((@MONTH(@DATE) < @MONTH(BirthDate))
     or (@MONTH(@DATE) = @MONTH(BirthDate) AND @DOM(@DATE) < @DOM(BirthDate)))
 



(By the way, please ignore - other than if it is relevant to my specific question - the age programming.  The reason I say this is that I have previously been told that it could not work and yet I have never found one single instance when it did not properly calculate the correct age).

(I see no other programmed "change" to the form except for the unbound Age LE (and, similarly an undboud  Years LE, based on an anniversary date)).

Then, in the Last Updated LE on form change I have:
Code
Select All
Last Updated = @date 



Unfortunately, if I am searching through a stack of records I noticed the following problem.

If the Birthdate LE is blank, I can advance to the next form, revert to the previous form and can verify that the Last Updated LE has not changed.

If on the other hand there is a birthdate, then when I advance and revert to the record which contained the birthdate, the last updated field value has been changed to the current date.

What am I overlooking and how can I fix this.  Naturally, I only want the last updated field to be changed when, in fact, I make a change to one or more of the bound LE's.

Thanks!
  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Unbound Field & On Form Change
Reply #1 - Dec 30th, 2005 at 1:55pm
Print Post Print Post  
Quote:
For example, I have a date of birth and age LE.  The date of birth is bound to a field and the Age LE is not ... it is a calculated LE on form entry (and in a few other instances); however all it does is calculate the age.

The on form entry programming is: 
Code
Select All
If not @isblank(Birthdate) then

     Age = @YEAR(@DATE)-@YEAR(BirthDate) - ((@MONTH(@DATE) < @MONTH(BirthDate))
     or (@MONTH(@DATE) = @MONTH(BirthDate) AND @DOM(@DATE) < @DOM(BirthDate)))
 



(By the way, please ignore - other than if it is relevant to my specific question - the age programming.  The reason I say this is that I have previously been told that it could not work and yet I have never found one single instance when it did not properly calculate the correct age).

I don't want to hiack your thread, but I can't ignore this because it looks like it will be very useful to some things I need to do.  But I'm having a bit of trouble parsing it.  What does the "or" condition look to and do?
  

**
Captain Infinity
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Unbound Field & On Form Change
Reply #2 - Dec 30th, 2005 at 2:19pm
Print Post Print Post  
Spencer,

The Form Change and Element Change events run whenever any value on the form is changed, even if it is unbound. Chaging only unbound elements will no longer trigger the Save warnings (as there is nothing to save), but it will still trigger the programming event. Otherwise, you could not do anything in response to changing an unbound element, such as selecting something from an unbound combo box.

The trick is to put the code in the events to which you actually want to respond. If you don't want the code to run when any element value changes, the code does not belong in the On Form Change event. It belongs in the On Element Change event of only those elements that "count" as far as you are concerned for this particular form.

Alternately, you may want to move the code that  calculates Age somewhere other than On Form Entry so it doesn't run just because you passed through on your way to another record.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
SpencerWulwick
Senior Member
Members
*****
Offline



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Re: Unbound Field & On Form Change
Reply #3 - Dec 30th, 2005 at 5:22pm
Print Post Print Post  
Erika -

The reason I put the age/years calculation in the on form entry is that I do want to see the correct age even if I am just looking at a form and I don't want to have to remember to click on a "button" (which I could easily put there) to calculate the age.  I sometimes do want to simply scan through a stack of records to check age.  (I also have it on the on the birthdate/anniversary elements exit event, so that it will automatically appear instantly, should I enter a birthdate or anniversary).  In that case I do want the last update field executed but only because I made a change to a bound element.

As for putting last update programming in "on element change" I have about 84 layout elements.  I want the last update field populated for all but nine of the elements (all of which are unbound).

If, as you suggested, I "put the code in the events to which I actually want to respond" I would have to program 75 of the 84 elements.  This is not the worst thing in the world but it is certainly a "one-time" nuicance" for each of my databases (since most of them have a similar situation).

You said: Quote:
Otherwise, you could not do anything in response to changing an unbound element, such as selecting something from an unbound combo box.


So, I have a REQUEST, for program enhancement (unless I am overlooking something).

Why NOT preclude an unboud field from triggering a program event - but ONLY in the "on form change" programming?

In your example of having a combo box respond, I only need it to respond when I click on (or enter) that particular LE ... so I would only need the programming executed on the element entry event.

My other unbound fields are all command buttons that cause programming to be triggered but without affecting any of the bound layout elements on the form (such as looking up a zip-code, retrieving an alternate record, printing an envelope etc.).

I cannot think of a single instance when I would NEED a click on an unbound field to trigger my on form change event programming.

And by the way, until you pointed this out I hadn't realized that there was another problem.  Even if a record does NOT have a birthdate/anniversary to trigger on form change programming, clicking on any one of my command buttons will.

Alternatively, should there be a reason to trigger on form change event programming, then how about a "switch" built into code that would allow the user to enter a programming statement in the on form change event and tell Sesame whether or not to include unbound fields?

Thanks!



  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Unbound Field & On Form Change
Reply #4 - Dec 30th, 2005 at 6:01pm
Print Post Print Post  
Quote:
I cannot think of a single instance when I would NEED a click on an unbound field to trigger my on form change event programming.


I can. And, from the real world apps I see on a daily basis, so can lots of other people.

I'm in the middle of something right now, but I have an idea that might give you what you need. I'll try to get to it later today.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
SpencerWulwick
Senior Member
Members
*****
Offline



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Re: Unbound Field & On Form Change
Reply #5 - Dec 30th, 2005 at 6:13pm
Print Post Print Post  
CAPTAIN INFINITY -

No need to apologize for "hacking" my code.  If it is something you are able to use, I am delighted.

Code
Select All
If not @isblank(Birthdate) then

     Age = @YEAR(@DATE)-@YEAR(BirthDate) - ((@MONTH(@DATE) < @MONTH(BirthDate))
     or (@MONTH(@DATE) = @MONTH(BirthDate) AND @DOM(@DATE) < @DOM(BirthDate)))
 



To tell you the truth, I obtained this code from Symantec Technical Support (when there was such a thing) for use in Q&A about what - 20 years ago?  lol  ... and it works like a charm in Sesame.

As best I can recall the only time I had a problem with "earlier" code I had created was if it was the same date (day of month) as the birthday.  In other words the age would calculate properly if you checked it either a day before (or earlier) or a day after (or later) than the actual birthdate.  But, if it was on the actual birthdate it would be off by one year.

This programming was designed to fix that.  When it was provided, I understood it perfectly.  Now I only understand it in theory and am not able to disect it without an extraordinary amount of effort.

The way it is written, it incorporates ("unseen" in the code) if/then conditions.

But I do offer you this.  Here's a way to test it.  I just went to my birthdate field - today - December 30, 2005.

If I enter a birthdate of December 31, 2000, the age is shown as 4 (because indeed the person is a day shy of being 5 years old)

If I enter a birthdate of December 30, 2000, the age is shown as 5 (because indeed, today is the day the person reached age 5)

If I enter a birthdate of December 29, 2000, the age is shown as 5 (because indeed the person has passed reaching the age of 5)

So I have checked the date of birth as being (1) a day (or more) before the actual birthdate, (2) on the actual birthdate or (3) a day (or more) after the actual birthdate - and it calculates correctly.  I cannot think of a single "example" that would "slip through" the programming, except that:

I DO NOT know whether this works correctly for someone born on February 29th of a leap year; however, I never had a single instance where I needed to calculate based on February 29 and if needed, it should be easy enough to modify the programming for that particular date.

I know that I did not answer your question precisely but hope that the information I did provide will help you.  

If it does not then please be specific about what you want to do.

I have numerous other (old Q&A) programming statements that do "math" calculations based on a date (of birth, anniversary, fixed date, etc.)

I do hope that this response will help you and wish you good luck.

By the way, just for "accuracy", I do not believe that Q&A had an @isblank function so the "lead in" was probably something like:  If birthdate /=  (not blank)       or      If birthdate <>"" (less than or greater than nothing).  While that might work in Sesame, as well, it is not recommended - so Erika has told me and told me and told me ... lol



  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged
 
SpencerWulwick
Senior Member
Members
*****
Offline



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Re: Unbound Field & On Form Change
Reply #6 - Dec 30th, 2005 at 6:27pm
Print Post Print Post  
Erika -

No rush.  This code has been working incorrectly (meaning it is not doing what I want - I am not saying that is not working as intended) for quite some time now and is certainly not critical).  But, when properly executed, can frequently be of value to me.

Code
Select All
I can. And, from the real world apps I see on a daily basis, so can lots of other people.
 



So, are you implying that MY APPLICATION is NOT a REAL WORLD application.  lol   Just kidding!!!!!

But, in all seriousness, when you do provide your recommendation I would also appreciate your giving me a couple of examples of when you would want programming triggered based on an on form change event limited to a change in an unbound field. 

The only type of situation I can think of would be if I wanted programming to execute based on age.  So, for example, I might have programming that would say "If age => 62 then Senior Citizen Discount = "Yes"  .... BUT, in that type of situation, a change would also occur to a bound element (Senior Citizen Discount).

Knowing what I am overlooking might be very helpful to me in future database design (especially if it is for someone other than myself).

Thanks!
  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Unbound Field & On Form Change
Reply #7 - Dec 30th, 2005 at 6:42pm
Print Post Print Post  
Quote:
The only type of situation I can think of would be if I wanted programming to execute based on age.  So, for example, I might have programming that would say "If age => 62 then Senior Citizen Discount = "Yes"  .... BUT, in that type of situation, a change would also occur to a bound element (Senior Citizen Discount).


Your example is exactly the type of situation I mean. You want a bound value to change because you altered an unbound value. It is the changing of the unbound value that triggers the On Form Change program which sets the bound value. If the change to Age doesn't trigger the progamming, the Senior Citizen Discount never gets set.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Unbound Field & On Form Change
Reply #8 - Dec 30th, 2005 at 7:07pm
Print Post Print Post  
Spencer,

Thank you, your info is helpful and illuminating.  I plan to use your code in my Personnel database, and may tweak it a bit to age Open Receivables.

Still, though...that "OR" floating in there baffles me.  Just what is it comparing?

Thanks again.
  

**
Captain Infinity
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Unbound Field & On Form Change
Reply #9 - Dec 30th, 2005 at 7:19pm
Print Post Print Post  
Quote:
I don't want to hiack your thread, but I can't ignore this because it looks like it will be very useful to some things I need to do.  But I'm having a bit of trouble parsing it.  What does the "or" condition look to and do?


Infinity,

The code subtracts the years. It then subtracts 1 if the person has not yet reached their birthday this year or zero if they have. The OR condition is boolean and returns 1 or 0.

I'll show you how it works by resolving the logic step by step. My birthday is Feb 10, 1969. Therefore to find out how old I am:

@YEAR(@DATE)-@YEAR(BirthDate) - ((@MONTH(@DATE) < @MONTH(BirthDate))
     or (@MONTH(@DATE) = @MONTH(BirthDate) AND @DOM(@DATE) < @DOM(BirthDate)))

First, we resolve the date months and years:
2005-1969 - ((12 < 2)  or (12 = 2 AND 30 < 10))

We do the first subtraction to find out how many years:
36 - ((12 < 2)  or (12 = 2 AND 30 < 10))

Now, we resolve the rest of the expressions. They are boolean, so they will all resolve to either 1 (true) or 0 (false):
36 - ((0)  or (0 AND 0))

Resolve the AND. For AND, both must be true. They aren't so:
36 - ((0)  or (0))

Resolve the OR. For OR, if either is true, it's true. Neither is true, so:
36 - 0

Do the math, and I am:
36

-------------------------
Let's do this again, but this time, lets make my birthday Dec 31, 1969. Meaning I have not yet had my birthday.

2005-1969 - ((12 < 12)  or (12 = 12 AND 30 < 31))

36 - ((12 < 12)  or (12 = 12 AND 30 < 31))

36 - ((0)  or (1 AND 1))

36 - ((0)  or (1))

36 - 1

My age is: 35

------------------------

See how it works?

  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
SpencerWulwick
Senior Member
Members
*****
Offline



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Re: Unbound Field & On Form Change
Reply #10 - Dec 30th, 2005 at 7:28pm
Print Post Print Post  
CAPTAIN INFINITY -

Code
Select All
If not @isblank(Birthdate) then

    Age = @YEAR(@DATE)-@YEAR(BirthDate) - ((@MONTH(@DATE) < @MONTH(BirthDate))
     or (@MONTH(@DATE) = @MONTH(BirthDate) AND @DOM(@DATE) < @DOM(BirthDate)))   



POW!

I believe that something "tucked away" more than 20 years ago has just resurfaced.

I BELIEVE that I may remember the parsing and that it provides for 4 separate "conditions" the first being the condition of the BirthdateLE and remaining 3 being on the comparison of the Year, Month and Date of birth.   My explanation is based  on my example of calculating the age on December 30, 2005 with a birthdate of either (1) December 31, 2000 or (2) December 30, 2000 or (3) December 29, 2000

1)      The easiest, of course, is "IF NOT @BLANK(BIRTHDATE) (which apparently you understand).   It simply says if the birthdate element contains a value then execute the following programming.  Otherwise (if the field is blank) the programming will be ignored.

2)      The second (and also easy to understand) is "AGE = @YEAR(@DATE) - @YEAR(BIRTHDATE)"  This simply calculates a number of years by taking the current year (2005) and subtracting the year of birth (2000) with a result of "5."  Now the question becomes, "Is this the correct age?"

3)      The next portion " – ((@MONTH(@DATE) < @MONTH (BIRTHDATE" is a combination of an if/then true/false condition.  It is saying to SUBTRACT the response to the true/false "condition" of the months.  IF the month of the actual date is LESS THAN the month of the birthdate THEN subtract the true/false response.  If the condition is TRUE – a "1" will be subtracted.  Since the month of the actual date is DECEMBER and the month of Birth is DECEMBER the condition is FALSE – and so zero (0) is subtracted, leaving the age as 5

4)      And now for the "toughest" part – and the part you want to understand, we have

OR (@MONTH@DATE) = @MONTH(BIRTHDATE) AND @DOM(@DATE < @DOM(BIRTHDATE)))

If the month of the current date is equal to the month of birth (in my example December = December) AND the DATE OF MONTH of the CURRENT DATE date is  LESS THAN the DATE OF MONTH of the BIRTHDATE that would make the condition true (and 1 would be subtracted).  Here's how it plays out

On December 30, 2005  with a birthdate of:

December 29, 2000 – the condition is false and a zero is subtracted leaving age 5
December 30, 2000 – the condition is false and a zero is subtracted leaving age 5
December 31, 2000 – the condition is true and a "1" is subtracted making the age 4

I believe (and hope) that my premise is correct. 

I tried to make this as easy to understand as possible and hope I've succeeded.

Once again, good luck!
  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged
 
SpencerWulwick
Senior Member
Members
*****
Offline



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Re: Unbound Field & On Form Change
Reply #11 - Dec 30th, 2005 at 7:49pm
Print Post Print Post  
Erika -

AARRRGGHHH!!!!


Why didn't you tell me you were responding to Captain Infinity - you would have saved me all my trouble.  lol 

Now, getting back to my original scenario.

Code
Select All
You want a bound value to change because you altered an unbound value. It is the changing of the unbound value that triggers the On Form Change program which sets the bound value. If the change to Age doesn't trigger the progamming, the Senior Citizen Discount never gets set 



This is the part I don't understand.  The age LE is changing based on FORM ENTRY.  It is not bound to a field and so I onle "see it" in the unboud Age LE.  Again, the age calculation was triggered by the on form entry event.

Now, the SENIOR DISCOUNT is a bound field but if the programming were also on form entry following the age caculation it would seem to me that it would still calculate and since it IS IN a bound field that - in and of itself, without regard to the age calculation would trigger the "on form change event" programming to execute and thus (since the element is bound) save the calculated value, along with my LAST UPDATE LE since there was (in the Senior Discount LE) a form change AND the LAST UPDATE LE is bound. 

I admire your expertise and am certain you must be right - but somehow I am just not getting it from the explanation ... and would like to.

Thanks!

25 1/2 MORE DAYS
  but who's counting?   lol

  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Unbound Field & On Form Change
Reply #12 - Dec 30th, 2005 at 8:10pm
Print Post Print Post  
Wow.  Erika, Spencer...both have you have blown my mind.  I had no idea such complex stuff could be jammed in such a simple statement.  Thank you both for your explanations.
  

**
Captain Infinity
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Unbound Field & On Form Change
Reply #13 - Dec 31st, 2005 at 1:27am
Print Post Print Post  
Spencer,

I didn't realize that your example was meant to run On Form Entry. I was talking about typing into or calculating Age, changing the unbound value which would in turn trigger the On Form Change event to set the value in a bound element.

There are many examples of wanting to change a bound value based on a change to an unbound element.

For example, you may have three unbound elements whose values are used a calculate a single bound element. If you change any of the unbound values, the bound value should recalculate. Examples of this include a custom calculator, assembling an adddress, creating a customer code, etc.

You may want to make a selection from an unbound combo box and have the change trigger a recalculation of bound elements on your Form.

You may want to make a choice from an unbound radio button group and have the change trigger a recalculation of bound elements.

And so on...

As to your case, if you don't want certain changes to "count" as a change, set a variable indicating the special condition. It would go something like this:

GLOBAL CODE
[code]stat gFlag as Int

    gFlag = 0[/code]

FORM::ON FORM ENTRY
[code]If Not @IsBlank(Birthdate)
{
     Age = @YEAR(@DATE)-@YEAR(BirthDate) - ((@MONTH(@DATE) < @MONTH(BirthDate)) or (@MONTH(@DATE) = @MONTH(BirthDate) AND @DOM(@DATE) < @DOM(BirthDate)))

    // Set the flag telling SBasic that you
    // don't want this particular change to count.
    gFlag = 1 
}[/code]

FORM::ON FORM CHANGE (or wherever)
[code]// Only set LastUpdate if the change "counts"
If gFlag = 0
{
     LastUpdate = @Date
}
Else
{
    gFlag = 0
}[/code]

This method allows you to manage more than just the limited case of unbound values. You can pick and choose which changes matter based on whatever criteria is appropriate at the moment. Sometimes it will be unbound elements, sometimes it will be only certain values. Sometimes you will want unbound changes to count. Sometimes you won't. Sometimes what you want is the same as what most other people want. Sometimes it isn't.

By using methods like this, you don't have to rely on us as developers to be able to accurately predict what is "right" for each of thousands of users in every circumstance. We try to give you flexible powerful tools that allow you to make these decisions for yourself, as needed.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Unbound Field & On Form Change
Reply #14 - Dec 31st, 2005 at 4:32am
Print Post Print Post  
Quote:
I do want to see the correct age even if I am just looking at a form and I don't want to have to remember to click on a "button" (which I could easily put there) to calculate the age.  I sometimes do want to simply scan through a stack of records to check age.

I have been using @Msg to display temporary calculation results. This way, it does not cause a form change condition at all, and doesn't require any special action on your part. Which, I think, was your original concern.

  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
SpencerWulwick
Senior Member
Members
*****
Offline



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Re: Unbound Field & On Form Change
Reply #15 - Dec 31st, 2005 at 5:33am
Print Post Print Post  
Carl -

I appreciate the "suggestion"; however, I have never used the @message function because it is barely visible and somehow, no matter how important it may be, I never think to look there.  Now, if a certain designer would like to give us the option of placing a "message" OVER an LE - limiting the size of the message to the size of the LE - THAT would be a WONDERFUL enhancement for version 2.0.   lol

My date of birth and date of anniversary are on a separate (called Special Events) tab, along with the age and years.  The age/years is only important to me if the Special Events tab is in view.  Perhaps there is a way for me to program something that will work for me based on that condition.

For me, the main issue is still (as you said) that I don't want the on form change programming to be triggered based simply on the recalculation of my age and/or years LE's.

Erika -

I understand the examples you gave about wanting to execute programming based on a change in an unbound element; however, in each of the specific examples you gave, I believe that I would find it easy enough to simply have the programming execute based on element exit.  Even if the statement had to go in more than one field, that is not like having to insert programming for 77 fields.

As for your stat gflag suggestion, assuming it works for what I need, and it looks like it will, I would still have to deal with it in my age/years LE's but more importantly, in every single command button on the form (and perhaps other instances that just don't come to mind right now) and for every command button I add to the form.  Once again, that seems like a lot of extra work to me.  Nevertheless, it may not be as bad as I think and I'll certainly give it a shot.

I cannot help but feel that there has to be a better solution.  Just as the distinction has been made whether or not to give the "warning" notice when the only change is in an unbound LE, so too do I think there's a way to provide for what I want and still be allowing the individual user to make individual choices based on their individual needs - but to make doing so easier.

I mentioned earlier a "switch."  Suppose for example I could use an @LE function (not a switch but this would work too ... in switch form - I would simply follow my programming with someting like /LEB or /LEU):

@LE(Bound,Last Updated = @date )
@LE(Unbound,Last Updated = @date)

giving me a choice of whether the on-form-change programming executes only when a bound le is changed or only when an unbound le is changed.  If neither is specified - meaning I just dont use the @LE portion of the programming, then the default would be the current state of considering both bound and unbound LE's as triggering a form change.

and perhaps another option of
@LEIGNORE(Birthdate;Anniversary)

where I can chose all but the specified fields to trigger the programming.

These suggestions would not take anything away from people  who are happy now with the way things are; They would not have to learn anything new nor would they have to do anything different than what they are currently doing.  For them, everything would be just as good as it now is.

But for the customer (me and maybe even one other person - lol) who is not happy, I (or we) would have an easy-to-use, viable, means of "grabbing control."

Once again, I am looking to have the best of both worlds; flexibility (as we both agree) for the user to have control when wanted BUT coupled with ease of use in implementing that control.

25 MORE DAYS!
  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Unbound Field & On Form Change
Reply #16 - Dec 31st, 2005 at 2:29pm
Print Post Print Post  
You also have another option. Instead of using a text box for Age and setting its value, use a static text element instead and set its label. The behavior will look identical to you, but I don't think that this will trigger On Form Change.


Quote:
As for your stat gflag suggestion, assuming it works for what I need, and it looks like it will, I would still have to deal with it in my age/years LE's but more importantly, in every single command button on the form (and perhaps other instances that just don't come to mind right now) and for every command button I add to the form.  Once again, that seems like a lot of extra work to me.  Nevertheless, it may not be as bad as I think and I'll certainly give it a shot.


Only if every command button on your Form changes an unbound element that you do not want to count as an update. Clicking a command button does not change a value unless there is programming that does so in its On Element Entry event.

I think you may be confusing the event itself with the programming it triggers.

In your case, you have On Form Entry programming that sets an unbound element called Age. You also have On Form Change programming that sets LastUpdate whenever any value changes (because that's what On Form Change does). Here's the sequence:

1. You arrive on a record. This triggers the On Form Entry event.
2. You have programming in this event that changes the value in Age.
3. Because a value changed, the On Form Change event is triggered.
4. The programming in your On Form Change event runs, setting LastUpdate.

Now, let's look at an example of clicking a command button that uses @SelectTreeItem to print a Report.

1. You click the command button. This triggers the On Element Entry event.
2. You have programming in this event that prints out a report. The report prints.

That's it. Nothing else happens. LastUpdate does not get updated because no value, unbound or otherwise, has changed.

  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
SpencerWulwick
Senior Member
Members
*****
Offline



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Re: Unbound Field & On Form Change
Reply #17 - Dec 31st, 2005 at 4:57pm
Print Post Print Post  
Erika -

I appreciate your efforts to help me understand this and to come up with a viable solution.  Unfortunately, I am still at a loss (except that I have not yet tried the gflag approach and hope to.  Even if that doesn't make me happy in this particular case I can see that it has inherent value that I might want to use for another purpose).

With regard to command buttons, they do seem to trigger a "form change" unless - again - I am missing something and, unfortunately, I don't have a clue what that might be.

I just went to a record that does not contain a date of birth and therefore the age calucation programming did not occur.

But the instant I clicked on the command button, the Last Update field changed.  (Please remember that if I don't click on a button - and there is no date of birth, the last update field is not updated). 

Here is the code on the particular command button I pressed.  I do not see that it is affecting any bound (or unbound for that matter) field.

Code
Select All
ar Z as int

if not @update then
{
z = @asynchshell("C:\Sesame\Data\Sounds\Cannot Use Here.wav")
STOP
}
else
if status = "deceased"
{
z = @asynchshell("C:\Sesame\Data\Sounds\Deceased.wav")
STOP
}
else
if record type = "companion"
and @isblank(Mail Name)
then
{
z = @asynchshell("C:\Sesame\Data\Sounds\Companion.wav")
throwfocus(Alt Record)
STOP
}
else
if @isblank(Mail Name)
and not record type = "companion"
then
{
z = @asynchshell("C:\Sesame\Data\Sounds\Mail Name.wav")
throwfocus(Mail Name)
STOP
}
else
if
@isblank (Address1)
or @isblank (city)
or @isblank (state)
or @isblank (zip)
then
{
z = @asynchshell("C:\Sesame\Data\Sounds\Address Incomplete.wav")
STOP
}
else
AlternateDefaultPrinter("Auto HP LaserJet 5 - Envelopes")
Newpage(950,412)
PrintString("Spencer Wulwick (MVR)", 30, 25, 0, "Arial", 14, 0)
PrintString("210 South Hale Avenue", 30, @PageExtentY(), 0, "Arial", 14, 0)
PrintString("Tampa, FL 33609-3933", 30, @PageExtentY(), 0, "Arial", 14, 0)

PrintString(Mail Name, 450, 200, 0, "BArial", 16, 0)
PrintString(Address1 + " " + Apt, 450, @PageExtentY(), 0, "BArial", 16, 0)
PrintString(City + ", " + State + "  " + Zip, 450, @PageExtentY(), 0, "BArial", 16, 0)
FinishPage()
RestoreDefaultPrinter()
 



Your suggestion to try a static text box and change the label sounds like it mght be the perfect solution, assuming that, indeed, it does not trigger an on form change event.  I searched through he program guide and do not have a clue what function I would use to accomplish the programming.  Could you point me in the right direction, please.

Thanks!
  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Unbound Field & On Form Change
Reply #18 - Dec 31st, 2005 at 6:53pm
Print Post Print Post  
Spencer,

With all the ThrowFocus calls, I can't see all the code that is actually running, so I would have to have your app to say for sure if and why a change is running.

Oh, and STOP USING STOP!!!!!!!!  Smiley

As to the Static Text, I think the call you want is @Label. I don't have a Programming Guide here.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
SpencerWulwick
Senior Member
Members
*****
Offline



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Re: Unbound Field & On Form Change
Reply #19 - Dec 31st, 2005 at 7:06pm
Print Post Print Post  
Erika -

I forgot about the "throw focus."  Most of the "conditions" simply play a sound file (instead of providing a message box with the accompanying obnoxious sound).

I have been told many times to STOP using STOP; however, it works perfectly in this instance and I simply haven't had the time to figure out the alternative way to do this.  (Perhaps on January 26th, I'll get some fresh ideas).   Grin

@label returns the label text of the layout element, so I don't think that's the one I want.  That led me; however, to
Label(element,m) which allows me to "Assigns label m to layout element. Adds a label if none exists." and that sounds like precisely what I need.

I am very eager to try it but first I MUST work on my new Palm Pilot which I received as a gift, after having kinda wanted one for over 20 years or so.  Soon as I get it working with my address book uploaded, I am going to try this.

Thanks!
  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged
 
SpencerWulwick
Senior Member
Members
*****
Offline



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Re: Unbound Field & On Form Change
Reply #20 - Jan 2nd, 2006 at 4:35pm
Print Post Print Post  
Erika -

BRAVO!!!!

You finally figured out a way to "shut me up" on this issue.   lol

The  Label(element,m)  function, does the trick and works like a charm.  (And you were probably right about the command buttons not triggering an on-form-change event, because I just tested it with my new code and it did not affect the last updated field. There must have been something else going on that I was unaware of).

And, I'm excited about a "bonus option" I've just been provided.  I see no reason now, why I can't set up my OWN "Message Box" and use it (when the line at the bottom doesn't do the trick) also without triggering an on-form-change event to occur.  So now I can have a message appear wherever I want without it being "lost" on the bottom of the form ... and without using the msgbox which makes that "gosh-awful" sound and which requires a click to get rid of it.

In case anyone is interested, here's the on-form-entry code (which does NOT affect my on-form-change event to be triggered) that I came up with to accomplish precisely what I wanted.  

Remember that "STage" is nothing more than a static label (actually a static text box with nothing in it, initially).

Code
Select All
var success as string
If not @isblank(Birthdate) then
success = @YEAR(@DATE)-@YEAR(BirthDate) - ((@MONTH(@DATE) < @MONTH(BirthDate))
   or (@MONTH(@DATE) = @MONTH(BirthDate) AND @DOM(@DATE) < @DOM(BirthDate)))
Label(STage,success)
ForceRedraw()
 



Once again, thanks so much for "hanging in there" with me.
« Last Edit: Jan 3rd, 2006 at 8:03pm by SpencerWulwick »  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Unbound Field & On Form Change
Reply #21 - Jan 3rd, 2006 at 3:04pm
Print Post Print Post  
Quote:
I have been told many times to STOP using STOP; however, it works perfectly in this instance and I simply haven't had the time to figure out the alternative way to do this.  (Perhaps on January 26th, I'll get some fresh ideas).   Grin


Stop only appears to work perfectly in this instance but I can guarantee you that it is not working perfectly. Calling Stop is like driving your car into a wall doing 100 mph. You will stop and it will not be pretty. The alternative in this case is a pair of braces {} on your last else statement. The reason you were using STOP is because your code was written incorrectly and the last Else statement was only controlling the call to AlternateDefaultPrinter().

Code
Select All
Var Z as int

if not @update then
{
	z = @asynchshell("C:\Sesame\Data\Sounds\Cannot Use Here.wav")
}
else if status = "deceased"
{
	z = @asynchshell("C:\Sesame\Data\Sounds\Deceased.wav")
}
else if record type = "companion" and @isblank(Mail Name) then
{
	z = @asynchshell("C:\Sesame\Data\Sounds\Companion.wav")
	throwfocus(Alt Record)
}
else if @isblank(Mail Name) and not record type = "companion" then
{
	z = @asynchshell("C:\Sesame\Data\Sounds\Mail Name.wav")
	throwfocus(Mail Name)
}
else if @isblank (Address1) or @isblank (city) or @isblank (state) or @isblank (zip) then
{
	z = @asynchshell("C:\Sesame\Data\Sounds\Address Incomplete.wav")
}
else
{
	AlternateDefaultPrinter("Auto HP LaserJet 5 - Envelopes")
	Newpage(950,412)
	PrintString("Spencer Wulwick (MVR)", 30, 25, 0, "Arial", 14, 0)
	PrintString("210 South Hale Avenue", 30, @PageExtentY(), 0, "Arial", 14, 0)
	PrintString("Tampa, FL 33609-3933", 30, @PageExtentY(), 0, "Arial", 14, 0)

	PrintString(Mail Name, 450, 200, 0, "BArial", 16, 0)
	PrintString(Address1 + " " + Apt, 450, @PageExtentY(), 0, "BArial", 16, 0)
	PrintString(City + ", " + State + "  " + Zip, 450, @PageExtentY(), 0, "BArial", 16, 0)
	FinishPage()
	RestoreDefaultPrinter()
} 



-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Unbound Field & On Form Change
Reply #22 - Jan 3rd, 2006 at 3:20pm
Print Post Print Post  
Quote:
Stop only appears to work perfectly in this instance but I can guarantee you that it is not working perfectly. Calling Stop is like driving your car into a wall doing 100 mph. You will stop and it will not be pretty.
-Ray


I think that this may be something of an overstatement. Stop generally does work, but puts a needless strain on the programming environment and creates hard to read, hard to follow, hard to compile, and hard to fix code. There are no circumstances where stop cannot be replaced by a conditional. As such, it is always recommended that you do not use stop. Using a conditional will cause the code to run faster and better.

Stop is not so much "running headlong into a wall" as it is stopping the car by suddenly removing the running engine.

In general, try to write code that has one and only one entry point and one and only one exit point.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
SpencerWulwick
Senior Member
Members
*****
Offline



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Re: Unbound Field & On Form Change
Reply #23 - Jan 3rd, 2006 at 7:57pm
Print Post Print Post  
Hi -

Ray, thanks so much for taking time to provide the "correct" code for my command button.  

Mark, thanks for the explanation and, especially now that Ray has given me the code - and now that I have a better and realistic reason for not using "stop," I will get it "fixed" and avoid its use.

I would strongly urge you to put stronger language in the Programmer's Guide cautioning against the use.  I would even go so far as to state that this is only available if it MUST be used in converting Q&A applications and that it should NOT be used in newly developed Sesame applications.  If the programming guide gives me the instructions for using a specific "function" (I'm referring to "stop" in this instance) then I ought to be comfortable with using it.  It is disconcerting to follow the published guide and then be told - "this is bad."

I would hope that at some point, the references to Q&A could be eliminated completely. After all, Q&A has been "dead" (even though I realize that some people are still using it) for over 10 years now.  Sesame has been out for two. At some point, Q&A users, who will convert to Sesame will be non-existent and the manuals will be cleaner and clearer if they are limited to Sesame.

Thanks.

  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged
 
Foster
Ex Member


Re: Unbound Field & On Form Change
Reply #24 - Jan 5th, 2006 at 3:43pm
Print Post Print Post  
I will have to disagree with Spencer.  Even Microsoft provides helps for converts to their programes.  I like such helps as I use both Q&A and Sesame. Smiley
  
Back to top
 
IP Logged
 
walt
Member
*
Offline



Posts: 48
Joined: Nov 30th, 2002
Re: Unbound Field & On Form Change
Reply #25 - Jan 6th, 2006 at 6:45pm
Print Post Print Post  
Quote:
I will have to disagree with Spencer.  Even Microsoft provides helps for converts to their programes.  I like such helps as I use both Q&A and Sesame. Smiley

Ditto!
  
Back to top
 
IP Logged