Comments translated from French to English.
parent
5649419a46
commit
c2be3181ac
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Variables statiques
|
// Static variables
|
||||||
|
|
||||||
static CBotClass* m_pClassFILE;
|
static CBotClass* m_pClassFILE;
|
||||||
static CBotProgram* m_pFuncFile;
|
static CBotProgram* m_pFuncFile;
|
||||||
|
@ -25,7 +25,7 @@ static char* m_filesDir;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Pr<EFBFBD>pare un nom de fichier.
|
// Prepares a file name.
|
||||||
|
|
||||||
void PrepareFilename(CBotString &filename)
|
void PrepareFilename(CBotString &filename)
|
||||||
{
|
{
|
||||||
|
@ -34,67 +34,67 @@ void PrepareFilename(CBotString &filename)
|
||||||
pos = filename.ReverseFind('\\');
|
pos = filename.ReverseFind('\\');
|
||||||
if ( pos > 0 )
|
if ( pos > 0 )
|
||||||
{
|
{
|
||||||
filename = filename.Mid(pos+1); // enl<6E>ve les dossiers
|
filename = filename.Mid(pos+1); // Remove files with \\
|
||||||
}
|
}
|
||||||
|
|
||||||
pos = filename.ReverseFind('/');
|
pos = filename.ReverseFind('/');
|
||||||
if ( pos > 0 )
|
if ( pos > 0 )
|
||||||
{
|
{
|
||||||
filename = filename.Mid(pos+1); // aussi ceux avec /
|
filename = filename.Mid(pos+1); // also with /
|
||||||
}
|
}
|
||||||
|
|
||||||
pos = filename.ReverseFind(':');
|
pos = filename.ReverseFind(':');
|
||||||
if ( pos > 0 )
|
if ( pos > 0 )
|
||||||
{
|
{
|
||||||
filename = filename.Mid(pos+1); // enl<EFBFBD>ve aussi la lettre d'unit<69> C:
|
filename = filename.Mid(pos+1); // also removes the drive letter C:
|
||||||
}
|
}
|
||||||
|
|
||||||
filename = CBotString(m_filesDir) + CBotString("\\") + filename;
|
filename = CBotString(m_filesDir) + CBotString("\\") + filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// constructeur de la classe
|
// constructor of the class
|
||||||
// re<EFBFBD>ois le nom du fichier en param<61>tre
|
// get the filename as a parameter
|
||||||
|
|
||||||
// ex<EFBFBD>cution
|
// execution
|
||||||
BOOL rfconstruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
BOOL rfconstruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||||
{
|
{
|
||||||
CBotString mode;
|
CBotString mode;
|
||||||
|
|
||||||
// accepte sans param<61>tre
|
// accepts no parameters
|
||||||
if ( pVar == NULL ) return TRUE;
|
if ( pVar == NULL ) return TRUE;
|
||||||
|
|
||||||
// qui doit <20>tre une cha<68>ne de caract<63>res
|
// must be a character string
|
||||||
if ( pVar->GivType() != CBotTypString ) { Exception = CBotErrBadString; return FALSE; }
|
if ( pVar->GivType() != CBotTypString ) { Exception = CBotErrBadString; return FALSE; }
|
||||||
|
|
||||||
CBotString filename = pVar->GivValString();
|
CBotString filename = pVar->GivValString();
|
||||||
PrepareFilename(filename);
|
PrepareFilename(filename);
|
||||||
|
|
||||||
// il peut y avoir un second param<61>tre
|
// there may be a second parameter
|
||||||
pVar = pVar->GivNext();
|
pVar = pVar->GivNext();
|
||||||
if ( pVar != NULL )
|
if ( pVar != NULL )
|
||||||
{
|
{
|
||||||
// r<EFBFBD>cup<EFBFBD>re le mode
|
// recover mode
|
||||||
mode = pVar->GivValString();
|
mode = pVar->GivValString();
|
||||||
if ( mode != "r" && mode != "w" ) { Exception = CBotErrBadParam; return FALSE; }
|
if ( mode != "r" && mode != "w" ) { Exception = CBotErrBadParam; return FALSE; }
|
||||||
|
|
||||||
// pas de 3e param<61>tre
|
// no third parameter
|
||||||
if ( pVar->GivNext() != NULL ) { Exception = CBotErrOverParam; return FALSE; }
|
if ( pVar->GivNext() != NULL ) { Exception = CBotErrOverParam; return FALSE; }
|
||||||
}
|
}
|
||||||
|
|
||||||
// enregistre le nom du fichier
|
// saves the file name
|
||||||
pVar = pThis->GivItem("filename");
|
pVar = pThis->GivItem("filename");
|
||||||
pVar->SetValString(filename);
|
pVar->SetValString(filename);
|
||||||
|
|
||||||
if ( ! mode.IsEmpty() )
|
if ( ! mode.IsEmpty() )
|
||||||
{
|
{
|
||||||
// ouvre le ficher demand<6E>
|
// opens the requested file
|
||||||
FILE* pFile = fopen( filename, mode );
|
FILE* pFile = fopen( filename, mode );
|
||||||
if ( pFile == NULL ) { Exception = CBotErrFileOpen; return FALSE; }
|
if ( pFile == NULL ) { Exception = CBotErrFileOpen; return FALSE; }
|
||||||
|
|
||||||
m_CompteurFileOpen ++;
|
m_CompteurFileOpen ++;
|
||||||
|
|
||||||
// enregiste le canal du fichier
|
// save the channel file
|
||||||
pVar = pThis->GivItem("handle");
|
pVar = pThis->GivItem("handle");
|
||||||
pVar->SetValInt((long)pFile);
|
pVar->SetValInt((long)pFile);
|
||||||
}
|
}
|
||||||
|
@ -105,38 +105,38 @@ BOOL rfconstruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exceptio
|
||||||
// compilation
|
// compilation
|
||||||
CBotTypResult cfconstruct (CBotVar* pThis, CBotVar* &pVar)
|
CBotTypResult cfconstruct (CBotVar* pThis, CBotVar* &pVar)
|
||||||
{
|
{
|
||||||
// accepte sans param<61>tre
|
// accepts no parameters
|
||||||
if ( pVar == NULL ) return CBotTypResult( 0 );
|
if ( pVar == NULL ) return CBotTypResult( 0 );
|
||||||
|
|
||||||
// qui doit <20>tre une chaine
|
// must be a character string
|
||||||
if ( pVar->GivType() != CBotTypString )
|
if ( pVar->GivType() != CBotTypString )
|
||||||
return CBotTypResult( CBotErrBadString );
|
return CBotTypResult( CBotErrBadString );
|
||||||
|
|
||||||
// il peut y avoir un second param<61>tre
|
// there may be a second parameter
|
||||||
pVar = pVar->GivNext();
|
pVar = pVar->GivNext();
|
||||||
if ( pVar != NULL )
|
if ( pVar != NULL )
|
||||||
{
|
{
|
||||||
// qui doit <20>tre une chaine
|
// which must be a string
|
||||||
if ( pVar->GivType() != CBotTypString )
|
if ( pVar->GivType() != CBotTypString )
|
||||||
return CBotTypResult( CBotErrBadString );
|
return CBotTypResult( CBotErrBadString );
|
||||||
// pas de 3e param<61>tre
|
// no third parameter
|
||||||
if ( pVar->GivNext() != NULL ) return CBotTypResult( CBotErrOverParam );
|
if ( pVar->GivNext() != NULL ) return CBotTypResult( CBotErrOverParam );
|
||||||
}
|
}
|
||||||
|
|
||||||
// le r<>sultat est de type void (constructeur)
|
// the result is void (constructor)
|
||||||
return CBotTypResult( 0 );
|
return CBotTypResult( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// destructeur de la classe
|
// destructor of the class
|
||||||
|
|
||||||
// ex<EFBFBD>cution
|
// execution
|
||||||
BOOL rfdestruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
BOOL rfdestruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||||
{
|
{
|
||||||
// r<EFBFBD>cup<EFBFBD>re l'<27>l<EFBFBD>ment "handle"
|
// retrieve the item "handle"
|
||||||
pVar = pThis->GivItem("handle");
|
pVar = pThis->GivItem("handle");
|
||||||
|
|
||||||
// pas ouvert ? pas de probl<62>me
|
// don't open? no problem :)
|
||||||
if ( pVar->GivInit() != IS_DEF) return TRUE;
|
if ( pVar->GivInit() != IS_DEF) return TRUE;
|
||||||
|
|
||||||
FILE* pFile= (FILE*)pVar->GivValInt();
|
FILE* pFile= (FILE*)pVar->GivValInt();
|
||||||
|
@ -149,52 +149,52 @@ BOOL rfdestruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// m<EFBFBD>thode FILE :: open
|
// process FILE :: open
|
||||||
// re<EFBFBD>ois le mode r/w en param<61>tre
|
// get the r/w mode as a parameter
|
||||||
|
|
||||||
// ex<EFBFBD>cution
|
// execution
|
||||||
BOOL rfopen (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
BOOL rfopen (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||||
{
|
{
|
||||||
// il doit y avoir un param<61>tre
|
// there must be a parameter
|
||||||
if ( pVar == NULL ) { Exception = CBotErrLowParam; return FALSE; }
|
if ( pVar == NULL ) { Exception = CBotErrLowParam; return FALSE; }
|
||||||
|
|
||||||
// qui doit <20>tre une cha<68>ne de caract<63>res
|
// which must be a character string
|
||||||
if ( pVar->GivType() != CBotTypString ) { Exception = CBotErrBadString; return FALSE; }
|
if ( pVar->GivType() != CBotTypString ) { Exception = CBotErrBadString; return FALSE; }
|
||||||
|
|
||||||
// il peut y avoir un second param<61>tre
|
// There may be a second parameter
|
||||||
if ( pVar->GivNext() != NULL )
|
if ( pVar->GivNext() != NULL )
|
||||||
{
|
{
|
||||||
// dans ce cas le premier param<61>tre est le nom du fichier
|
// if the first parameter is the file name
|
||||||
CBotString filename = pVar->GivValString();
|
CBotString filename = pVar->GivValString();
|
||||||
PrepareFilename(filename);
|
PrepareFilename(filename);
|
||||||
|
|
||||||
// enregistre le nom du fichier
|
// saves the file name
|
||||||
CBotVar* pVar2 = pThis->GivItem("filename");
|
CBotVar* pVar2 = pThis->GivItem("filename");
|
||||||
pVar2->SetValString(filename);
|
pVar2->SetValString(filename);
|
||||||
|
|
||||||
// param<EFBFBD>tre suivant est le mode
|
// next parameter is the mode
|
||||||
pVar = pVar -> GivNext();
|
pVar = pVar -> GivNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
CBotString mode = pVar->GivValString();
|
CBotString mode = pVar->GivValString();
|
||||||
if ( mode != "r" && mode != "w" ) { Exception = CBotErrBadParam; return FALSE; }
|
if ( mode != "r" && mode != "w" ) { Exception = CBotErrBadParam; return FALSE; }
|
||||||
|
|
||||||
// pas de 3e param<61>tre
|
// no third parameter
|
||||||
if ( pVar->GivNext() != NULL ) { Exception = CBotErrOverParam; return FALSE; }
|
if ( pVar->GivNext() != NULL ) { Exception = CBotErrOverParam; return FALSE; }
|
||||||
|
|
||||||
// r<EFBFBD>cup<EFBFBD>re l'<27>l<EFBFBD>ment "handle"
|
// retrieve the item "handle"
|
||||||
pVar = pThis->GivItem("handle");
|
pVar = pThis->GivItem("handle");
|
||||||
|
|
||||||
// qui doit pas <20>tre initialis<69>
|
// which must not be initialized
|
||||||
if ( pVar->GivInit() == IS_DEF) { Exception = CBotErrFileOpen; return FALSE; }
|
if ( pVar->GivInit() == IS_DEF) { Exception = CBotErrFileOpen; return FALSE; }
|
||||||
|
|
||||||
// reprend le nom du fichier
|
// file contains the name
|
||||||
pVar = pThis->GivItem("filename");
|
pVar = pThis->GivItem("filename");
|
||||||
CBotString filename = pVar->GivValString();
|
CBotString filename = pVar->GivValString();
|
||||||
|
|
||||||
PrepareFilename(filename); // si le nom a <20>t<EFBFBD> attribu<62> par h.filename = "...";
|
PrepareFilename(filename); // if the name was h.filename attribute = "...";
|
||||||
|
|
||||||
// ouvre le ficher demand<6E>
|
// opens the requested file
|
||||||
FILE* pFile = fopen( filename, mode );
|
FILE* pFile = fopen( filename, mode );
|
||||||
if ( pFile == NULL )
|
if ( pFile == NULL )
|
||||||
{
|
{
|
||||||
|
@ -204,7 +204,7 @@ BOOL rfopen (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||||
|
|
||||||
m_CompteurFileOpen ++;
|
m_CompteurFileOpen ++;
|
||||||
|
|
||||||
// enregiste le canal du fichier
|
// Registered the channel file
|
||||||
pVar = pThis->GivItem("handle");
|
pVar = pThis->GivItem("handle");
|
||||||
pVar->SetValInt((long)pFile);
|
pVar->SetValInt((long)pFile);
|
||||||
|
|
||||||
|
@ -215,39 +215,39 @@ BOOL rfopen (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||||
// compilation
|
// compilation
|
||||||
CBotTypResult cfopen (CBotVar* pThis, CBotVar* &pVar)
|
CBotTypResult cfopen (CBotVar* pThis, CBotVar* &pVar)
|
||||||
{
|
{
|
||||||
// il doit y avoir un param<61>tre
|
// there must be a parameter
|
||||||
if ( pVar == NULL ) return CBotTypResult( CBotErrLowParam );
|
if ( pVar == NULL ) return CBotTypResult( CBotErrLowParam );
|
||||||
|
|
||||||
// qui doit <20>tre une chaine
|
// which must be a string
|
||||||
if ( pVar->GivType() != CBotTypString )
|
if ( pVar->GivType() != CBotTypString )
|
||||||
return CBotTypResult( CBotErrBadString );
|
return CBotTypResult( CBotErrBadString );
|
||||||
|
|
||||||
// il peut y avoir un second param<61>tre
|
// there may be a second parameter
|
||||||
pVar = pVar->GivNext();
|
pVar = pVar->GivNext();
|
||||||
if ( pVar != NULL )
|
if ( pVar != NULL )
|
||||||
{
|
{
|
||||||
// qui doit <20>tre une chaine
|
// which must be a string
|
||||||
if ( pVar->GivType() != CBotTypString )
|
if ( pVar->GivType() != CBotTypString )
|
||||||
return CBotTypResult( CBotErrBadString );
|
return CBotTypResult( CBotErrBadString );
|
||||||
|
|
||||||
// pas de 3e param<61>tre
|
// no third parameter
|
||||||
if ( pVar->GivNext() != NULL ) return CBotTypResult( CBotErrOverParam );
|
if ( pVar->GivNext() != NULL ) return CBotTypResult( CBotErrOverParam );
|
||||||
}
|
}
|
||||||
|
|
||||||
// le r<>sultat est de type bool
|
// the result is bool
|
||||||
return CBotTypResult(CBotTypBoolean);
|
return CBotTypResult(CBotTypBoolean);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// m<EFBFBD>thode FILE :: close
|
// process FILE :: close
|
||||||
|
|
||||||
// ex<EFBFBD>cution
|
// execeution
|
||||||
BOOL rfclose (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
BOOL rfclose (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||||
{
|
{
|
||||||
// il ne doit pas y avoir de param<61>tre
|
// it shouldn't be any parameters
|
||||||
if ( pVar != NULL ) return CBotErrOverParam;
|
if ( pVar != NULL ) return CBotErrOverParam;
|
||||||
|
|
||||||
// r<EFBFBD>cup<EFBFBD>re l'<27>l<EFBFBD>ment "handle"
|
// retrieve the item "handle"
|
||||||
pVar = pThis->GivItem("handle");
|
pVar = pThis->GivItem("handle");
|
||||||
|
|
||||||
if ( pVar->GivInit() != IS_DEF) { Exception = CBotErrNotOpen; return FALSE; }
|
if ( pVar->GivInit() != IS_DEF) { Exception = CBotErrNotOpen; return FALSE; }
|
||||||
|
@ -264,27 +264,27 @@ BOOL rfclose (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||||
// compilation
|
// compilation
|
||||||
CBotTypResult cfclose (CBotVar* pThis, CBotVar* &pVar)
|
CBotTypResult cfclose (CBotVar* pThis, CBotVar* &pVar)
|
||||||
{
|
{
|
||||||
// il ne doit pas y avoir de param<61>tre
|
// it shouldn't be any parameters
|
||||||
if ( pVar != NULL ) return CBotTypResult( CBotErrOverParam );
|
if ( pVar != NULL ) return CBotTypResult( CBotErrOverParam );
|
||||||
|
|
||||||
// la fonction retourne un r<>sultat "void"
|
// function returns a result "void"
|
||||||
return CBotTypResult( 0 );
|
return CBotTypResult( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
// m<EFBFBD>thode FILE :: writeln
|
// process FILE :: writeln
|
||||||
|
|
||||||
// ex<EFBFBD>cution
|
// execution
|
||||||
BOOL rfwrite (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
BOOL rfwrite (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||||
{
|
{
|
||||||
// il doit y avoir un param<61>tre
|
// there must be a parameter
|
||||||
if ( pVar == NULL ) { Exception = CBotErrLowParam; return FALSE; }
|
if ( pVar == NULL ) { Exception = CBotErrLowParam; return FALSE; }
|
||||||
|
|
||||||
// qui doit <20>tre une cha<68>ne de caract<63>res
|
// which must be a character string
|
||||||
if ( pVar->GivType() != CBotTypString ) { Exception = CBotErrBadString; return FALSE; }
|
if ( pVar->GivType() != CBotTypString ) { Exception = CBotErrBadString; return FALSE; }
|
||||||
|
|
||||||
CBotString param = pVar->GivValString();
|
CBotString param = pVar->GivValString();
|
||||||
|
|
||||||
// r<EFBFBD>cup<EFBFBD>re l'<27>l<EFBFBD>ment "handle"
|
// retrieve the item "handle"
|
||||||
pVar = pThis->GivItem("handle");
|
pVar = pThis->GivItem("handle");
|
||||||
|
|
||||||
if ( pVar->GivInit() != IS_DEF) { Exception = CBotErrNotOpen; return FALSE; }
|
if ( pVar->GivInit() != IS_DEF) { Exception = CBotErrNotOpen; return FALSE; }
|
||||||
|
@ -293,7 +293,7 @@ BOOL rfwrite (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||||
|
|
||||||
int res = fputs(param+"\n", pFile);
|
int res = fputs(param+"\n", pFile);
|
||||||
|
|
||||||
// en cas d'erreur g<>n<EFBFBD>re une exception
|
// if an error occurs generate an exception
|
||||||
if ( res < 0 ) { Exception = CBotErrWrite; return FALSE; }
|
if ( res < 0 ) { Exception = CBotErrWrite; return FALSE; }
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -302,28 +302,28 @@ BOOL rfwrite (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||||
// compilation
|
// compilation
|
||||||
CBotTypResult cfwrite (CBotVar* pThis, CBotVar* &pVar)
|
CBotTypResult cfwrite (CBotVar* pThis, CBotVar* &pVar)
|
||||||
{
|
{
|
||||||
// il doit y avoir un param<61>tre
|
// there must be a parameter
|
||||||
if ( pVar == NULL ) return CBotTypResult( CBotErrLowParam );
|
if ( pVar == NULL ) return CBotTypResult( CBotErrLowParam );
|
||||||
|
|
||||||
// qui doit <20>tre une cha<68>ne de caract<63>res
|
// which must be a character string
|
||||||
if ( pVar->GivType() != CBotTypString ) return CBotTypResult( CBotErrBadString );
|
if ( pVar->GivType() != CBotTypString ) return CBotTypResult( CBotErrBadString );
|
||||||
|
|
||||||
// pas d'autre param<61>tre
|
// no other parameter
|
||||||
if ( pVar->GivNext() != NULL ) return CBotTypResult( CBotErrOverParam );
|
if ( pVar->GivNext() != NULL ) return CBotTypResult( CBotErrOverParam );
|
||||||
|
|
||||||
// la fonction retourne un r<>sultat void
|
// the function returns a void result
|
||||||
return CBotTypResult( 0 );
|
return CBotTypResult( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
// m<EFBFBD>thode FILE :: readln
|
// process FILE :: readln
|
||||||
|
|
||||||
// ex<EFBFBD>cution
|
// execution
|
||||||
BOOL rfread (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
BOOL rfread (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||||
{
|
{
|
||||||
// il ne doit pas y avoir de param<61>tre
|
// it shouldn't be any parameters
|
||||||
if ( pVar != NULL ) { Exception = CBotErrOverParam; return FALSE; }
|
if ( pVar != NULL ) { Exception = CBotErrOverParam; return FALSE; }
|
||||||
|
|
||||||
// r<EFBFBD>cup<EFBFBD>re l'<27>l<EFBFBD>ment "handle"
|
// retrieve the item "handle"
|
||||||
pVar = pThis->GivItem("handle");
|
pVar = pThis->GivItem("handle");
|
||||||
|
|
||||||
if ( pVar->GivInit() != IS_DEF) { Exception = CBotErrNotOpen; return FALSE; }
|
if ( pVar->GivInit() != IS_DEF) { Exception = CBotErrNotOpen; return FALSE; }
|
||||||
|
@ -338,7 +338,7 @@ BOOL rfread (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||||
|
|
||||||
for ( i = 0 ; i < 2000 ; i++ ) if (chaine[i] == '\n') chaine[i] = 0;
|
for ( i = 0 ; i < 2000 ; i++ ) if (chaine[i] == '\n') chaine[i] = 0;
|
||||||
|
|
||||||
// en cas d'erreur g<>n<EFBFBD>re une exception
|
// if an error occurs generate an exception
|
||||||
if ( ferror(pFile) ) { Exception = CBotErrRead; return FALSE; }
|
if ( ferror(pFile) ) { Exception = CBotErrRead; return FALSE; }
|
||||||
|
|
||||||
pResult->SetValString( chaine );
|
pResult->SetValString( chaine );
|
||||||
|
@ -349,22 +349,22 @@ BOOL rfread (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||||
// compilation
|
// compilation
|
||||||
CBotTypResult cfread (CBotVar* pThis, CBotVar* &pVar)
|
CBotTypResult cfread (CBotVar* pThis, CBotVar* &pVar)
|
||||||
{
|
{
|
||||||
// il ne doit pas y avoir de param<61>tre
|
// it should not be any parameter
|
||||||
if ( pVar != NULL ) return CBotTypResult( CBotErrOverParam );
|
if ( pVar != NULL ) return CBotTypResult( CBotErrOverParam );
|
||||||
|
|
||||||
// la fonction retourne un r<>sultat "string"
|
// function returns a result "string"
|
||||||
return CBotTypResult( CBotTypString );
|
return CBotTypResult( CBotTypString );
|
||||||
}
|
}
|
||||||
// m<EFBFBD>thode FILE :: readln
|
// process FILE :: readln
|
||||||
|
|
||||||
|
|
||||||
// ex<EFBFBD>cution
|
// execution
|
||||||
BOOL rfeof (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
BOOL rfeof (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||||
{
|
{
|
||||||
// il ne doit pas y avoir de param<61>tre
|
// it should not be any parameter
|
||||||
if ( pVar != NULL ) { Exception = CBotErrOverParam; return FALSE; }
|
if ( pVar != NULL ) { Exception = CBotErrOverParam; return FALSE; }
|
||||||
|
|
||||||
// r<EFBFBD>cup<EFBFBD>re l'<27>l<EFBFBD>ment "handle"
|
// retrieve the item "handle"
|
||||||
pVar = pThis->GivItem("handle");
|
pVar = pThis->GivItem("handle");
|
||||||
|
|
||||||
if ( pVar->GivInit() != IS_DEF) { Exception = CBotErrNotOpen; return FALSE; }
|
if ( pVar->GivInit() != IS_DEF) { Exception = CBotErrNotOpen; return FALSE; }
|
||||||
|
@ -379,10 +379,10 @@ BOOL rfeof (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||||
// compilation
|
// compilation
|
||||||
CBotTypResult cfeof (CBotVar* pThis, CBotVar* &pVar)
|
CBotTypResult cfeof (CBotVar* pThis, CBotVar* &pVar)
|
||||||
{
|
{
|
||||||
// il ne doit pas y avoir de param<61>tre
|
// it shouldn't be any parameter
|
||||||
if ( pVar != NULL ) return CBotTypResult( CBotErrOverParam );
|
if ( pVar != NULL ) return CBotTypResult( CBotErrOverParam );
|
||||||
|
|
||||||
// la fonction retourne un r<>sultat booleen
|
// the function returns a boolean result
|
||||||
return CBotTypResult( CBotTypBoolean );
|
return CBotTypResult( CBotTypBoolean );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -392,25 +392,25 @@ CBotTypResult cfeof (CBotVar* pThis, CBotVar* &pVar)
|
||||||
|
|
||||||
void InitClassFILE()
|
void InitClassFILE()
|
||||||
{
|
{
|
||||||
// cr<EFBFBD>e une classe pour la gestion des fichiers
|
// create a class for file management
|
||||||
// l'utilisation en est la suivante:
|
// the use is as follows:
|
||||||
// file canal( "NomFichier.txt" )
|
// file canal( "NomFichier.txt" )
|
||||||
// canal.open( "r" ); // ouvre en lecture
|
// canal.open( "r" ); // open for read
|
||||||
// s = canal.readln( ); // lit une ligne
|
// s = canal.readln( ); // reads a line
|
||||||
// canal.close(); // referme le fichier
|
// canal.close(); // close the file
|
||||||
|
|
||||||
// cr<EFBFBD>e la classe FILE
|
// create the class FILE
|
||||||
m_pClassFILE = new CBotClass("file", NULL);
|
m_pClassFILE = new CBotClass("file", NULL);
|
||||||
// ajoute le composant ".filename"
|
// adds the component ".filename"
|
||||||
m_pClassFILE->AddItem("filename", CBotTypString);
|
m_pClassFILE->AddItem("filename", CBotTypString);
|
||||||
// ajoute le composant ".handle"
|
// adds the component ".handle"
|
||||||
m_pClassFILE->AddItem("handle", CBotTypInt, PR_PRIVATE);
|
m_pClassFILE->AddItem("handle", CBotTypInt, PR_PRIVATE);
|
||||||
|
|
||||||
// d<EFBFBD>fini un constructeur et un destructeur
|
// define a constructor and a destructor
|
||||||
m_pClassFILE->AddFunction("file", rfconstruct, cfconstruct );
|
m_pClassFILE->AddFunction("file", rfconstruct, cfconstruct );
|
||||||
m_pClassFILE->AddFunction("~file", rfdestruct, NULL );
|
m_pClassFILE->AddFunction("~file", rfdestruct, NULL );
|
||||||
|
|
||||||
// d<EFBFBD>fini les m<>thodes associ<63>es
|
// end of the methods associated
|
||||||
m_pClassFILE->AddFunction("open", rfopen, cfopen );
|
m_pClassFILE->AddFunction("open", rfopen, cfopen );
|
||||||
m_pClassFILE->AddFunction("close", rfclose, cfclose );
|
m_pClassFILE->AddFunction("close", rfclose, cfclose );
|
||||||
m_pClassFILE->AddFunction("writeln", rfwrite, cfwrite );
|
m_pClassFILE->AddFunction("writeln", rfwrite, cfwrite );
|
||||||
|
@ -420,6 +420,6 @@ void InitClassFILE()
|
||||||
m_pFuncFile = new CBotProgram( );
|
m_pFuncFile = new CBotProgram( );
|
||||||
CBotStringArray ListFonctions;
|
CBotStringArray ListFonctions;
|
||||||
m_pFuncFile->Compile( "public file openfile(string name, string mode) {return new file(name, mode);}", ListFonctions);
|
m_pFuncFile->Compile( "public file openfile(string name, string mode) {return new file(name, mode);}", ListFonctions);
|
||||||
m_pFuncFile->SetIdent(-2); // identificateur sp<73>cial pour RestoreState dans cette fonction
|
m_pFuncFile->SetIdent(-2); // restoreState in special identifier for this function
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue