Hot Topic (More than 10 Replies) Field Template (Read 1452 times)
proudpoppy
Full Member
Members
***
Offline


Do What ??

Posts: 420
Location: South Carolina
Joined: Apr 7th, 2004
Field Template
Aug 20th, 2006 at 2:27am
Print Post Print Post  
I have a time field in the 24-hr format that I would like to make a template for, like ##:## I would like to see a example if anyone has one. I have accomplished the task in basic, but having trouble in Sbasic.
Like how do I get the value from the element field then add the  ":" and put it back in the element. And which event would it need to go in. Any help much appreciated !! Smiley
  
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Field Template
Reply #1 - Aug 20th, 2006 at 2:08pm
Print Post Print Post  
Why would you not simply use an element bound to a TIME field, and let Sesame take care of it for you.
  


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


Do What ??

Posts: 420
Location: South Carolina
Joined: Apr 7th, 2004
Re: Field Template
Reply #2 - Aug 20th, 2006 at 2:59pm
Print Post Print Post  
I do have the element bound to a time field, but it don't put the ":" in automatically.Thats what I'm trying to accomplish. Wink
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Field Template
Reply #3 - Aug 20th, 2006 at 3:05pm
Print Post Print Post  
What are your format settings?
  

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


Do What ??

Posts: 420
Location: South Carolina
Joined: Apr 7th, 2004
Re: Field Template
Reply #4 - Aug 20th, 2006 at 7:17pm
Print Post Print Post  
24 hour format
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Field Template
Reply #5 - Aug 20th, 2006 at 7:39pm
Print Post Print Post  
Is the colon not appearing when you leave the element?

Or, is the problem that you would like the colon to appear while you are in the element?

If the former, I'll need more details.

If the latter, then you can use on immediate change programming to insert the colon.
  

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


Do What ??

Posts: 420
Location: South Carolina
Joined: Apr 7th, 2004
Re: Field Template
Reply #6 - Aug 20th, 2006 at 8:36pm
Print Post Print Post  
When i put a value such as 1600 is the time element I get a popup saying "value can't be retained reverting to blank". The field is bound to a time field, its set to the 24 time format "##:##".
I have put in programing on element exit { Time Started = @Totime(Time Started)}  it then blanks the value out of the field and put  00:00 in the field. I can then backspace the zero's out and it will retain the proper format. of course thats more trouble than just putting the ":" in to start with. Mark to answer your question the colon never appears.
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Field Template
Reply #7 - Aug 20th, 2006 at 8:43pm
Print Post Print Post  
That's because it belives that you are trying to enter 1600 hours (i.e.: 1600:00). If you just type 16 and leave the element, you will get 16:00. If you want to type a number like 1632 and get 16:32, you will need to use SBasic.
  

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


Do What ??

Posts: 420
Location: South Carolina
Joined: Apr 7th, 2004
Re: Field Template
Reply #8 - Aug 20th, 2006 at 8:59pm
Print Post Print Post  
I have modified the following from a inside sesame issue would this work and what event would I put it in.

Subroutine TimeNumb()
//Check length and format Time number ##:##
If @IsBlank(ThisElement) = 0 and
@Instr(ThisElement, “:”) = 0
{
If @Len(@ToTime(ThisElement)) = 4 then
{
ThisElement = @Left(@ToTime(ThisElement), 2) + “:”
+ @Right(@ToTime(ThisElement), 2)
}
}
End Subroutine
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Field Template
Reply #9 - Aug 20th, 2006 at 9:23pm
Print Post Print Post  
That code will work if you change the time field into a string field. If you leave it a time field, the format check will run first and prevent the SBasic code from running (because the data is presumably incorrect for a time field). Or you can use immediate change programming, in which case, no, the code will not work. Ite will need to be rewritten so as to not interfere with the user.

If you do change the field type to string, put the subroutine in Global Code, and call it from On Change or On Exit. Note that your version is using "smart quotes", those will have to be changed to regular double quotes.
Code
Select All
Subroutine TimeNumb()
var vStr as string

	vStr = @Str(ThisElement)
	If @IsBlank(ThisElement) = 0 and @Instr(vStr, ":") = 0
	{
		If @Len(vStr) = 4 then
		{
			ThisElement = @Left(vStr, 2) + ":" + @Right(vStr, 2)
		}
	}
End Subroutine
 

  

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


Do What ??

Posts: 420
Location: South Carolina
Joined: Apr 7th, 2004
Re: Field Template
Reply #10 - Aug 21st, 2006 at 12:54pm
Print Post Print Post  
I had already got it working with code put into the exit event, so this morning I put it into a subroutine as you suggested, That's Cool !!! makes a big difference not having to put that colon in each time, got me rethinking my whole application. Wink
  
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Field Template
Reply #11 - Aug 21st, 2006 at 1:12pm
Print Post Print Post  
It sounds like you worked it out, but for others looking on:

You don't have to use the colon when entering hours and minutes. You could use a period, which is easier to type. So, you could use "9.2" or "9.02" and Sesame will display "09:02", or use "9.20" and Sesame will display "09:20".
« Last Edit: Aug 22nd, 2006 at 11:16am by Carl Underwood »  


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


Do What ??

Posts: 420
Location: South Carolina
Joined: Apr 7th, 2004
Re: Field Template
Reply #12 - Aug 21st, 2006 at 5:51pm
Print Post Print Post  
In my application the time fields was used in calculations later on in the application, to get the right $ amount mine required the colon. I had been using a number field set to two decimal places, which worked for for me alone using the app, but if others are to use it they wouldn't understand how to make it work. This is just much easier on the user.
Thanks for all the input !!
Different ways of thinking are great!!

  
Back to top
 
IP Logged