First commit 27/02/2001
This commit is contained in:
commit
3d8ed4020f
9
README.md
Normal file
9
README.md
Normal file
@ -0,0 +1,9 @@
|
||||
#ExpansorHTML
|
||||
|
||||
|
||||
*27/02/2001*
|
||||
|
||||
ToDo: wwtcf?
|
||||
|
||||
|
||||

|
107
expansor.bpr
Normal file
107
expansor.bpr
Normal file
@ -0,0 +1,107 @@
|
||||
<?xml version='1.0' encoding='utf-8' ?>
|
||||
<!-- C++Builder XML Project -->
|
||||
<PROJECT>
|
||||
<MACROS>
|
||||
<VERSION value="BCB.05.03"/>
|
||||
<PROJECT value="expansor.exe"/>
|
||||
<OBJFILES value="expansor.obj"/>
|
||||
<RESFILES value=""/>
|
||||
<IDLFILES value=""/>
|
||||
<IDLGENFILES value=""/>
|
||||
<DEFFILE value=""/>
|
||||
<RESDEPEN value="$(RESFILES)"/>
|
||||
<LIBFILES value=""/>
|
||||
<LIBRARIES value="vclbde50.lib vcldb50.lib vcl50.lib"/>
|
||||
<SPARELIBS value="vcl50.lib vcldb50.lib vclbde50.lib"/>
|
||||
<PACKAGES value=""/>
|
||||
<PATHCPP value=".;"/>
|
||||
<PATHPAS value=".;"/>
|
||||
<PATHRC value=".;"/>
|
||||
<PATHASM value=".;"/>
|
||||
<DEBUGLIBPATH value="$(BCB)\lib\debug"/>
|
||||
<RELEASELIBPATH value="$(BCB)\lib\release"/>
|
||||
<LINKER value="ilink32"/>
|
||||
<USERDEFINES value=""/>
|
||||
<SYSDEFINES value="NO_STRICT"/>
|
||||
<MAINSOURCE value="expansor.cpp"/>
|
||||
<INCLUDEPATH value="$(BCB)\include;$(BCB)\include\vcl"/>
|
||||
<LIBPATH value="$(BCB)\lib\obj;$(BCB)\lib"/>
|
||||
<WARNINGS value="-w-par -w-8027 -w-8026"/>
|
||||
<WARNOPTSTR value=""/>
|
||||
</MACROS>
|
||||
<OPTIONS>
|
||||
<IDLCFLAGS value="-src_suffix cpp -I$(BCB)\include -I$(BCB)\include\vcl -boa"/>
|
||||
<CFLAG1 value="-Od -H=c:\PROGRAM\CBUILDER\CBUILD~1\lib\vcl35.csm -Hc -Vx -Ve -X- -r- -a8
|
||||
-b- -k -y -v -vi- -c -tWC -Tkh30000 -tWM"/>
|
||||
<CFLAG2 value=""/>
|
||||
<CFLAG3 value=""/>
|
||||
<PFLAGS value="-$YD -$W -$O- -v -M -JPHNE"/>
|
||||
<RFLAGS value=""/>
|
||||
<AFLAGS value="/mx /w2 /zd"/>
|
||||
<LFLAGS value="-D"" -ap -Tpe -x -Gn -v"/>
|
||||
<IFLAGS value=""/>
|
||||
</OPTIONS>
|
||||
<LINKER>
|
||||
<ALLOBJ value="c0x32.obj $(OBJFILES)"/>
|
||||
<ALLRES value="$(RESFILES)"/>
|
||||
<ALLLIB value="$(LIBFILES) $(LIBRARIES) import32.lib cp32mt.lib"/>
|
||||
</LINKER>
|
||||
<IDEOPTIONS>
|
||||
[Version Info]
|
||||
IncludeVerInfo=0
|
||||
AutoIncBuild=0
|
||||
MajorVer=1
|
||||
MinorVer=0
|
||||
Release=0
|
||||
Build=0
|
||||
Debug=0
|
||||
PreRelease=0
|
||||
Special=0
|
||||
Private=0
|
||||
DLL=0
|
||||
Locale=3082
|
||||
CodePage=1252
|
||||
|
||||
[Version Info Keys]
|
||||
CompanyName=
|
||||
FileDescription=Executable (Console)
|
||||
FileVersion=1.0.0.0
|
||||
InternalName=
|
||||
LegalCopyright=
|
||||
LegalTrademarks=
|
||||
OriginalFilename=
|
||||
ProductName=
|
||||
ProductVersion=1.0.0.0
|
||||
Comments=
|
||||
|
||||
[HistoryLists\hlRunParameters]
|
||||
Count=2
|
||||
Item0=t tb_ref.db
|
||||
Item1=t t
|
||||
|
||||
[Debugging]
|
||||
DebugSourceDirs=$(BCB)\source\vcl
|
||||
|
||||
[Parameters]
|
||||
RunParams=
|
||||
HostApplication=
|
||||
RemoteHost=
|
||||
RemotePath=
|
||||
RemoteDebug=0
|
||||
|
||||
[Compiler]
|
||||
ShowInfoMsgs=0
|
||||
LinkDebugVcl=1
|
||||
LinkCGLIB=0
|
||||
|
||||
[CORBA]
|
||||
AddServerUnit=1
|
||||
AddClientUnit=1
|
||||
PrecompiledHeaders=1
|
||||
|
||||
[Language]
|
||||
ActiveLang=
|
||||
ProjectLang=
|
||||
RootDir=
|
||||
</IDEOPTIONS>
|
||||
</PROJECT>
|
232
expansor.cpp
Normal file
232
expansor.cpp
Normal file
@ -0,0 +1,232 @@
|
||||
#include <vcl\math.hpp>
|
||||
#include <vcl\DB.hpp>
|
||||
#include <vcl\DBTables.hpp>
|
||||
|
||||
#include <iostream.h>
|
||||
#include <condefs.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <io.h>
|
||||
|
||||
#pragma hdrstop
|
||||
|
||||
int file_exists(char *filename);
|
||||
void Expande( char *Texto, char *Origen );
|
||||
int findTAG( FILE *handle, char *TAG );
|
||||
char * scanUntil( char *text, char Terminador );
|
||||
char * scanUntil( FILE *handle, char Terminador, char *buffer );
|
||||
|
||||
bool SinDecimales;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma argsused
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if ( argc < 3 )
|
||||
{
|
||||
cout << "Expansor de Datos\n";
|
||||
cout << "-----------------\n\n";
|
||||
cout << "Parámetros insuficientes: [documento_a_expandir] [origen_de_datos] \n\n";
|
||||
cout << "<EXT ID=\"campo del id\" IDV=\"valor de concordancia\" C=\"campo a mostrar\"></EXT>\n\n";
|
||||
} else {
|
||||
|
||||
if ( argc == 4 ) SinDecimales = false; else SinDecimales = true;
|
||||
|
||||
if ( !file_exists( argv[1] ) )
|
||||
{
|
||||
cout << "El documento a expandir no existe: " << argv[1];
|
||||
} else {
|
||||
if ( !file_exists( argv[2] ) )
|
||||
{
|
||||
cout << "El origen de datos no existe: " << argv[2];
|
||||
} else
|
||||
Expande( argv[1], argv[2] );
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int file_exists(char *filename)
|
||||
{
|
||||
return (access(filename, 0) == 0);
|
||||
}
|
||||
|
||||
/*
|
||||
<EXT ID="nombre del ID" IDV="valor que debe tener" C="campo de resultados"></EXT>
|
||||
|
||||
opcionalmente: F="1.16" (factor de multiplicación)
|
||||
*/
|
||||
void Expande( char *Texto, char *Origen )
|
||||
{
|
||||
FILE *handle; char digit, buffer[80], *buff;
|
||||
AnsiString IDnombre, IDvalor, Campo_n, FactorM, dev;
|
||||
float Factor;
|
||||
|
||||
buffer[79] = '\0';
|
||||
|
||||
TTable *TbOrigen;
|
||||
|
||||
TbOrigen = new TTable(0);
|
||||
|
||||
TbOrigen->TableName = AnsiString( Origen );
|
||||
try {
|
||||
TbOrigen->Active = true;
|
||||
} catch(...) {
|
||||
puts( "\nERROR GRABE ABRIENDO ORIGEN\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( (handle = fopen( Texto, "r") ) == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
while ( !feof( handle ) )
|
||||
{
|
||||
if ( findTAG( handle, "<EXT ID=\"" ) )
|
||||
{
|
||||
IDnombre = AnsiString( scanUntil( handle, '\"', buffer ) );
|
||||
findTAG( handle, "IDV=\"" );
|
||||
IDvalor = AnsiString( scanUntil( handle, '\"', buffer ) );
|
||||
findTAG( handle, "C=\"" );
|
||||
Campo_n = AnsiString( scanUntil( handle, '\"', buffer ) );
|
||||
|
||||
scanUntil( handle, '>', buffer ); // Buscamos en buffer si hay parámetros opcionales
|
||||
FactorM = AnsiString( buffer );
|
||||
digit = FactorM.Pos( "F=\"" );
|
||||
|
||||
|
||||
if ( TbOrigen->FindField( Campo_n ) == NULL )
|
||||
{
|
||||
dev = "ERROR ACCEDIENDO AL DESTINO: " + Campo_n + " ";
|
||||
} else {
|
||||
|
||||
// Buscamos en la base de datos y...
|
||||
try {
|
||||
if ( !TbOrigen->Locate( IDnombre, IDvalor, TLocateOptions() << loCaseInsensitive ) )
|
||||
dev = "Valor: " + IDvalor + " no encontrado en: " + IDnombre + " ";
|
||||
} catch(...) {
|
||||
dev = "ERROR ACCEDIENDO AL CAMPO: " + IDnombre + " ";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( digit )
|
||||
{
|
||||
StrLCopy( buffer, (FactorM.SubString( digit+3, FactorM.Length() - digit+1 ) ).c_str(), 79 );
|
||||
scanUntil( buffer, '\"' );
|
||||
try {
|
||||
Factor = atof( buffer );
|
||||
}catch(...){
|
||||
dev = "El campo FACTOR debe ser numérico";
|
||||
}
|
||||
|
||||
//Aplicamos el Valor del campo deseado X el factor de escala
|
||||
try {
|
||||
if ( TbOrigen->FindField( Campo_n ) != NULL )
|
||||
{
|
||||
dev = TbOrigen->FieldByName( Campo_n )->AsString;
|
||||
if ( SinDecimales )
|
||||
dev = FormatCurr( "###,###,##0;0; ", dev.ToDouble() * Factor );
|
||||
//AnsiString( Ceil( dev.ToDouble() * Factor) );
|
||||
else
|
||||
dev = FormatCurr( "###,###,###.#0;0; ", dev.ToDouble() * Factor );
|
||||
}
|
||||
} catch( ... ) {
|
||||
dev = "El campo: "+Campo_n+" no es NUMERICO ";
|
||||
}
|
||||
|
||||
} else {
|
||||
//Soltamos el Valor del campo deseado
|
||||
if ( TbOrigen->FindField( Campo_n ) != NULL )
|
||||
dev = TbOrigen->FieldByName( Campo_n )->AsString;
|
||||
}
|
||||
|
||||
printf( "%s", dev.c_str() );
|
||||
|
||||
findTAG( handle, "</EXT>" );
|
||||
}
|
||||
}
|
||||
|
||||
fclose(handle);
|
||||
|
||||
TbOrigen->Active = false;
|
||||
delete TbOrigen;
|
||||
|
||||
}
|
||||
|
||||
char * scanUntil( FILE *handle, char Terminador, char *buffer )
|
||||
{
|
||||
char digit;
|
||||
char *buff;
|
||||
int count;
|
||||
|
||||
count = 0;
|
||||
buff = buffer;
|
||||
digit = fgetc( handle );
|
||||
while ( !feof( handle ) && digit != Terminador && count<32 )
|
||||
{
|
||||
*buff = digit;
|
||||
buff ++;
|
||||
count ++;
|
||||
digit = fgetc( handle );
|
||||
}
|
||||
*buff = '\0';
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
char * scanUntil( char *text, char Terminador )
|
||||
{
|
||||
char *buff;
|
||||
|
||||
buff = text;
|
||||
|
||||
while ( *buff != '\0' && *buff != Terminador )
|
||||
buff++;
|
||||
|
||||
*buff = '\0';
|
||||
|
||||
return buff;
|
||||
}
|
||||
|
||||
int findTAG( FILE *handle, char *TAG )
|
||||
{
|
||||
char digit; char *TAG2, *TAG3;
|
||||
|
||||
do {
|
||||
TAG2 = TAG;
|
||||
digit = fgetc( handle );
|
||||
while( digit != *TAG2 && !feof(handle) )
|
||||
{
|
||||
fputchar( digit );
|
||||
digit = fgetc( handle );
|
||||
}
|
||||
|
||||
while( digit == *TAG2 && !feof( handle ) )
|
||||
{
|
||||
TAG2++;
|
||||
if ( *TAG2 != '\0' )
|
||||
digit = fgetc( handle );
|
||||
}
|
||||
|
||||
if ( *TAG2 != '\0' )
|
||||
{
|
||||
TAG3 = TAG;
|
||||
while ( TAG3 != TAG2 )
|
||||
{
|
||||
fputchar( *TAG3 );
|
||||
TAG3++;
|
||||
}
|
||||
fputchar( digit );
|
||||
if ( feof( handle ) )
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
} while( 1 );
|
||||
|
||||
return 0;
|
||||
}
|
BIN
expansor.exe
Normal file
BIN
expansor.exe
Normal file
Binary file not shown.
17
t
Normal file
17
t
Normal file
@ -0,0 +1,17 @@
|
||||
o
|
||||
esto solo es una prueba <ex
|
||||
para probar<exro <EXT ID="ID Producto" IDV="cjmtat" C="Nombre del Producto">buscar en la base de datos</EXT>ksldf
|
||||
<extnew wt rtt
|
||||
<ext fdgs¤ s<ext fgd
|
||||
ewrew
|
||||
rewrewrew
|
||||
rewr
|
||||
<EXT ID="campo del id" IDV="valor de concordancia" C="campo a mostrar"></EXT>ewrew
|
||||
rewrew
|
||||
rewrew
|
||||
rewr
|
||||
<EXT ID="ID Producto" IDV="112" C="Nombre del Producto" F="1.16"></EXT>
|
||||
ew
|
||||
<EXT ID="ID Producto" IDV="112" C="Precio Venta 1" ></EXT>
|
||||
sd
|
||||
<EXT ID="ID Producto" IDV="112" C="Nombre del Producto" ></EXT> == <EXT ID="ID Producto" IDV="112" C="Precio Venta 1" F="1.16"></EXT>
|
Loading…
x
Reference in New Issue
Block a user