len(right(number, 3))

James Hurley jhurley at infostations.com
Wed Jan 26 09:40:56 CST 2005


>
>Paul Salyers wrote:
>
>How is this statement wrote in Rev,
>
>len(right(number, 3)
>
>this in VB will take the number ex:
>
>number = "12345678"
>
>and cut it down to
>
>number = "678"
>
>starting at the right and give you the first 3 numbers.
>
>I need to do this in Rev.
>
>
>I searched "len" and got
>
>put char (length(it) - 3) to (length(it)) of it into myExtension
>
>but don't understand what it means.
>


Paul,

The thing you need to know about Run Rev is that it treats a string 
of characters like words or numbers depending on the context. For 
example

If you write:

	Put 123 & 456 into theResult

Then theResult is 123456

If you write:

	put 123 * 456 into theResult

Then the result is 56088

If you write:

	Put char 1 to 4 of  123*456

Then theReuslt is 56088

Which is confusing. But if you

	put char 1 to 4 of (123*456) into theResult

Then theResult is 5608

Which is what you might hope for.

Moral: Don't abuse flexibility.

I think the function you want is:

function rightCharacters tNum,howMany
   put the number of chars in tNum into tNumChars
   return char -(tNumChars-howMany) to -1 of tNum
end rightCharacters

Notice: You  count characters from the right as -1, -2, -3 etc.

Jim


More information about the use-livecode mailing list