Strip Leading Zeros

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
warrenk
Posts: 110
Joined: Sun Sep 21, 2008 5:39 am

Strip Leading Zeros

Post by warrenk » Sat Mar 07, 2009 7:19 am

What is the easiest way to strip leading zeros from a numeric field?

ie. 00009 should be 9

Thanks for any help!
Warren

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Post by FourthWorld » Sat Mar 07, 2009 8:45 am

Hmmm...apparently adding zero works pretty quickly:

put 0+000009
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

warrenk
Posts: 110
Joined: Sun Sep 21, 2008 5:39 am

Post by warrenk » Sat Mar 07, 2009 2:08 pm

Thanks Richard....that was a easy solution!

Appreciate your help!
Warren

Philhold
Posts: 64
Joined: Thu Mar 05, 2009 3:39 pm

Post by Philhold » Sat Mar 07, 2009 4:40 pm

I was watching this thread hoping that it would answer a question I've been trying to answer myself. How do you actually apply input validation/input aids in Runtime Revolution?

In Javascript if I wanted to change the contents of an input field to all upper case I would put this in the field tags.

onChange = "toupper(this)"

and this elsewhere on my html page.
<script type = "text/javascript" language ="javascript">

function toupper(myObject){
myObject.value = myObject.value.toUpperCase();
}

</script>

Lets say I rewrote that in Transcript how would I apply it to a field and what would I use to trigger the function?

Many thanks

Phil

HankT
Posts: 17
Joined: Mon Oct 27, 2008 7:24 pm

Post by HankT » Sat Mar 07, 2009 5:46 pm

Philhold wrote: how would I apply it to a field and what would I use to trigger the function?
Put this in the field's script

Code: Select all

ON closeField
    put toupper(me) into me
END closeField
Leaving the field by tabbing out, clicking in another field, etc, would trigger it.

Hank

Philhold
Posts: 64
Joined: Thu Mar 05, 2009 3:39 pm

Post by Philhold » Sat Mar 07, 2009 5:54 pm

Hi Hank,

Brilliant! Many thanks.

Where can I find a list of even handlers and what objects they apply to?

Cheers

Phil

HankT
Posts: 17
Joined: Mon Oct 27, 2008 7:24 pm

Post by HankT » Sat Mar 07, 2009 5:57 pm

Philhold wrote:Where can I find a list of even handlers and what objects they apply to?
The Dictionary, under the Help menu.

Hank

Philhold
Posts: 64
Joined: Thu Mar 05, 2009 3:39 pm

Post by Philhold » Sat Mar 07, 2009 6:53 pm

Hi Hank,

I meant to say "event".

I'll have a dig in the Dictionary.

Cheers

Phil

Post Reply