Normal Topic Converting inches to feet and inches (Read 929 times)
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Converting inches to feet and inches
Dec 27th, 2005 at 7:19pm
Print Post Print Post  
I'm using the following code to convert inches to feet and inches.  I have layour elements named LengthFeet and LengthInches.
Code
Select All
var vExtraInches as Double
var vExtraFeet as Double
var vExtraFeetInches as Double

if LengthInches>12 then
	{
	VExtraFeetInches = (LengthInches/12)
	vExtraFeet = @Int(VExtraFeetInches)
	vExtraInches = (VExtraFeetInches-vExtraFeet)
	VExtraInches = (VExtraInches*12)
	LengthFeet = LengthFeet + vExtraFeet
	LengthInches = vExtraInches
	} 



This is working very nicely as an on-element-exit for the LE named LengthInches.  Thing is, I need to do this calculation in a number of other places (at the very least twice more for Width and Height).  Would this be better placed in Global code?  If so, how would I call it from the LE, and how would the variable names change?
  

**
Captain Infinity
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: Converting inches to feet and inches
Reply #1 - Dec 27th, 2005 at 8:15pm
Print Post Print Post  
Never mind, I just re-read the manual section pertaining to Global Code and it's clearly not viable there.  I'll stick with on-element-exit.
  

**
Captain Infinity
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Converting inches to feet and inches
Reply #2 - Dec 27th, 2005 at 9:05pm
Print Post Print Post  
If you make your routine into a function or a subroutine, passing variables as arguments rather than using the LEs directly, you could (and should) put the function/subroutine in global code, and then invoke it from anywhere on your form.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
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: Converting inches to feet and inches
Reply #3 - Dec 28th, 2005 at 4:31pm
Print Post Print Post  
Yeah, I would love to do that, but creating functions is a bit out of my range of experience.  I'm just getting used to variables.  These calculations were formerly performed in Q&A with a sub-routine, but that stopped working after translation to Sesame and I don't know why.

I weighed the options of debugging the Q&A programming against creating fresh Sesame code using my new-found friends, variables, and came down on the side of learning some new stuff.

I'll tackle functions after I've taken the advanced class.  I hope that functions are dealt with there; they're clearly very useful.
  

**
Captain Infinity
Back to top
IP Logged