Programing style

Jim Ault JimAultWins at yahoo.com
Thu Nov 16 16:06:17 CST 2006


Forgot to ask about final format  ? two decimals ?
Add one line at the end to handle this 'if there are no decimals'


On 11/16/06 2:00 PM, "Jim Ault" <JimAultWins at yahoo.com> wrote:

> --takes advantage of Rev parsing
> --does not handle negative numbers
>> function fNumericToMoney
> put param(1) into tParam
>  set itemdel to "."

>   put item 1 of tParam into newNum
>   set the lineDel to ","
>   repeat until char 1 of newNum is ","
>     put "," before char -3 of line 1 of newNum
>   end repeat
>   put "$" into char 1 of newNum
if item 2 of tParam is not empty
then put  "." & item 2 of tParam after newNum
>   return newNum
>> end fNumericToMoney
> 
> --after this handler finishes, the itemDel and lineDel expire, since these
> only apply to the active handler when set.

 Jim Ault
 Las Vegas
> 
> On 11/16/06 1:01 PM, "Hershel Fisch" <hershf at rgllc.us> wrote:
> 
>> Hi all, I'd like to know how others write a function like this.
>> TIA Hershel
>> 
>> function fNumericToMoney
>>   put param(1) into tParam
>>   if tParam contains "." then
>>     put offSet(".",tParam)-1 into tTs
>>     put 3 into tC
>>   else
>>     put the number of chars in tParam into tTs
>>     put 0 into tC
>>   end if
>>   repeat while tTs >3
>>     add 3 tC
>>     put "," before char -tC in tParam
>>     add 1 to tC
>>     subtract 3 from tTs
>>   end repeat
>>   return "$" & tParam
>> end fNumericToMoney
>> 
> 
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution





More information about the use-livecode mailing list