Backup:
Code:
; NTOW-INR 45L | Author: SKAN [ Suresh Kumar A N ] | Created: 2008-02-27 | Mod: 2008-02-27
; http://www.autohotkey.com/forum/viewtopic.php?t=29090
#SingleInstance, Force
SetBatchLines, -1
Menu, Tray, Tip, [NTOW-INR] Press Win+Scroll-Lock to toggle HotString suspension.
#ScrollLock::Suspend
:c*B0:Rs.::
Num:=""
Loop {
Input, N, L1 V ; accept a single key an build a numeric string
If ( N="*" OR N="=" OR N=">" OR N="?" OR N="(" )
{
VarSetCapacity( fNum,32 )
DllCall( "GetNumberFormat",UInt,0x0449,UInt,0,Str,Num,UInt,0,Str,fNum,Int,32 )
FS := RegExReplace( NTOW_IN( fNum,0,"AND PAISE" ),"(^ +| +(?= )| +$)" ) ; Thx Manauser
SendInput, {BS}{Space}( Rupees %FS% Only )
Break
}
Else If InStr( " ,", N ) ; characters to be ignored for fault tolerance
Continue
Else If InStr( ".0123456789", N ) ; characters to be considered
Num .= N
Else Break ; any other character would break the hotstring
}
Return
NTOW_IN( Num=0, RecursiveCall=0, SubUnit="POINT", Delimiter=",", Fraction="." ) {
Static L1:="ONE", L2:="TWO", L3:="THREE", L4:="FOUR", L5:="FIVE", L6:="SIX", L7:="SEVEN"
, L8:="EIGHT", L9:="NINE", L10:="TEN", L11:="ELEVEN", L12:="TWELVE", L13:="THIRTEEN"
, L14:="FOURTEEN", L15:="FIFTEEN", L16:="SIXTEEN", L17:="SEVENTEEN", L18:="EIGHTEEN"
, L19:="NINETEEN", L20:="TWENTY", L30:="THIRTY", L40:="FORTY", L50:="FIFTY"
, L60:="SIXTY", L70:="SEVENTY", L80:="EIGHTY", L90:="NINETY", L0:= ""
, G1:="", G2:="THOUSAND", G3:="LAKH", G4:="CRORE"
If RecursiveCall
{
H:=SubStr("00" Num,-2), T:=SubStr(H,-1)+0
N1:=SubStr(H,1,1),N2:=SubStr(H,2,1),N3:=SubStr(H,3,1)
Return (N1>0 ? L%N1% " HUNDRED " : "") (T<21 ? L%T% : L%N2%0 (N3<>0 ? " " L%N3% : ""))
}
StringSplit, Sec, Num , %Fraction%
StringSplit, Q , Sec1, %Delimiter%
Str := ((Sec1<1) ? "ZERO " : ""). ((Sec2>0) ? SubUnit " " NTOW_IN(Sec2,1) : "")
Loop %Q0%
I:=Q0-(A_Index-1), Str:=(Q%I%>0 ? NTOW_IN(Q%I%,1) " " G%A_Index% " " : "") . Str
StringLower, Str, Str, T
Return Str
}
/*
========================================================
| NTOW-INR 45L | Number To Words [ for Indian Currency ] |
========================================================
What is does ?
---------------
The script is a HotString Utility to convert number into words
You run the script and type > Rs.1250*
you get > Rs.1250 ( Rupees One Thousand Two Hundred Fifty Only )
Note: "Rs." triggers and "*" ends the HotString routine.
Sample output:
--------------
Rs.0.50 ( Rupees Zero And Paise Fifty Only )
Rs.10 ( Rupees Ten Only )
Rs.250 ( Rupees Two Hundred Fifty Only )
Rs.10000000.01 ( Rupees One Crore And Paise One Only )
Rs.1000000.2 ( Rupees Ten Lakh And Paise Twenty Only )
Rs.99,99,99,999.99 ( Rupees Ninety Nine Crore Ninety Nine Lakh Ninety Nine Thousand Nine
Hundred Ninety Nine And Paise Ninety Nine Only )
Rs.12 56 234.50 ( Rupees Twelve Lakh Fifty Six Thousand Two Hundred Thirty Four And Paise
Fifty Only )
Fault Tolerance:
----------------
Rs.1,2,3,4,5 ( Rupees Twelve Thousand Three Hundred Forty Five Only )
Rs.1,2,3.4,4 ( Rupees One Hundred Twenty Three And Paise Forty Four Only )
Rs.1 2 3 4 5 . 6 7 ( Rupees Twelve Thousand Three Hundred Forty Five And Paise Sixty Seven
Only )
Rs.256.256 ( Rupees Two Hundred Fifty Six And Paise Twenty Six Only )
Rs.256.999 ( Rupees Two Hundred Fifty Seven Only )
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Thanks to tic and Manauser for helping out with the RegEx *
* Removing Redundant Spaces / Code required for RegExReplace *
* http://www.autohotkey.com/forum/viewtopic.php?t=29075 *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/
