Arturo_
13-07-2007, 19:02:14
// **** SPLASH ****
// Por: Arturo Vidal Gómez
// Versión: 1.000.000
// Copyright © 1980, 2007
// Derechos - Reservados
// Arequipa, Perú
// PASCAL - DELPHI (Client Server Suite)
// Ingeniería de Software
unit Splash;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls, ExtCtrls, ComCtrls, jpeg, Gauges, DateUtils;
// For NumbersToLetters
const
// Table Unidades 0 - 9
LIBRARY_Table_0001 : packed array[0..9] of string =
('CERO', 'UNO', 'DOS', 'TRES', 'CUATRO', 'CINCO',
'SEIS', 'SIETE', 'OCHO', 'NUEVE');
// Table Decenas 10 - 19
LIBRARY_Table_0002 : packed array[0..9] of string =
('DIEZ', 'ONCE', 'DOCE', 'TRECE', 'CATORCE', 'QUINCE',
'DIECISEIS', 'DIECISIETE', 'DIECIOCHO', 'DIECINUEVE');
// Table Decenas 20 - 90
LIBRARY_Table_0003 : packed array[2..9] of string =
('VEINTE', 'TREINTA', 'CUARENTA', 'CINCUENTA',
'SESENTA', 'SETENTA', 'OCHENTA', 'NOVENTA');
// Table Centenas 100 - 900
LIBRARY_Table_0004 : packed array[0..9] of string =
('', 'CIEN', 'DOSCIENTOS', 'TRESCIENTOS', 'CUATROCIENTOS',
'QUINIENTOS', 'SEISCIENTOS', 'SETENCIENTOS',
'OCHOCIENTOS', 'NOVECIENTOS');
const
SubChar_ON : Boolean = True; // Enabled Reemplazar UNO por UN
SubChar_OFF : Boolean = False; // Disabled Reemplazar UNO por UN
Sep_NULL : Integer = 0; // Value NULL
Sep_MIL : Integer = 1; // Separador de Miles
Sep_MILLON : Integer = 2; // Separador de Millones
const
asm_POINT : string = '.';
asm_COMET : string = ',';
asm_DECIMALS : string = '0000000000';
asm_VALID : set of char = ['0'..'9', '.', ','];
var
lib_RESULT_CNA : string;
lib_DIGITS_ALF : string;
lib_DIGITS_INT : string;
lib_DIGITS_DEC : string;
lib_TYPE : string;
// INTERFACE Procedimientos para Conversiones
function NumbersToLetters(pmt_NUMBER, pmt_TYPE: string; pmt_DEC: Integer): string; export;
implementation
{$R *.DFM}
// IMPLEMENTATION Procedimientos para Conversiones
// NumbersToLetters Numeros a Letras
function NumbersToLetters(pmt_NUMBER, pmt_TYPE: string; pmt_DEC: Integer): string; export;
var
Loop : Integer;
// Seleccionar TIPO 1 2 ó 3
// TIPO 1 = 0 para las Unidades
// TIPO 2 = 00 para las Decenas
// TIPO 3 = 000 para las Centenas
// 12 Digitos y n Decimales
// 999,000,000,000.00
function Select_TYPE(pmt_DIGITS_INT: string; Flag_SUB: Boolean;
Flag_SEP: Integer): string;
// Seleccionar Separador MIL MILLON...
procedure Select_SEP(pmt_DIGITS_INT: string; Flag_SUB: Boolean;
Flag_SEP: Integer);
begin
if (Flag_SUB) and
(Length(lib_DIGITS_INT) >= 4) and
(Length(lib_DIGITS_INT) <= 12) then
begin
if Flag_SEP = sep_MIL then
lib_DIGITS_ALF := lib_DIGITS_ALF + ' MIL '
else
if Flag_SEP = sep_MILLON then
begin
lib_DIGITS_ALF := lib_DIGITS_ALF + ' MILLONES ';
// Elimina 'ES' de 'MILLONES' si Primer Digito es 1
if (Length(lib_DIGITS_INT) = 7) and
(Copy(pmt_DIGITS_INT, 1, 1) = '1') then
SYSTEM.Delete(lib_DIGITS_ALF, 10, 2);
end;
end;
end;
begin
(* DIGITS = 1 *)
if (Length(pmt_DIGITS_INT) = 1) then
begin
lib_DIGITS_ALF := LIBRARY_Table_0001[StrToInt(pmt_DIGITS_INT)];
// Remplaza UNO por UN
if (Flag_SUB) and
(Copy(pmt_DIGITS_INT, 1, 1) = '1') then
SYSTEM.Delete(lib_DIGITS_ALF, Length(lib_DIGITS_ALF), 1);
Select_SEP(pmt_DIGITS_INT, Flag_SUB, Flag_SEP);
end;
(* DIGITS = 2 *)
if (Length(pmt_DIGITS_INT) = 2) then
begin
// Asigna de 10 - 19
if (Copy(pmt_DIGITS_INT, 1, 1) = '1') then
lib_DIGITS_ALF := LIBRARY_Table_0002[StrToInt(Copy(pmt_DIGITS_INT, 2, 1))]
// Asigna de 20 a 99
else
begin
// Asigna de 20 a 90 Decenas
lib_DIGITS_ALF := LIBRARY_Table_0003[StrToInt(Copy(pmt_DIGITS_INT, 1, 1))];
// Asigna de 20 a 90 Decenas y 21 a 99 Unidades
if (Copy(pmt_DIGITS_INT, 2, 1) <> '0') then
begin
lib_DIGITS_ALF := Copy(lib_DIGITS_ALF, 1, Length(lib_DIGITS_ALF) - 2)
+ 'TI' + LIBRARY_Table_0001[StrToInt(Copy(pmt_DIGITS_INT, 2, 1))];
// Remplaza UNO por UN
if (Flag_SUB) and
(Copy(pmt_DIGITS_INT, 2, 1) = '1') then
SYSTEM.Delete(lib_DIGITS_ALF, Length(lib_DIGITS_ALF), 1);
end;
end;
Select_SEP(pmt_DIGITS_INT, Flag_SUB, Flag_SEP);
end;
(* DIGITS = 3 *)
if (Length(pmt_DIGITS_INT) = 3) then
begin
// Salir si los tres Digitos son cero
if (Copy(pmt_DIGITS_INT, 1, 1) = '0') and
(Copy(pmt_DIGITS_INT, 2, 1) = '0') and
(Copy(pmt_DIGITS_INT, 3, 1) = '0') then
begin
Select_TYPE := '';
Exit;
end;
// Asignar Centenas
lib_DIGITS_ALF := LIBRARY_Table_0004[StrToInt(Copy(pmt_DIGITS_INT, 1, 1))];
// Si el Primer Digito es 1 de 100 a 199 Agregar 'TO'
if (Copy(pmt_DIGITS_INT, 1, 1) = '1') and
((Copy(pmt_DIGITS_INT, 2, 1) <> '0') or
(Copy(pmt_DIGITS_INT, 3, 1) <> '0')) then
lib_DIGITS_ALF := lib_DIGITS_ALF + 'TO '
// Si no Agregar Espacio en Blanco si Primer
// Digito de la Centena no es 0
else
if (Copy(pmt_DIGITS_INT, 1, 1) <> '0') then
lib_DIGITS_ALF := lib_DIGITS_ALF + ' ';
// Si son Centenas Asignar y Salir
if (Copy(pmt_DIGITS_INT, 2, 1) = '0') and
(Copy(pmt_DIGITS_INT, 3, 1) = '0') then
begin
Select_SEP(pmt_DIGITS_INT, Flag_SUB, Flag_SEP);
Select_TYPE := lib_DIGITS_ALF;
Exit;
end;
// Asignar Unidades en Base a Decenas y
// Asignar Decenas en Base a Centenas
// Unidades
if (Copy(pmt_DIGITS_INT, 2, 1) = '0') then
begin
lib_DIGITS_ALF := lib_DIGITS_ALF
+ LIBRARY_Table_0001[StrToInt(Copy(pmt_DIGITS_INT, 3, 1))];
// Remplaza UNO por UN
if (Flag_SUB) and
(Copy(pmt_DIGITS_INT, 2, 1) = '0') and
(Copy(pmt_DIGITS_INT, 3, 1) = '1') then
SYSTEM.Delete(lib_DIGITS_ALF, Length(lib_DIGITS_ALF), 1);
end
// Decenas 10 - 19
else
if (Copy(pmt_DIGITS_INT, 2, 1) = '1') then
lib_DIGITS_ALF := lib_DIGITS_ALF
+ LIBRARY_Table_0002[StrToInt(Copy(pmt_DIGITS_INT, 3, 1))];
// Decenas 20 - 99
if (Copy(pmt_DIGITS_INT, 2, 1) >= '2') then
begin
lib_DIGITS_ALF := lib_DIGITS_ALF
+ LIBRARY_Table_0003[StrToInt(Copy(pmt_DIGITS_INT, 2, 1))];
if (Copy(pmt_DIGITS_INT, 3, 1) <> '0') then
begin
lib_DIGITS_ALF := Copy(lib_DIGITS_ALF, 1, Length(lib_DIGITS_ALF) - 2)
+ 'TI' + LIBRARY_Table_0001[StrToInt(Copy(pmt_DIGITS_INT, 3, 1))];
// Remplaza UNO por UN
if (Flag_SUB) and
(Copy(pmt_DIGITS_INT, 3, 1) = '1') then
SYSTEM.Delete(lib_DIGITS_ALF, Length(lib_DIGITS_ALF), 1);
end;
end;
Select_SEP(pmt_DIGITS_INT, Flag_SUB, Flag_SEP);
end;
Select_TYPE := lib_DIGITS_ALF;
end;
// Main
begin
// Validación Entrada
if (pmt_NUMBER = '') then
begin
NumbersToLetters := '';
Exit;
end;
// Validación de Digitos
for Loop := 1 to Length(pmt_NUMBER) do
begin
if not (pmt_NUMBER[Loop] in asm_VALID) then
begin
NumbersToLetters := 'ERROR: No se Permiten Caracteres Alfabeticos.';
Exit;
end;
end;
// Longitud Permitida en Digitos
if (Pos(asm_POINT, pmt_NUMBER) - 1 > 12) or
(Pos(asm_COMET, pmt_NUMBER) - 1 > 12) then
begin
NumbersToLetters := 'Solo se Permiten Hasta (12) Enteros y (02) Decimales';
Exit;
end;
// Inicializar
lib_RESULT_CNA := '';
lib_DIGITS_ALF := '';
lib_DIGITS_INT := '';
lib_DIGITS_DEC := '';
lib_TYPE := '';
// Seleccionar Tipo de Moneda
if (pmt_TYPE = vk_SOLES) then lib_TYPE := vk_SOLES
else if (pmt_TYPE = vk_DOLAR) then lib_TYPE := vk_DOLAR;
// Extraer Numero Entero y Decimales
if (Pos(asm_POINT, pmt_NUMBER) <> 0) then
begin
lib_DIGITS_INT := Copy(pmt_NUMBER, 1, Pos(asm_POINT, pmt_NUMBER) - 1);
lib_DIGITS_DEC := Copy(pmt_NUMBER, Pos(asm_POINT, pmt_NUMBER) + 1, pmt_DEC);
end
else
if (Pos(asm_COMET, pmt_NUMBER) <> 0) then
begin
lib_DIGITS_INT := Copy(pmt_NUMBER, 1, Pos(asm_COMET, pmt_NUMBER) - 1);
lib_DIGITS_DEC := Copy(pmt_NUMBER, Pos(asm_COMET, pmt_NUMBER) + 1, pmt_DEC);
end
else
begin
lib_DIGITS_INT := pmt_NUMBER;
lib_DIGITS_DEC := Copy(asm_DECIMALS, 1, pmt_DEC);
end;
// Execute_NOW ****
// Length = 1 Format: 9
if Length(lib_DIGITS_INT) = 1 then
lib_RESULT_CNA := Select_TYPE(Copy(lib_DIGITS_INT, 1, 1), SubChar_OFF, Sep_NULL)
// Length = 2 Format: 99
else
if Length(lib_DIGITS_INT) = 2 then
lib_RESULT_CNA := Select_TYPE(Copy(lib_DIGITS_INT, 1, 2), SubChar_OFF, Sep_NULL)
// Length = 3 Format: 999
else
if Length(lib_DIGITS_INT) = 3 then
lib_RESULT_CNA := Select_TYPE(Copy(lib_DIGITS_INT, 1, 3), SubChar_OFF, Sep_NULL)
// Length = 4 Format: 9 999
else
if Length(lib_DIGITS_INT) = 4 then
begin
lib_RESULT_CNA := Select_TYPE(Copy(lib_DIGITS_INT, 1, 1), SubChar_ON, Sep_MIL)
+ Select_TYPE(Copy(lib_DIGITS_INT, 2, 3), SubChar_OFF, Sep_NULL);
end
// Length = 5 Format: 99 999
else
if Length(lib_DIGITS_INT) = 5 then
begin
lib_RESULT_CNA := Select_TYPE(Copy(lib_DIGITS_INT, 1, 2), SubChar_ON, Sep_MIL)
+ Select_TYPE(Copy(lib_DIGITS_INT, 3, 3), SubChar_OFF, Sep_NULL);
end
// Length = 6 Format: 999 999
else
if Length(lib_DIGITS_INT) = 6 then
begin
lib_RESULT_CNA := Select_TYPE(Copy(lib_DIGITS_INT, 1, 3), SubChar_ON, Sep_MIL)
+ Select_TYPE(Copy(lib_DIGITS_INT, 4, 3), SubChar_OFF, Sep_NULL);
end
// Length = 7 Format: 9 999 999
else
if Length(lib_DIGITS_INT) = 7 then
begin
lib_RESULT_CNA := Select_TYPE(Copy(lib_DIGITS_INT, 1, 1), SubChar_ON, Sep_MILLON)
+ Select_TYPE(Copy(lib_DIGITS_INT, 2, 3), SubChar_ON, Sep_MIL)
+ Select_TYPE(Copy(lib_DIGITS_INT, 5, 3), SubChar_OFF, Sep_NULL);
end
// Length = 8 Format: 99 999 999
else
if Length(lib_DIGITS_INT) = 8 then
begin
lib_RESULT_CNA := Select_TYPE(Copy(lib_DIGITS_INT, 1, 2), SubChar_ON, Sep_MILLON)
+ Select_TYPE(Copy(lib_DIGITS_INT, 3, 3), SubChar_ON, Sep_MIL)
+ Select_TYPE(Copy(lib_DIGITS_INT, 6, 3), SubChar_OFF, Sep_NULL);
end
// Length = 9 Format: 999 999 999
else
if Length(lib_DIGITS_INT) = 9 then
begin
lib_RESULT_CNA := Select_TYPE(Copy(lib_DIGITS_INT, 1, 3), SubChar_ON, Sep_MILLON)
+ Select_TYPE(Copy(lib_DIGITS_INT, 4, 3), SubChar_ON, Sep_MIL)
+ Select_TYPE(Copy(lib_DIGITS_INT, 7, 3), SubChar_OFF, Sep_NULL);
end
// Length = 10 Format: 9 999 999 999
else
if Length(lib_DIGITS_INT) = 10 then
begin
lib_RESULT_CNA := Select_TYPE(Copy(lib_DIGITS_INT, 1, 1), SubChar_ON, Sep_MIL)
+ Select_TYPE(Copy(lib_DIGITS_INT, 2, 3), SubChar_ON, Sep_MILLON)
+ Select_TYPE(Copy(lib_DIGITS_INT, 5, 3), SubChar_ON, Sep_MIL)
+ Select_TYPE(Copy(lib_DIGITS_INT, 8, 3), SubChar_OFF, Sep_NULL);
end
// Length = 11 Format: 99 999 999 999
else
if Length(lib_DIGITS_INT) = 11 then
begin
lib_RESULT_CNA := Select_TYPE(Copy(lib_DIGITS_INT, 1, 2), SubChar_ON, Sep_MIL)
+ Select_TYPE(Copy(lib_DIGITS_INT, 3, 3), SubChar_ON, Sep_MILLON)
+ Select_TYPE(Copy(lib_DIGITS_INT, 6, 3), SubChar_ON, Sep_MIL)
+ Select_TYPE(Copy(lib_DIGITS_INT, 9, 3), SubChar_OFF, Sep_NULL);
end
// Length = 12 Format: 999 999 999 999
else
if Length(lib_DIGITS_INT) = 12 then
begin
lib_RESULT_CNA := Select_TYPE(Copy(lib_DIGITS_INT, 1, 3), SubChar_ON, Sep_MIL)
+ Select_TYPE(Copy(lib_DIGITS_INT, 4, 3), SubChar_ON, Sep_MILLON)
+ Select_TYPE(Copy(lib_DIGITS_INT, 7, 3), SubChar_ON, Sep_MIL)
+ Select_TYPE(Copy(lib_DIGITS_INT, 10, 3), SubChar_OFF, Sep_NULL);
end;
// Asignar Resultado
SYSTEM.Insert('SON: ', lib_RESULT_CNA, 1);
lib_RESULT_CNA := lib_RESULT_CNA + ' Y ' + lib_DIGITS_DEC + '/100' + lib_TYPE;
NumbersToLetters := lib_RESULT_CNA;
end;
end.
//Edite: Para colocar etiquetas DELPHI.
// Por: Arturo Vidal Gómez
// Versión: 1.000.000
// Copyright © 1980, 2007
// Derechos - Reservados
// Arequipa, Perú
// PASCAL - DELPHI (Client Server Suite)
// Ingeniería de Software
unit Splash;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls, ExtCtrls, ComCtrls, jpeg, Gauges, DateUtils;
// For NumbersToLetters
const
// Table Unidades 0 - 9
LIBRARY_Table_0001 : packed array[0..9] of string =
('CERO', 'UNO', 'DOS', 'TRES', 'CUATRO', 'CINCO',
'SEIS', 'SIETE', 'OCHO', 'NUEVE');
// Table Decenas 10 - 19
LIBRARY_Table_0002 : packed array[0..9] of string =
('DIEZ', 'ONCE', 'DOCE', 'TRECE', 'CATORCE', 'QUINCE',
'DIECISEIS', 'DIECISIETE', 'DIECIOCHO', 'DIECINUEVE');
// Table Decenas 20 - 90
LIBRARY_Table_0003 : packed array[2..9] of string =
('VEINTE', 'TREINTA', 'CUARENTA', 'CINCUENTA',
'SESENTA', 'SETENTA', 'OCHENTA', 'NOVENTA');
// Table Centenas 100 - 900
LIBRARY_Table_0004 : packed array[0..9] of string =
('', 'CIEN', 'DOSCIENTOS', 'TRESCIENTOS', 'CUATROCIENTOS',
'QUINIENTOS', 'SEISCIENTOS', 'SETENCIENTOS',
'OCHOCIENTOS', 'NOVECIENTOS');
const
SubChar_ON : Boolean = True; // Enabled Reemplazar UNO por UN
SubChar_OFF : Boolean = False; // Disabled Reemplazar UNO por UN
Sep_NULL : Integer = 0; // Value NULL
Sep_MIL : Integer = 1; // Separador de Miles
Sep_MILLON : Integer = 2; // Separador de Millones
const
asm_POINT : string = '.';
asm_COMET : string = ',';
asm_DECIMALS : string = '0000000000';
asm_VALID : set of char = ['0'..'9', '.', ','];
var
lib_RESULT_CNA : string;
lib_DIGITS_ALF : string;
lib_DIGITS_INT : string;
lib_DIGITS_DEC : string;
lib_TYPE : string;
// INTERFACE Procedimientos para Conversiones
function NumbersToLetters(pmt_NUMBER, pmt_TYPE: string; pmt_DEC: Integer): string; export;
implementation
{$R *.DFM}
// IMPLEMENTATION Procedimientos para Conversiones
// NumbersToLetters Numeros a Letras
function NumbersToLetters(pmt_NUMBER, pmt_TYPE: string; pmt_DEC: Integer): string; export;
var
Loop : Integer;
// Seleccionar TIPO 1 2 ó 3
// TIPO 1 = 0 para las Unidades
// TIPO 2 = 00 para las Decenas
// TIPO 3 = 000 para las Centenas
// 12 Digitos y n Decimales
// 999,000,000,000.00
function Select_TYPE(pmt_DIGITS_INT: string; Flag_SUB: Boolean;
Flag_SEP: Integer): string;
// Seleccionar Separador MIL MILLON...
procedure Select_SEP(pmt_DIGITS_INT: string; Flag_SUB: Boolean;
Flag_SEP: Integer);
begin
if (Flag_SUB) and
(Length(lib_DIGITS_INT) >= 4) and
(Length(lib_DIGITS_INT) <= 12) then
begin
if Flag_SEP = sep_MIL then
lib_DIGITS_ALF := lib_DIGITS_ALF + ' MIL '
else
if Flag_SEP = sep_MILLON then
begin
lib_DIGITS_ALF := lib_DIGITS_ALF + ' MILLONES ';
// Elimina 'ES' de 'MILLONES' si Primer Digito es 1
if (Length(lib_DIGITS_INT) = 7) and
(Copy(pmt_DIGITS_INT, 1, 1) = '1') then
SYSTEM.Delete(lib_DIGITS_ALF, 10, 2);
end;
end;
end;
begin
(* DIGITS = 1 *)
if (Length(pmt_DIGITS_INT) = 1) then
begin
lib_DIGITS_ALF := LIBRARY_Table_0001[StrToInt(pmt_DIGITS_INT)];
// Remplaza UNO por UN
if (Flag_SUB) and
(Copy(pmt_DIGITS_INT, 1, 1) = '1') then
SYSTEM.Delete(lib_DIGITS_ALF, Length(lib_DIGITS_ALF), 1);
Select_SEP(pmt_DIGITS_INT, Flag_SUB, Flag_SEP);
end;
(* DIGITS = 2 *)
if (Length(pmt_DIGITS_INT) = 2) then
begin
// Asigna de 10 - 19
if (Copy(pmt_DIGITS_INT, 1, 1) = '1') then
lib_DIGITS_ALF := LIBRARY_Table_0002[StrToInt(Copy(pmt_DIGITS_INT, 2, 1))]
// Asigna de 20 a 99
else
begin
// Asigna de 20 a 90 Decenas
lib_DIGITS_ALF := LIBRARY_Table_0003[StrToInt(Copy(pmt_DIGITS_INT, 1, 1))];
// Asigna de 20 a 90 Decenas y 21 a 99 Unidades
if (Copy(pmt_DIGITS_INT, 2, 1) <> '0') then
begin
lib_DIGITS_ALF := Copy(lib_DIGITS_ALF, 1, Length(lib_DIGITS_ALF) - 2)
+ 'TI' + LIBRARY_Table_0001[StrToInt(Copy(pmt_DIGITS_INT, 2, 1))];
// Remplaza UNO por UN
if (Flag_SUB) and
(Copy(pmt_DIGITS_INT, 2, 1) = '1') then
SYSTEM.Delete(lib_DIGITS_ALF, Length(lib_DIGITS_ALF), 1);
end;
end;
Select_SEP(pmt_DIGITS_INT, Flag_SUB, Flag_SEP);
end;
(* DIGITS = 3 *)
if (Length(pmt_DIGITS_INT) = 3) then
begin
// Salir si los tres Digitos son cero
if (Copy(pmt_DIGITS_INT, 1, 1) = '0') and
(Copy(pmt_DIGITS_INT, 2, 1) = '0') and
(Copy(pmt_DIGITS_INT, 3, 1) = '0') then
begin
Select_TYPE := '';
Exit;
end;
// Asignar Centenas
lib_DIGITS_ALF := LIBRARY_Table_0004[StrToInt(Copy(pmt_DIGITS_INT, 1, 1))];
// Si el Primer Digito es 1 de 100 a 199 Agregar 'TO'
if (Copy(pmt_DIGITS_INT, 1, 1) = '1') and
((Copy(pmt_DIGITS_INT, 2, 1) <> '0') or
(Copy(pmt_DIGITS_INT, 3, 1) <> '0')) then
lib_DIGITS_ALF := lib_DIGITS_ALF + 'TO '
// Si no Agregar Espacio en Blanco si Primer
// Digito de la Centena no es 0
else
if (Copy(pmt_DIGITS_INT, 1, 1) <> '0') then
lib_DIGITS_ALF := lib_DIGITS_ALF + ' ';
// Si son Centenas Asignar y Salir
if (Copy(pmt_DIGITS_INT, 2, 1) = '0') and
(Copy(pmt_DIGITS_INT, 3, 1) = '0') then
begin
Select_SEP(pmt_DIGITS_INT, Flag_SUB, Flag_SEP);
Select_TYPE := lib_DIGITS_ALF;
Exit;
end;
// Asignar Unidades en Base a Decenas y
// Asignar Decenas en Base a Centenas
// Unidades
if (Copy(pmt_DIGITS_INT, 2, 1) = '0') then
begin
lib_DIGITS_ALF := lib_DIGITS_ALF
+ LIBRARY_Table_0001[StrToInt(Copy(pmt_DIGITS_INT, 3, 1))];
// Remplaza UNO por UN
if (Flag_SUB) and
(Copy(pmt_DIGITS_INT, 2, 1) = '0') and
(Copy(pmt_DIGITS_INT, 3, 1) = '1') then
SYSTEM.Delete(lib_DIGITS_ALF, Length(lib_DIGITS_ALF), 1);
end
// Decenas 10 - 19
else
if (Copy(pmt_DIGITS_INT, 2, 1) = '1') then
lib_DIGITS_ALF := lib_DIGITS_ALF
+ LIBRARY_Table_0002[StrToInt(Copy(pmt_DIGITS_INT, 3, 1))];
// Decenas 20 - 99
if (Copy(pmt_DIGITS_INT, 2, 1) >= '2') then
begin
lib_DIGITS_ALF := lib_DIGITS_ALF
+ LIBRARY_Table_0003[StrToInt(Copy(pmt_DIGITS_INT, 2, 1))];
if (Copy(pmt_DIGITS_INT, 3, 1) <> '0') then
begin
lib_DIGITS_ALF := Copy(lib_DIGITS_ALF, 1, Length(lib_DIGITS_ALF) - 2)
+ 'TI' + LIBRARY_Table_0001[StrToInt(Copy(pmt_DIGITS_INT, 3, 1))];
// Remplaza UNO por UN
if (Flag_SUB) and
(Copy(pmt_DIGITS_INT, 3, 1) = '1') then
SYSTEM.Delete(lib_DIGITS_ALF, Length(lib_DIGITS_ALF), 1);
end;
end;
Select_SEP(pmt_DIGITS_INT, Flag_SUB, Flag_SEP);
end;
Select_TYPE := lib_DIGITS_ALF;
end;
// Main
begin
// Validación Entrada
if (pmt_NUMBER = '') then
begin
NumbersToLetters := '';
Exit;
end;
// Validación de Digitos
for Loop := 1 to Length(pmt_NUMBER) do
begin
if not (pmt_NUMBER[Loop] in asm_VALID) then
begin
NumbersToLetters := 'ERROR: No se Permiten Caracteres Alfabeticos.';
Exit;
end;
end;
// Longitud Permitida en Digitos
if (Pos(asm_POINT, pmt_NUMBER) - 1 > 12) or
(Pos(asm_COMET, pmt_NUMBER) - 1 > 12) then
begin
NumbersToLetters := 'Solo se Permiten Hasta (12) Enteros y (02) Decimales';
Exit;
end;
// Inicializar
lib_RESULT_CNA := '';
lib_DIGITS_ALF := '';
lib_DIGITS_INT := '';
lib_DIGITS_DEC := '';
lib_TYPE := '';
// Seleccionar Tipo de Moneda
if (pmt_TYPE = vk_SOLES) then lib_TYPE := vk_SOLES
else if (pmt_TYPE = vk_DOLAR) then lib_TYPE := vk_DOLAR;
// Extraer Numero Entero y Decimales
if (Pos(asm_POINT, pmt_NUMBER) <> 0) then
begin
lib_DIGITS_INT := Copy(pmt_NUMBER, 1, Pos(asm_POINT, pmt_NUMBER) - 1);
lib_DIGITS_DEC := Copy(pmt_NUMBER, Pos(asm_POINT, pmt_NUMBER) + 1, pmt_DEC);
end
else
if (Pos(asm_COMET, pmt_NUMBER) <> 0) then
begin
lib_DIGITS_INT := Copy(pmt_NUMBER, 1, Pos(asm_COMET, pmt_NUMBER) - 1);
lib_DIGITS_DEC := Copy(pmt_NUMBER, Pos(asm_COMET, pmt_NUMBER) + 1, pmt_DEC);
end
else
begin
lib_DIGITS_INT := pmt_NUMBER;
lib_DIGITS_DEC := Copy(asm_DECIMALS, 1, pmt_DEC);
end;
// Execute_NOW ****
// Length = 1 Format: 9
if Length(lib_DIGITS_INT) = 1 then
lib_RESULT_CNA := Select_TYPE(Copy(lib_DIGITS_INT, 1, 1), SubChar_OFF, Sep_NULL)
// Length = 2 Format: 99
else
if Length(lib_DIGITS_INT) = 2 then
lib_RESULT_CNA := Select_TYPE(Copy(lib_DIGITS_INT, 1, 2), SubChar_OFF, Sep_NULL)
// Length = 3 Format: 999
else
if Length(lib_DIGITS_INT) = 3 then
lib_RESULT_CNA := Select_TYPE(Copy(lib_DIGITS_INT, 1, 3), SubChar_OFF, Sep_NULL)
// Length = 4 Format: 9 999
else
if Length(lib_DIGITS_INT) = 4 then
begin
lib_RESULT_CNA := Select_TYPE(Copy(lib_DIGITS_INT, 1, 1), SubChar_ON, Sep_MIL)
+ Select_TYPE(Copy(lib_DIGITS_INT, 2, 3), SubChar_OFF, Sep_NULL);
end
// Length = 5 Format: 99 999
else
if Length(lib_DIGITS_INT) = 5 then
begin
lib_RESULT_CNA := Select_TYPE(Copy(lib_DIGITS_INT, 1, 2), SubChar_ON, Sep_MIL)
+ Select_TYPE(Copy(lib_DIGITS_INT, 3, 3), SubChar_OFF, Sep_NULL);
end
// Length = 6 Format: 999 999
else
if Length(lib_DIGITS_INT) = 6 then
begin
lib_RESULT_CNA := Select_TYPE(Copy(lib_DIGITS_INT, 1, 3), SubChar_ON, Sep_MIL)
+ Select_TYPE(Copy(lib_DIGITS_INT, 4, 3), SubChar_OFF, Sep_NULL);
end
// Length = 7 Format: 9 999 999
else
if Length(lib_DIGITS_INT) = 7 then
begin
lib_RESULT_CNA := Select_TYPE(Copy(lib_DIGITS_INT, 1, 1), SubChar_ON, Sep_MILLON)
+ Select_TYPE(Copy(lib_DIGITS_INT, 2, 3), SubChar_ON, Sep_MIL)
+ Select_TYPE(Copy(lib_DIGITS_INT, 5, 3), SubChar_OFF, Sep_NULL);
end
// Length = 8 Format: 99 999 999
else
if Length(lib_DIGITS_INT) = 8 then
begin
lib_RESULT_CNA := Select_TYPE(Copy(lib_DIGITS_INT, 1, 2), SubChar_ON, Sep_MILLON)
+ Select_TYPE(Copy(lib_DIGITS_INT, 3, 3), SubChar_ON, Sep_MIL)
+ Select_TYPE(Copy(lib_DIGITS_INT, 6, 3), SubChar_OFF, Sep_NULL);
end
// Length = 9 Format: 999 999 999
else
if Length(lib_DIGITS_INT) = 9 then
begin
lib_RESULT_CNA := Select_TYPE(Copy(lib_DIGITS_INT, 1, 3), SubChar_ON, Sep_MILLON)
+ Select_TYPE(Copy(lib_DIGITS_INT, 4, 3), SubChar_ON, Sep_MIL)
+ Select_TYPE(Copy(lib_DIGITS_INT, 7, 3), SubChar_OFF, Sep_NULL);
end
// Length = 10 Format: 9 999 999 999
else
if Length(lib_DIGITS_INT) = 10 then
begin
lib_RESULT_CNA := Select_TYPE(Copy(lib_DIGITS_INT, 1, 1), SubChar_ON, Sep_MIL)
+ Select_TYPE(Copy(lib_DIGITS_INT, 2, 3), SubChar_ON, Sep_MILLON)
+ Select_TYPE(Copy(lib_DIGITS_INT, 5, 3), SubChar_ON, Sep_MIL)
+ Select_TYPE(Copy(lib_DIGITS_INT, 8, 3), SubChar_OFF, Sep_NULL);
end
// Length = 11 Format: 99 999 999 999
else
if Length(lib_DIGITS_INT) = 11 then
begin
lib_RESULT_CNA := Select_TYPE(Copy(lib_DIGITS_INT, 1, 2), SubChar_ON, Sep_MIL)
+ Select_TYPE(Copy(lib_DIGITS_INT, 3, 3), SubChar_ON, Sep_MILLON)
+ Select_TYPE(Copy(lib_DIGITS_INT, 6, 3), SubChar_ON, Sep_MIL)
+ Select_TYPE(Copy(lib_DIGITS_INT, 9, 3), SubChar_OFF, Sep_NULL);
end
// Length = 12 Format: 999 999 999 999
else
if Length(lib_DIGITS_INT) = 12 then
begin
lib_RESULT_CNA := Select_TYPE(Copy(lib_DIGITS_INT, 1, 3), SubChar_ON, Sep_MIL)
+ Select_TYPE(Copy(lib_DIGITS_INT, 4, 3), SubChar_ON, Sep_MILLON)
+ Select_TYPE(Copy(lib_DIGITS_INT, 7, 3), SubChar_ON, Sep_MIL)
+ Select_TYPE(Copy(lib_DIGITS_INT, 10, 3), SubChar_OFF, Sep_NULL);
end;
// Asignar Resultado
SYSTEM.Insert('SON: ', lib_RESULT_CNA, 1);
lib_RESULT_CNA := lib_RESULT_CNA + ' Y ' + lib_DIGITS_DEC + '/100' + lib_TYPE;
NumbersToLetters := lib_RESULT_CNA;
end;
end.
//Edite: Para colocar etiquetas DELPHI.