Page Index Toggle Pages: [1] 2  Send Topic Send Topic Print Print
Hot Topic (More than 10 Replies) using @modified effectively (Read 4740 times)
Steve_in_Texas
Senior Member
*****
Offline


No personal text

Posts: 893
Location: San Antonio
Joined: Feb 21st, 2004
using @modified effectively
Aug 24th, 2004 at 3:42pm
Print Post Print Post  
I'm seeing that various programming is setting the @modified to true and thereby 'trashing' my 'modifieddate' LE.

For example:Exporting to csv using sbasic, using a button to display an image in an unbound image LE, etc.

The only solution I see doesn't seem to work to well:

Putting 'If @modified then modifieddate = @date' in each each relevent LE's 'On element change' works partially, but still not 100% accurate. What if a user accidentally makes a change and then fixes it before saving the form?

What I think would be ideal is something like this:

On form exit:
if @modified(Quality, Collection, part number, color name) then ModifiedDate = @date

Is there a way to accomplish this currently, for the most accurate use of @modified?

Also, does running a mass update trigger the @modified and other form programming?

Thanks,
Steve
  
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: using @modified effectively
Reply #1 - Aug 24th, 2004 at 7:10pm
Print Post Print Post  
[quote author=Steve_in_Texas  link=1093362167/0#0 date=1093362167]On form exit:
if @modified(Quality, Collection, part number, color name) then ModifiedDate = @date

Is there a way to accomplish this currently, for the most accurate use of @modified?[/quote]

Yes. If you want to only check certain values, or only bound values, etc., you can use variables to shadow those values you care about. This will also the cover the "changed it, then changed it back" situation.

For example:

[code]Form::On Form Entry

var vShadowQuality as String
var vShadowCollection as String
var vShadowPartNumber as String
var vShadowColorName as String

vShadowQuality = Quality
vShadowCollection = Collection
vShadowPartNumber = part_number
vShadowColorName = color_name

Form::On Form Exit

If ((Quality <> vShadowQuality)
Or (Collection <> vShadowCollection)
Or (part_number <> vShadowPartNumber)
Or (color_name <> vShadowColorName))
{
       ModifiedDate = @Date
}[/code]

I usually use the Form::On Element Change method. If someone changes something, then changes it back to the original value, I still want to know that somebody was mucking about in that record.
  

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


No personal text

Posts: 893
Location: San Antonio
Joined: Feb 21st, 2004
Re: using @modified effectively
Reply #2 - Aug 24th, 2004 at 7:28pm
Print Post Print Post  
Erika,

Thanks for the solution to my delimma, but I think my idea is much easier.

Maybe in a future release?

Smiley

Thanks again for your help. I'll get started.

Steve
  
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: using @modified effectively
Reply #3 - Aug 24th, 2004 at 7:49pm
Print Post Print Post  
Quote:
Thanks for the solution to my delimma, but I think my idea is much easier.


Well, implementing my suggestion would be WAY easier for you than implementing your suggestion would be for me.  Wink

Seriously though, you could use StringArray to make a really simple function that takes a semicolon separated list of element names and returns a semicolon separated list of values. Run it on the way in and set  a global variable to the result. Run it again on the way out and just compare the two semicolon separated strings to see if they equal each other.  You can even use the @ElementBoundToType function to automatically grab all the bound elements and skip the statics. It would be very cool, and very flexible.
  

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


No personal text

Posts: 893
Location: San Antonio
Joined: Feb 21st, 2004
Re: using @modified effectively
Reply #4 - Aug 24th, 2004 at 7:54pm
Print Post Print Post  
Wow, great advice and a great tip to keep in mind for my future programming work. (Although its not easy for a new Sesame user to pick up and run with, like my idea is.)

Good information, though.

Thanks!  Smiley

Steve
  
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: using @modified effectively
Reply #5 - Aug 24th, 2004 at 8:35pm
Print Post Print Post  
I used to make "shadow" fields in Q&A, but in Sesame, I have been making these fields ReadOnly if not @ADD, on Record Entry Event.

That allows me to have the field manually created, but once saved it cannot easily be accessed and changed by mistake.  And no need for any comparison of an original value vs. the current value.

  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: using @modified effectively
Reply #6 - Aug 24th, 2004 at 9:01pm
Print Post Print Post  
Steve,

Can you be more specific as to what is setting @modified. I've just tested a number of cases and the only case so far with any question is setting the label of a unbound static using the assignment operator (i.e. "LE0 = "New Label"), which does set @modified. But, for example, neither pressing an unbound command button, nor setting the label of an LE with label(), set the @modified flag.

Yes, changing the value of a bound LE and leaving the LE, then returning to it and setting it back to the original value, does leave the @modified flag set - and must. The @modified flag is singular, if Sesame sets it back, because one LE was set back to an original value, it would lose the fact that several other LEs may have also changed.

The @modified flag is intended to indicate if the form has changed, even if the user has no intent of saving the changes, thereby allowing the programmer to react to changes immediately.

It sounds like you could use a new function called something like @RecordWouldModify() that compares the current state of the form against the record still on the engine, before the form is committed. The difficulty in something like that is the amount of network traffic and complexity it would cause during simple form navigation - particularly in large forms with many subforms. Additionally, you could never tell if what is being compared is identical to the values actually committed because of subsequent navigation or form exit code.

Your idea to write a function that compares the values of multiple LEs is a good idea. But it also could only tell you if a value has been modified - not if it has subsequently returned to its original value. Nor could it reply which of the values of the LEs passed in have changed. The only way to tell if a particular value has been modified from its "engine original" value, is to keep the original value when it is received from the engine. That would require that all of the LEs be "shadowed" or duplicated in value, and that this duplication only occur when a form first receives the value from the engine.

This is not to say that I won't write such a function, but the difficulty becomes somewhat ponderous when confronted with table viewed subforms, where each LE may well have dozens or hundreds of values.
  

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


No personal text

Posts: 893
Location: San Antonio
Joined: Feb 21st, 2004
Re: using @modified effectively
Reply #7 - Aug 24th, 2004 at 9:39pm
Print Post Print Post  
Bob, Read only doesnt work becuase often we need to make changes in @update mode.

Also, our users complain about read only fields because they are hard to read. (The font color lightens when the field is readonly)

Mark,

I'll try to get the specifics on whats triggering the @modified. All I know at the moment is that is triggering when I dont want it to, so I assumed its becuase of some form programming that isn't altering data. (I have a lot of programming in place to check for errors and run calculations so it may take some time to find the answer).

Thanks for listening.

Steve
  
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: using @modified effectively
Reply #8 - Aug 24th, 2004 at 9:53pm
Print Post Print Post  
Quote:
Also, our users complain about read only fields because they are hard to read. (The font color lightens when the field is readonly)
This raises some other issues with ReadOnly fields. 

I have started a new Subject, Read Only fields at: http://www.lantica.com/Forum2/cgi-bin/yabb/YaBB.pl?board=gen_disc;action=display....
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Steve_in_Texas
Senior Member
*****
Offline


No personal text

Posts: 893
Location: San Antonio
Joined: Feb 21st, 2004
Re: using @modified effectively
Reply #9 - Aug 24th, 2004 at 10:30pm
Print Post Print Post  
Mark,

Now that I'm looking, I see that @modified is being triggered every time I enter a form.

I exported my programming to a text file and searched it for every use of @modified and for every instance where my ModifiedDate LE was being changed.

I am only using the below program in 'on element change' LE's of my important fields (about 25 fields):

if @modified then ModifiedDate = @date

I took out the above line from all LE's and @modified is working just fine (only triggers when it's supposed to), so it appears Sesame THINKS an LE is being changed, but I dont see a change anywhere. Maybe this is part of the combo box bug that has been fixed in the next release? (on element change was firing prematurely)

