PROCEDURE MYPADL
LPARAMETERS tncValor,tnResultSize,tcPadChar ,tcForcePoint
*!* -------------------------------------------------------------------
*!* Prepara tncValor para Padl()
*!* -------------------------------------------------------------------
*!* tncValor Character , Number (Abs(tncValor))
*!* En otro caso devolverá el TRANSFORM(tncValor)
*!* Si es Number puede contener decimales
*!* tnResultSize Cantidad de dígitos totales enteros
*!* Si es Number con Decimals se agregan nDec + 1
*!* tcPadChar Carácter de relleno (Defalut = "0")
*!* tcForcePoint Forzar un separador decimal distinto de SET("Point")
*!* Por defeto es el valor de SET("Point")
*!* -------------------------------------------------------------------
local lcExtrae, lcType,lcREturn,lcDecimals,lcPoint
lcDecimals = ""
lcPoint = SET("Point")
tcForcePoint =EVL(tcForcePoint , lcPoint )
tcPadChar=iif(Vartype(tcPadChar)#"C","0",tcPadChar)
IF VARTYPE(tnResultSize)#"N"
tnResultSize=0
ENDIF
lcType=Vartype(tncValor)
IF lcType="N"
tncValor=ABS(tncValor)
lcDecimals = GETWORDNUM(TRANSFORM(tncValor),2, lcPoint )
tnResultSize = MAX(tnResultSize ,LEN(GETWORDNUM(TRANSFORM(tncValor),1,lcPOint) ) )
IF NOT EMPTY(lcDecimals)
lcDecimals=tcForcePoint + lcDecimals
ENDIF
ENDIF
lcReturn = ICASE(lcType="N",PADL(transform(int(tncValor)),tnResultSize,tcPadChar),;
lcType="C",PADL(CHRTRAN(tncValor,CHRTRAN(tncValor,"1234567890",""),""),tnResultSize,tcPadChar),;
TRANSFORM(tncValor) ) + lcDecimals
RETURN lcReturn
ENDPROC