ok!
User will input a model name in to a variable, so the echo will create a file with this model name, so, another software (in C++) will check in DB and will return with the work instruction for this model.
I'm using Notepad++ for check it, and showed as your UltraEdit, but you can see the line number 2? It's is empty, but my C++ program didn't work with it, I made some test removing this line by manually, and works!
see my codes:
@echo off
cls
:: Network Configuration ::
IPCONFIG /RENEW
NET USE \\105.103.74.60 /user:fabio.b 1qazxdr5
XCOPY \\105.103.74.60\HDDSL\*.* C:\SOPLoader\SOP\ /S /E /Y
MOVE C:\SOPLoader\SOP\profiles.txt C:\SOPLoader
:: GUI CONFIGURATION ::
:START
set wabmp=ld.y
set waico=SL.ico
set wasig=SEDA C - Fabio.b
set wizapp=start /w WizApp.exe
set i0=1
set i1=1
set watitle=HDD SOP Loader
set model=
:: Model Scan ::
:PAGE1
set page=:page1
set wabat=%TEMP%\wabat.bat
set watext=~~~~~~~Código do modelo:
set waoutput=%model%
start /w wizapp noback EB
if errorlevel 2 goto :cancel
if errorlevel 1 goto :PAGE2
call %wabat%
set model=%waoutput%
:: DB access ::
:PAGE2
echo model>mdchk.txt
call MSL.exe
goto START
:cancel
C++ Code MSL
#include <iostream.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <fstream.h>
void print_profile( const char * code, const char * model, const char * sop )
{
char command[50];
cout << "\n\nPROFILE:"
<< "\n\t\t Code: " << code
<< "\n\t\t Model: " << model
<< "\n\t\t SOP: " << sop << "\n \n";
sprintf(command,"%s",sop);
system(command);
exit (1);
}
void find_record( const char * mdchk, const char * database_filename )
{
FILE * file;
if( !(file = fopen(database_filename, "r")) )
{
cout << "\nDatabase filename: " << database_filename << " not found!";
return;
}
char buffer[ 1024 ] = { '\0' };
while( fgets(buffer, 1023, file) )
{
if( strstr(buffer, mdchk) != 0 )
{
char code[ 16 ] = { '\0' };
char model[ 6 ] = { '\0' };
char sop[ 6 ] = { '\0' };
char * pCh = strtok(buffer, ",");
strcpy( code, pCh );
pCh = strtok( 0, "," );
strcpy( model, pCh);
pCh = strtok( 0, "," );
strcpy( sop, pCh );
print_profile( code, model, sop );
fclose( file );
return;
}
}
cout << "\n\n\nMODEL NOT FOUND => Database:" << database_filename;
fclose( file );
}
int main()
{
FILE * file;
if ( !(file = fopen("MDCHK.txt", "r")) )
{
cout << "\n\n\nMDCHK.txt not found!";
return(0);
}
char mdchk[16];
while( fgets(mdchk,15, file) )
{
mdchk[16]='\0';
puts (mdchk);
find_record( mdchk, "profiles.txt" );
return 0;
}
return (0);
}
and profiles.txt:
test,asdf,notepad test.txt,
test2,afds,notepad test2.txt,
Thank you!