Normal Topic Temporary Values (Read 1529 times)
CapitalG
Full Member
Members
***
Offline



Posts: 143
Location: Phoenix, Arizona
Joined: Mar 4th, 2003
Temporary Values
Mar 22nd, 2005 at 6:40pm
Print Post Print Post  
I know it was common in Q&A to have a bunch of fields that were used for calculating and then storing those calculated values. 

What is the best way (or at least some different ways) to handle those in Sesame?  In our case they are really temporary values used to merge/print in a document and do not need to be stored - they just take up space.
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Temporary Values
Reply #1 - Mar 22nd, 2005 at 6:54pm
Print Post Print Post  
Variables!  Smiley
  

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



Posts: 143
Location: Phoenix, Arizona
Joined: Mar 4th, 2003
Re: Temporary Values
Reply #2 - Mar 22nd, 2005 at 8:05pm
Print Post Print Post  
THANKS!
  
Back to top
 
IP Logged
 
CapitalG
Full Member
Members
***
Offline



Posts: 143
Location: Phoenix, Arizona
Joined: Mar 4th, 2003
Re: Temporary Values
Reply #3 - Mar 30th, 2005 at 9:16pm
Print Post Print Post  
In reading the programming guide pgs 47 - 54  I believe static variables would work best for my situation. 

Quote:
Simple Static variables, in contrast, retain their values only within the current
form, report, or Mass Update. In other words, as you move between records
in a form, you can retrieve (or update) a static variable. Although any
program connected to the current form can initialize, utilize and modify Static
variables, you must declare them in the Global Code section of the form:
stat MyName as String = "Linda Anderson"
By declaring (and optionally initializing) a variable like this in Global Code for
the form, it can be retrieved (and modified) by any program that runs in the
current form. When you exit the form, any static variables connected to it are
destroyed.


Is it possible to have the static variable change when a value on the form changes?   Example:  The form has two elements - Rate and LoanAmount.  The static variable declared in the global section simply multiplies the Rate and LoanAmount to come up with simple annual interest.  If a user changes the Rate or LoanAmount, I need the static variable to "recalculate."   

I got this to work using a regular variable in the "on change" element but I need the variable to be as the Programming Guide says, "more persistent"  and less "volatile and limited."  Static variables sound like the perfect solution but my knowledge is too limited.
  
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: Temporary Values
Reply #4 - Mar 30th, 2005 at 9:51pm
Print Post Print Post  
Yes. You can change static variables as you would a normal variable. It is named static because it holds it's value not because it never changes.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
CapitalG
Full Member
Members
***
Offline



Posts: 143
Location: Phoenix, Arizona
Joined: Mar 4th, 2003
Re: Temporary Values
Reply #5 - Mar 30th, 2005 at 10:26pm
Print Post Print Post  
What triggers the change?  Is it done with programming?  If so, where does the programming go?  With the example above it was easy to change the variable because the programming went in the On Element Change.  With this, it is in the Global section and does not have that option.   

or.....

Do I declare it in the Global Code section and then put the programming in the appropriate section?
  
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: Temporary Values
Reply #6 - Mar 30th, 2005 at 10:33pm
Print Post Print Post  
you declare your statics in global code and set them in the appropriate on change events.

so in global code
Code
Select All
stat gsMyName as String 



in the on form change event
Code
Select All
gsMyName = MyNameElement 



This will set the gsMyName variable equal to the name that is in the 'MyNameElement' element when the form change event fires.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
CapitalG
Full Member
Members
***
Offline



Posts: 143
Location: Phoenix, Arizona
Joined: Mar 4th, 2003
Re: Temporary Values
Reply #7 - Mar 30th, 2005 at 11:00pm
Print Post Print Post  
Got it.

Thanks.
  
Back to top
 
IP Logged