Maybe 'On retrieve spec open' programming is causing sesame to think an LE has been changed?

This will take some time to narrow down which LE is the culprit.

Steve
  
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: using @modified effectively
Reply #10 - Aug 25th, 2004 at 10:44am
Print Post Print Post  
Quote:
Maybe 'On retrieve spec open' programming is causing sesame to think an LE has been changed?


I'll look into this. Maybe it is not being reset between the search spec and the results form.
  

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


No personal text

Posts: 893
Location: San Antonio
Joined: Feb 21st, 2004
Re: using @modified effectively
Reply #11 - Aug 25th, 2004 at 1:14pm
Print Post Print Post  
FYI - The @modified is triggering immediately, only in one of my forms. (the one with 3 combo boxes and a button to autopopulate them at retrieve spec open.)

Steve
  
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: using @modified effectively
Reply #12 - Aug 25th, 2004 at 1:19pm
Print Post Print Post  
Could you check @modified while you are populating the combo boxes in the retrieve spec? Put in a check in the retrieve spec programming before you do anything else and then additional checks as you make other function calls. Then put in a last check before any of the regular form programming run (in on form enter). That should tel us whether it is being set in the retrieve spec programming (and what call set it) and if it is simply not being cleared before the the main programming runs.
  

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


No personal text

Posts: 893
Location: San Antonio
Joined: Feb 21st, 2004
Re: using @modified effectively
Reply #13 - Aug 25th, 2004 at 1:22pm
Print Post Print Post  
Whats a 'check'. Give me an example, please.

Steve
  
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: using @modified effectively
Reply #14 - Aug 25th, 2004 at 1:24pm
Print Post Print Post  
Quote:
Whats a 'check'. Give me an example, please.

Steve


WriteLn("Before Retrieve Spec Programming: " + @Str(@Modified))
WriteLn("After Populate Combo Boxes: " + @Str(@Modified))
WriteLn("After Retrieve Spec Programming: " + @Str(@Modified))
WriteLn("Before On Form Entry Programming: " + @Str(@Modified))
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send Topic Send Topic Print Print