Formatting entries in the fields

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
link76
Posts: 99
Joined: Fri Nov 04, 2011 1:52 pm

Formatting entries in the fields

Post by link76 » Fri Jun 22, 2012 3:09 pm

Hi,

You can have a formatting entries in the fields when digit?
eg: 00:00:00

thanks

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10321
Joined: Wed May 06, 2009 2:28 pm

Re: Formatting entries in the fields

Post by dunbarx » Fri Jun 22, 2012 6:45 pm

There are several native formats, for example, the long time is of the type you showed. "xx:xx:xx"

But I think you want to validate general formatting, no? You must use the "itemdelimeter" to create your own format. I do not know how you intend to use this, either for data entry or for data validation.

So, for example if you need data entry in that form, you might check an entered value as follows:

ask "Enter data"
answer checkFormat(it)

function checkFormat var
set the itemDelimiter to ":"
if item 1 of var is a number and item 2 of var is a number and item 3 of var is a number then
return var
else
return "Invalid Format"
end if
end checkFormat

This is a bit wordy, but I hope you get the idea. There are about a dozen other ways to do this. Write back if this is not what you had in mind at all.

Craig Newman

link76
Posts: 99
Joined: Fri Nov 04, 2011 1:52 pm

Re: Formatting entries in the fields

Post by link76 » Sat Jun 23, 2012 9:06 am

dunbarx wrote: There are several native formats, for example, the long time is of the type you showed. "xx:xx:xx"
Craig Newman

Thanks for the function! but I want to set a format native to the field text entry, how can I do?

gpb01
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 281
Joined: Sat Jun 04, 2011 5:41 pm

Re: Formatting entries in the fields

Post by gpb01 » Sat Jun 23, 2012 11:47 am

link76 wrote: Thanks for the function! but I want to set a format native to the field text entry, how can I do?
There is not "native format" for a field (use the inspector to see what you can set) ... you have to write your own function to format and verify as you like ... ;)

Guglielmo

link76
Posts: 99
Joined: Fri Nov 04, 2011 1:52 pm

Re: Formatting entries in the fields

Post by link76 » Sat Jun 23, 2012 12:38 pm

gpb01 wrote:
link76 wrote: Thanks for the function! but I want to set a format native to the field text entry, how can I do?
There is not "native format" for a field (use the inspector to see what you can set) ... you have to write your own function to format and verify as you like ... ;)

Guglielmo
you have any ideas?

Can you speak Italian?

-
Luca

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: Formatting entries in the fields

Post by BvG » Sat Jun 23, 2012 2:04 pm

To make a "restricted" entry field, you have to add code yourself. For example:

Code: Select all

on keyDown thePressedKey
  if thePressedKey is in "0123456789:" then
    pass keyDown
  end if
end keyDown
Note that this example allows entries like "99::13:323424:", so you have to add more "if then-end if" clausels.
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

gpb01
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 281
Joined: Sat Jun 04, 2011 5:41 pm

Re: Formatting entries in the fields

Post by gpb01 » Sat Jun 23, 2012 3:03 pm

link76 wrote: ...

Can you speak Italian?
-
Luca
Si Luca, l'Italiano è la mia lingua madre ... ma, per rispetto verso gli altri, solo al di fuori di questo forum (guglielmo (at) braguglia.ch) :)

(for English speakers : "Yes Luca, Italian is my mother tongue, but, for respect to others, only outside this forum)

Guglielmo

Post Reply