CBot console interpreter

Based on program found in sources
dev-ui
Michał Konopacki 2012-08-09 22:13:10 +02:00
parent ef7e297efe
commit 7b03a6a2ac
89 changed files with 732 additions and 2958 deletions

View File

@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 2.8)
project(CBot_console C CXX)
# Build with debugging symbols
set(CMAKE_BUILD_TYPE debug)
# Global compile flags
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -Wall -Wold-style-cast -std=gnu++0x")
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall -Wold-style-cast -std=gnu++0x")
# Include cmake directory
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${colobot_SOURCE_DIR}/cmake")
add_subdirectory(src bin)

View File

@ -0,0 +1 @@
../../../../CBot/

View File

@ -0,0 +1,32 @@
# CBot shared library is built separately
add_subdirectory(CBot)
# Configure options
option(DEBUG "Enable debug output" ON)
set(PLATFORM_LIBS "")
# Source files
# Commented out files are still dependent on DirectX or WinAPI
set(SOURCES
app/CClass.cpp
app/main.cpp
#app/routines.cpp
app/CBotDoc.cpp
app/CBotConsole.cpp
)
set(LIBS
CBot
)
include_directories(. ${CMAKE_CURRENT_BINARY_DIR}
)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/CBot)
add_executable(CBot_console ${SOURCES})
target_link_libraries(CBot_console ${LIBS})

View File

@ -0,0 +1,175 @@
/*
* CBotConsole.cpp
*
* Created on: 08-08-2012
* Author: michal
*/
#include "CBotConsole.h"
#include "CClass.h"
#include <ctime>
#include <iostream>
CBotConsole::CBotConsole() {
// TODO Auto-generated constructor stub
m_pProg = NULL;
m_threadinfo.m_bRun = false;
m_code = 0;
}
CBotConsole::~CBotConsole() {
// TODO Auto-generated destructor stub
}
uint ThreadProc(ThreadInfo *info)
{
time_t t0,t1;
time(&t0);
int Cpt = 0;
info->m_pProg->Start("LaCommande");
while ( !info->m_bStop && !info->m_pProg->Run() )
{
#if 0
const char* FunctionName;
const char* FN;
int start, end;
info->m_pProg->GetRunPos(FunctionName, start, end);
if ( FunctionName != NULL )
{
info->m_pEditx->SetSel(start, end);
char buffer[200];
sprintf( buffer, "step %s, %d, %d",FunctionName, start, end);
AfxMessageBox( buffer );
int level = 0;
do
{
CBotVar* t = info->m_pProg->GivStackVars(FN, level--);
if ( FN != FunctionName ) break;
if ( t != NULL )
{
CString s ;
while ( t != NULL )
{
if (s.IsEmpty()) s+= "Stack -> ";
else s+= " , ";
s += t->GivValString();
t = t->GivNext();
}
AfxMessageBox(s);
}
} while (TRUE);
}
#endif
Cpt++;
if ( Cpt%50 == 0 ) std::cout << ".";
}
if ( info->m_bStop )
{
std::cout << "\nInterrupt\n";
}
else if (info->m_pProg->GivError() == 0)
{
time(&t1);
double prog_time = difftime(t0,t1);
char buffer[200];
sprintf( buffer, "\nExecution terminated in %f seconds.\nInterrupted %d time(s).\n",
prog_time, Cpt);
std::cout << buffer;
}
// info->m_pWndMessage->SendMessage(WM_ENDPROG, 0, 0) ;
return 0 ;
}
long CBotConsole::EndProg()
{
m_threadinfo.m_bRun = false;
if (m_pProg->GetError(m_code, m_start, m_end))
{
CBotString TextError;
TextError = CBotProgram::GivErrorText(m_code);
std::cout << TextError;
return 1;
}
delete m_pProg;
m_pProg = NULL;
return 0 ;
}
void CBotConsole::OnOK()
{
m_code = 0;
std::string Commande;
std::cin >> Commande;
std::string s = "void LaCommande() { " + Commande + " ;}";
m_pProg = new CBotProgram();
CBotStringArray liste;
m_pProg->Compile(s.c_str(), liste);
int err, start, end;
if ( m_pProg->GetError(err, start, end) )
{
CBotString TextError;
TextError = CBotProgram::GivErrorText(err);
std::cout << TextError;
return;
}
std::cout << "\n" + Commande + " ->\n";
// m_Edit2.SetWindowText("");
// m_Edit1.SetFocus();
// m_Edit2.EnableWindow(FALSE);
// m_cOK.EnableWindow(FALSE);
// lance un processus paralèle pour l'exécution
// m_threadinfo.m_pWndMessage = this ;
// m_threadinfo.m_pEdit1 = &m_Edit1;
// m_threadinfo.m_pEditx = m_pEditx;
m_threadinfo.m_pProg = m_pProg;
m_threadinfo.m_bStop = false;
m_threadinfo.m_bRun = true;
ThreadProc(&m_threadinfo);
// here program starts
// AfxBeginThread((AFX_THREADPROC)ThreadProc, &m_threadinfo) ;
}
void CBotConsole::OnCancel()
{
m_threadinfo.m_bStop = true ;
}
bool CBotConsole::OnInitDialog()
{
// CDialog::OnInitDialog();
std::cout << "Following functions are availible:\n";
for ( int i = 0; i < m_pListe->GivSize(); i++ )
{
CBotString x = (*m_pListe)[i] + CBotString("\n");
std::cout << x;
}
std::cout << "Enter a command:\n";
return true; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}

View File

@ -0,0 +1,44 @@
/*
* CBotConsole.h
*
* Created on: 08-08-2012
* Author: michal
*/
#ifndef CBOTCONSOLE_H_
#define CBOTCONSOLE_H_
#include "CClass.h"
struct ThreadInfo
{
// CEdit* m_pEdit1 ;
// CEdit* m_pEditx ;
CBotProgram* m_pProg;
// CWnd* m_pWndMessage;
bool m_bStop;
bool m_bRun;
};
class CBotConsole {
public:
CBotConsole();
virtual ~CBotConsole();
// CEdit m_Edit1;
CBotProgram* m_pProg;
ThreadInfo m_threadinfo;
CBotStringArray* m_pListe;
int m_code, m_start, m_end;
// CEdit* m_pEditx;
// Implementation
void OnOK();
void OnCancel();
bool OnInitDialog();
long EndProg() ;
};
#endif /* CBOTCONSOLE_H_ */

View File

@ -0,0 +1,122 @@
/*
* CBotDoc.cpp
*
* Created on: 08-08-2012
* Author: michal
*/
#include "CBotDoc.h"
#include "CBotConsole.h"
#include <iostream>
CBotDoc::CBotDoc(std::string s) {
// TODO Auto-generated constructor stub
// TODO set m_DocText
// m_pEdit = NULL;
m_pProg = NULL;
// m_bModified = FALSE;
m_DocText = s;
std::cout << s << std::endl;
// std::cout << "Enter to continue..." << std::endl;
// getchar();
}
CBotDoc::~CBotDoc() {
// delete m_pEdit;
delete m_pProg;
}
//static bool test = false;
void CBotDoc::OnRun()
{
// m_pEdit->GetWindowText(m_DocText);
CBotString s;
std::string TextError;
int code, start, end;
if ( m_pProg == NULL ) m_pProg = new CBotProgram();
if (!m_pProg->Compile(m_DocText.c_str(), m_Liste, NULL))
{
m_pProg->GetError(code, start, end);
delete m_pProg;
m_pProg = NULL;
TextError = CBotProgram::GivErrorText( code );
std::cout << TextError << std::endl;
return;
}
if( m_Liste.GivSize() == 0 )
{
std::cout << "No function marked \"extern\" !\n";
return;
}
for ( int i = 0; i < m_Liste.GivSize(); i++ )
{
int start, stop;
m_pProg->GetPosition(m_Liste[i], start, stop, GetPosNom, GetPosParam);
CBotString s(m_DocText.substr( start, stop-start ).c_str());
m_Liste[i] = s;
}
// TODO
CBotConsole dlg;
dlg.m_pListe = &m_Liste;
// dlg.m_pEditx = m_pEdit;
dlg.OnInitDialog();
dlg.OnOK();
dlg.EndProg();
// if ( dlg.m_code>0 )
// {
// std::string TextError;
//
// TextError = m_pProg->GivErrorText( dlg.m_code );
//
// std::cout <<TextError;
// }
return;
}
bool CBotDoc::Compile()
{
// m_pEdit->GetWindowText(m_DocText);
std::string TextError;
int code, start, end;
if ( m_pProg == NULL ) m_pProg = new CBotProgram();
char buffer[100];
strcpy(buffer, "a pointer move to see");
if (!m_pProg->Compile(m_DocText.c_str(), m_Liste, static_cast<void*>(buffer)))
{
m_pProg->GetError(code, start, end);
delete m_pProg;
m_pProg = NULL;
// m_pEdit->SetSel( start, end );
// m_pEdit->SetFocus(); // higlights part of problem
TextError = CBotProgram::GivErrorText( code );
std::cout << TextError ;
return false;
}
// if ( m_pProg->GetPosition( "TheTest", start, end) )
// {
// m_pEdit->SetSel( start, end );
// m_pEdit->SetFocus(); // higlights part of problem
// }
// m_bModified = FALSE;
return true;
}

View File

@ -0,0 +1,39 @@
/*
* CBotDoc.h
*
* Created on: 08-08-2012
* Author: michal
*/
#pragma once
#ifndef CBOTDOC_H_
#define CBOTDOC_H_
#include "CClass.h"
#include <string>
class CBotDoc {
public:
CBotDoc(std::string);
virtual ~CBotDoc();
// CEdit* m_pEdit; // to memorize the text, and display
CBotProgram* m_pProg; // the compiled program
std::string m_DocText;
CBotStringArray m_Liste;
// Operations
bool Compile();
// virtual bool OnNewDocument();
void OnRun();
void OnChangeEdit1();
void OnTest();
};
#endif /* CBOTDOC_H_ */

View File

@ -0,0 +1,97 @@
#include "CClass.h"
#include "routines.cpp"
void rMajObject( CBotVar* pThis, void* pUser )
{
if (!pThis->IsElemOfClass("object"))
return ;
CBotVar* pPos = pThis->GivItem("position");
CBotVar* pX = pPos->GivItem("x");
CBotVar* pY = pPos->GivItem("y");
CBotVar* pZ = pPos->GivItem("z");
// CBotVar* pPt = pThis->GivItem("transport");
CBotString p = pX->GivValString();
// pX->SetValFloat( pUser == (void*)1 ? (float)12.5 : (float)44.4 );
pZ->SetValFloat( (float)0 );
pY->SetValFloat( (float)-3.33 );
pX->SetValFloat( pX->GivValFloat() + 10 ) ;
// pX = pThis->GivItem( "xx" );
// pX->SetValFloat( (float)22 );
// crée une instance sur une classe object
// CBotVar* pAutre = CBotVar::Create("autre", CBotTypClass, "object");
// pAutre->SetUserPtr( (void*)3 );
// pPt->SetPointer( pAutre );
// pPt->SetPointer( NULL );
// delete pAutre;
};
CClass::CClass()
{
m_pClassPoint= NULL;
}
bool CClass::InitInstance()
{
//////////////////////////////////////////////
// défini les mots clefs supplémentaires
// -------------------------------------------
CBotProgram::Init();
//////////////////////////////////////////////
// défini les fonctions "show()" et "print()"
// -------------------------------------------
//CBotProgram::AddFunction("show", rShow, cShow);
CBotProgram::AddFunction("print", rPrint, cPrint);
CBotProgram::AddFunction("println", rPrintLn, cPrint);
///////////////////////////////////
// définie la classe globale CPoint
// --------------------------------
m_pClassPoint = new CBotClass("CPoint", NULL);
// ajoute le composant ".x"
m_pClassPoint->AddItem("x", CBotTypFloat);
// ajoute le composant ".y"
m_pClassPoint->AddItem("y", CBotTypFloat);
// ajoute le constructeur pour cette classe
m_pClassPoint->AddFunction("CPoint", rCPoint, cCPoint);
m_pClassPointIntr = new CBotClass("point", NULL, true);
// ajoute le composant ".x"
m_pClassPointIntr->AddItem("x", CBotTypFloat);
// ajoute le composant ".y"
m_pClassPointIntr->AddItem("y", CBotTypFloat);
// ajoute le composant ".z"
m_pClassPointIntr->AddItem("z", CBotTypFloat);
// ajoute le constructeur pour cette classe
m_pClassPointIntr->AddFunction("point", rCPoint, cCPoint);
// défini la classe "object"
CBotClass* pClassObject = new CBotClass( "object", NULL ) ;
pClassObject->AddItem( "xx", CBotTypFloat );
pClassObject->AddItem( "position", CBotTypResult( CBotTypIntrinsic, "point" ) );
pClassObject->AddItem( "transport", CBotTypResult( CBotTypPointer, "object" ) );
pClassObject->AddUpdateFunc( rMajObject );
InitClassFILE();
return true;
}
void CClass::ExitInstance()
{
delete m_pFuncFile;
CBotProgram::Free();
}

View File

@ -0,0 +1,18 @@
#pragma once
#include <CBot/CBot.h>
#include <string>
extern std::string s;
class CClass
{
public:
CClass();
CBotClass* m_pClassPoint;
CBotClass* m_pClassPointIntr;
bool InitInstance();
void ExitInstance();
};

View File

@ -0,0 +1,45 @@
#include "CClass.h"
#include "CBotDoc.h"
#include <iostream>
#include <fstream>
std::string str;
// routine to update the instance of the class Bot common
int main(int argc, char* argv[])
{
CClass newclass;
CBotDoc *botdoc;
if (argc != 2)
{
std::cout << "Usage: "<<argv[0] << " <filename>" << std::endl;
return 0;
}
std::ifstream in(argv[1]);
std::cout << argv[1] << std::endl;
if (!in.good())
{
std::cout << "Oh no, error!" << std::endl;
return 1;
}
std::string contents((std::istreambuf_iterator<char>(in)),
std::istreambuf_iterator<char>());
str = contents;
if(!newclass.InitInstance())
{
std::cerr << "Initialization not complete!" << std::endl;
return 1;
}
botdoc = new CBotDoc(str);
// std::cout << "Hello CBot!" << std::endl << s;
botdoc->OnRun();
delete botdoc;
newclass.ExitInstance();
}

View File

@ -0,0 +1,141 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
////////////////////////////////////////////////////////////////////
// routine show()
// utilisable depuis le programme écrit en CBot
#include <iostream>
#include <string>
#include "CBot/ClassFILE.cpp"
//std::string s;
/*
// execution
bool rShow( CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser )
{
string::string s;
while ( pVar != NULL )
{
string::string ss;
ss.LoadString( TX_TYPENAMES + pVar->GivType() );
s += ss + " ";
ss = pVar->GivName();
if (ss.IsEmpty()) ss = "<sans nom>";
s += ss + " = ";
s += pVar->GivValString();
s += "\n";
pVar = pVar->GivNext();
}
AfxMessageBox(s, MB_OK|MB_ICONINFORMATION);
return TRUE; // pas d'interruption
}
CBotTypResult cShow( CBotVar* &pVar, void* pUser)
{
if ( pVar == NULL ) return CBotTypResult(5028);
return CBotTypResult(0); // tous paramètres acceptés, void en retour
}
*/
////////////////////////////////////////////////////////////////////
// routine print()
// utilisable depuis le programme écrit en CBot
// exécution
bool rPrintLn( CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser )
{
std::string s;
while ( pVar != NULL )
{
if ( !s.empty() ) s += " ";
s += pVar->GivValString();
pVar = pVar->GivNext();
}
s += "\n";
std::cout << s;
return true; // pas d'interruption
}
bool rPrint( CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser )
{
std::string s;
while ( pVar != NULL )
{
if ( !s.empty() ) s += " ";
s += pVar->GivValString();
pVar = pVar->GivNext();
}
s += " ";
std::cout << s;
return true; // pas d'interruption
}
CBotTypResult cPrint( CBotVar* &pVar, void* pUser)
{
return CBotTypResult(0); // tous paramètres acceptés, un entier en retour
}
//////////////////////////////////////////////////////////////////
// class CPoint pour essayer
// exécution
bool rCPoint( CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception )
{
if ( pVar == NULL )return true; // constructor with no parameters is ok
CBotVar* pX = pThis->GivItem("x");
pX->SetValFloat( pVar->GivValFloat() );
pVar = pVar->GivNext();
CBotVar* pY = pThis->GivItem("y");
pY->SetValFloat( pVar->GivValFloat() );
pVar = pVar->GivNext();
return true; // pas d'interruption
}
CBotTypResult cCPoint( CBotVar* pThis, CBotVar* &pVar)
{
// ok if no parameters!
if ( pVar == NULL ) return CBotTypResult(0);
// numeric type of parameter please
if ( pVar->GivType() > CBotTypDouble ) return CBotTypResult(5011);
pVar = pVar->GivNext();
// there must be a second parameter
if ( pVar == NULL ) return 5028;
// also numeric
if ( pVar->GivType() > CBotTypDouble )return CBotTypResult(5011);
pVar = pVar->GivNext();
// and not more than 2 parameters please
if ( pVar != NULL ) return CBotTypResult(5026);
return CBotTypResult(0); // This function returns void
}

View File

@ -1,164 +0,0 @@
// BotConsoleDlg.cpp : implementation file
//
#include "stdafx.h"
#include "TstCBot.h"
#include "BotConsoleDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CBotConsoleDlg dialog
CBotConsoleDlg::CBotConsoleDlg(CWnd* pParent /*=NULL*/)
: CDialog(CBotConsoleDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CBotConsoleDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_pProg = NULL;
m_threadinfo.m_bRun = FALSE;
}
void CBotConsoleDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CBotConsoleDlg)
DDX_Control(pDX, IDOK, m_cOK);
DDX_Control(pDX, IDC_EDIT2, m_Edit2);
DDX_Control(pDX, IDC_EDIT1, m_Edit1);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CBotConsoleDlg, CDialog)
//{{AFX_MSG_MAP(CBotConsoleDlg)
ON_MESSAGE(WM_ENDPROG, EndProg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBotConsoleDlg message handlers
UINT ThreadProc(ThreadInfo *info)
{
CTime t0 = CTime::GetCurrentTime();
int Cpt = 0;
info->m_pProg->Start("LaCommande");
while ( !info->m_bStop && !info->m_pProg->Run() )
{
Cpt++;
if ( Cpt%20 == 0 ) info->m_pEdit1->ReplaceSel(".");
}
if ( info->m_bStop )
{
info->m_pEdit1->ReplaceSel("\r\nInterrompu\r\n");
}
else if (info->m_pProg->GivError() == 0)
{
CTime t = CTime::GetCurrentTime();
CTimeSpan ts = t - t0;
char buffer[200];
sprintf( buffer, "\r\nExécution terminée en %d secondes.\r\nInterrompue %d fois.\r\n",
ts.GetTotalSeconds(), Cpt);
info->m_pEdit1->ReplaceSel(buffer);
}
info->m_pWndMessage->SendMessage(WM_ENDPROG, 0, 0) ;
return 0 ;
}
LONG CBotConsoleDlg::EndProg(UINT wparam, LONG lparam)
{
m_threadinfo.m_bRun = FALSE;
if (m_pProg->GetError(m_code, m_start, m_end))
{
AfxMessageBox(m_code);
CDialog::OnCancel();
return 1;
}
delete m_pProg;
m_pProg = NULL;
m_Edit2.EnableWindow(TRUE);
m_cOK.EnableWindow(TRUE);
m_Edit2.SetWindowText("");
m_Edit2.SetFocus();
return 0 ;
}
void CBotConsoleDlg::OnOK()
{
CTstCBotApp* pApp = (CTstCBotApp*)AfxGetApp();
pApp->m_pConsole = &m_Edit1;
CString Commande;
m_Edit2.GetWindowText(Commande);
CString s = "void LaCommande() { " + Commande + " ;}";
m_pProg = new CBotProgram();
CBotStringArray liste;
m_pProg->Compile(s, liste);
int err, start, end;
if ( m_pProg->GetError(err, start, end) )
{
AfxMessageBox(err);
m_Edit2.SetSel(start-20, end-20);
return;
}
m_Edit1.ReplaceSel(Commande + " ->\r\n");
m_Edit2.SetWindowText("");
m_Edit1.SetFocus();
m_Edit2.EnableWindow(FALSE);
m_cOK.EnableWindow(FALSE);
// lance un processus paralèle pour l'exécution
m_threadinfo.m_pWndMessage = this ;
m_threadinfo.m_pEdit1 = &m_Edit1;
m_threadinfo.m_pProg = m_pProg;
m_threadinfo.m_bStop = FALSE;
m_threadinfo.m_bRun = TRUE;
AfxBeginThread((AFX_THREADPROC)ThreadProc, &m_threadinfo) ;
}
void CBotConsoleDlg::OnCancel()
{
if (!m_threadinfo.m_bRun) CDialog::OnCancel();
m_threadinfo.m_bStop = TRUE ;
}
BOOL CBotConsoleDlg::OnInitDialog()
{
CTstCBotApp* pApp = (CTstCBotApp*)AfxGetApp();
CDialog::OnInitDialog();
m_Edit1.ReplaceSel("Les fonctions suivantes sont disponibles:\r\n");
for ( int i = 0; i < pApp->m_Liste.RetSize(); i++ )
{
CBotString x = CString(pApp->m_Liste[i]) + "\r\n";
m_Edit1.ReplaceSel(x);
}
m_Edit1.ReplaceSel("Entrez une commande ci-dessous.\r\n\r\n");
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}

View File

@ -1,65 +0,0 @@
#if !defined(AFX_BOTCONSOLEDLG_H__A11450A2_8E09_11D4_A439_00D059085115__INCLUDED_)
#define AFX_BOTCONSOLEDLG_H__A11450A2_8E09_11D4_A439_00D059085115__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// BotConsoleDlg.h : header file
//
struct ThreadInfo
{
CEdit* m_pEdit1 ;
CBotProgram* m_pProg;
CWnd* m_pWndMessage;
BOOL m_bStop;
BOOL m_bRun;
};
/////////////////////////////////////////////////////////////////////////////
// CBotConsoleDlg dialog
class CBotConsoleDlg : public CDialog
{
// Construction
public:
CBotConsoleDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CBotConsoleDlg)
enum { IDD = IDD_CONSOLE };
CButton m_cOK;
CEdit m_Edit2;
CEdit m_Edit1;
//}}AFX_DATA
CBotProgram* m_pProg;
ThreadInfo m_threadinfo;
int m_code, m_start, m_end;
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CBotConsoleDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CBotConsoleDlg)
virtual void OnOK();
virtual void OnCancel();
virtual BOOL OnInitDialog();
afx_msg LONG EndProg(UINT wparam, LONG lparam) ;
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_BOTCONSOLEDLG_H__A11450A2_8E09_11D4_A439_00D059085115__INCLUDED_)

View File

@ -1,56 +0,0 @@
// BotErrorDlg.cpp : implementation file
//
#include "stdafx.h"
#include "TstCBot.h"
#include "BotErrorDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CBotErrorDlg dialog
CBotErrorDlg::CBotErrorDlg(CWnd* pParent /*=NULL*/)
: CDialog(CBotErrorDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CBotErrorDlg)
m_TextProgram = _T("");
//}}AFX_DATA_INIT
}
void CBotErrorDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CBotErrorDlg)
DDX_Control(pDX, IDC_EDIT1, m_eProgram);
DDX_Control(pDX, IDC_STATIC1, m_sMessage);
DDX_Text(pDX, IDC_EDIT1, m_TextProgram);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CBotErrorDlg, CDialog)
//{{AFX_MSG_MAP(CBotErrorDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBotErrorDlg message handlers
BOOL CBotErrorDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_sMessage.SetWindowText(m_TextError);
m_eProgram.SetFocus();
m_eProgram.SetSel(m_start, m_end);
return FALSE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}

View File

@ -1,51 +0,0 @@
#if !defined(AFX_BOTERRORDLG_H__80E73D20_7454_11D4_A439_00D059085115__INCLUDED_)
#define AFX_BOTERRORDLG_H__80E73D20_7454_11D4_A439_00D059085115__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// BotErrorDlg.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CBotErrorDlg dialog
class CBotErrorDlg : public CDialog
{
// Construction
public:
CBotErrorDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CBotErrorDlg)
enum { IDD = IDD_DIALOG1 };
CEdit m_eProgram;
CStatic m_sMessage;
CString m_TextProgram;
//}}AFX_DATA
CString m_TextError;
int m_start, m_end;
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CBotErrorDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CBotErrorDlg)
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_BOTERRORDLG_H__80E73D20_7454_11D4_A439_00D059085115__INCLUDED_)

View File

@ -1,36 +0,0 @@
extern void TheTest()
{
for (int x = 130; x>0; x--) print (x);
}
extern void Test()
{
int var = 10000 ;
while (var > 0) var = var -1;
}
// exécuté en 30 secondes
extern void Autre()
{
int var = 10000 ;
while (var > 0) if ( var > 0 ) var = var -1;
}
// exécuté en 45 secondes
int Y ( int n )
{
if ( n < 2 ) return n;
int a = Y(n-1) + Y(n-2);
return a;
}
extern int X ( int n )
{
if ( n < 2 ) { print(n); return n; }
int a = X(n-1) + Y(n-2);
print (a);
return a;
}

View File

@ -1,107 +0,0 @@
// CMyThread.cpp : pour créer un processus pour la console
//
#include "stdafx.h"
#include "TstCBot.h"
#include "CMyThread.h"
#include "BotConsoleDlg.h"
//IMPLEMENT_DYNAMIC (CMyThread, CWinThread)
IMPLEMENT_DYNCREATE (CMyThread, CWinThread)
/////////////////////////////////////////////////////////////////////////////
// CMyThread
BEGIN_MESSAGE_MAP(CMyThread, CWinThread)
//{{AFX_MSG_MAP(CMyThread)
//}}AFX_MSG_MAP
// Standard file based document commands
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyThread construction
CMyThread::CMyThread()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// CMyThread initialization
/*
BOOL CMyThread::InitInstance()
{
AfxEnableControlContainer();
CTstCBotApp* pApp = (CTstCBotApp*)AfxGetApp();
// ouvre une fenêtre pour afficher les sorties
CRect rect;
AfxGetMainWnd()->GetClientRect( rect );
rect += CPoint(30,30);
CWnd* pWnd = new CWnd();
pWnd->CreateEx( 0,
AfxRegisterWndClass(0, AfxGetApp()->LoadStandardCursor(IDC_ARROW)),
"CBot console", WS_POPUPWINDOW|WS_CAPTION|WS_VISIBLE,
rect,
AfxGetMainWnd()->GetParent(), NULL, NULL);
m_pMainWnd = pWnd;
pApp->m_pEdit2 = new CEdit();
m_pMainWnd->GetClientRect( rect );
rect.bottom -= 40;
pApp->m_pEdit2->Create( WS_VISIBLE|WS_BORDER|WS_TABSTOP|ES_MULTILINE|ES_WANTRETURN|
ES_AUTOVSCROLL|ES_READONLY,
rect, m_pMainWnd, IDC_EDIT2 );
pApp->m_pEdit2->ReplaceSel("Les fonctions suivantes sont disponibles:\n\r");
for ( int i = 0; i < pApp->m_Liste.RetSize(); i++ )
{
pApp->m_pEdit2->ReplaceSel(pApp->m_Liste[i] + "\r\n");
}
pApp->m_pEdit2->ReplaceSel("Entrez une commande ci-dessous.\r\r");
// pApp->m_pEdit2->SetFocus();
pApp->m_pEdit3 = new CEdit();
m_pMainWnd->GetClientRect( rect );
rect.top = rect.bottom-40;
pApp->m_pEdit3->Create( WS_VISIBLE|WS_BORDER|WS_TABSTOP,
rect, m_pMainWnd, IDC_EDIT1 );
pApp->m_pEdit3->SetFocus();
return TRUE;
}*/
BOOL CMyThread::InitInstance()
{
CBotConsoleDlg dlg;
m_pMainWnd = &dlg; // cela ferme l'application avec la DBOX !
int nResponse = dlg.DoModal();
return TRUE;
}
int CMyThread::ExitInstance()
{
return 0;
}
/////////////////////////////////////////////////////////////////////////////
// CMyThread message handlers
void CMyThread::OnReturn()
{
// TODO: Add your command handler code here
__asm int 3;
}

View File

@ -1,44 +0,0 @@
// CMyThread.h : pour créer un processus pour la console
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_MAINFRM_H__20B3756C_5DFD_11D4_A15E_00E0189013DF__INCLUDED_)
#define AFX_MAINFRM_H__20B3756C_5DFD_11D4_A15E_00E0189013DF__INCLUDED_
#include "stdafx.h"
#include "TstCBot.h"
class CMyThread : public CWinThread
{
// DECLARE_DYNAMIC(CMyThread)
DECLARE_DYNCREATE(CMyThread)
public:
// Constructor
CMyThread();
virtual BOOL InitInstance();
virtual int ExitInstance(); // return app exit code
// Implementation
//{{AFX_MSG(CTstCBotApp)
afx_msg void OnAppAbout();
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
// Generated message map functions
protected:
//{{AFX_MSG(CMainFrame)
afx_msg void OnReturn();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MAINFRM_H__20B3756C_5DFD_11D4_A15E_00E0189013DF__INCLUDED_)

View File

@ -1,91 +0,0 @@
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "TstCBot.h"
#include "MainFrm.h"
#include "BotErrorDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR, // status line indicator
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame()
{
// TODO: add member initialization code here
}
CMainFrame::~CMainFrame()
{
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CFrameWnd::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers

View File

@ -1,55 +0,0 @@
// MainFrm.h : interface of the CMainFrame class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_MAINFRM_H__70B3756C_5DFD_11D4_A15E_00E0189013DF__INCLUDED_)
#define AFX_MAINFRM_H__70B3756C_5DFD_11D4_A15E_00E0189013DF__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
class CMainFrame : public CFrameWnd
{
protected: // create from serialization only
CMainFrame();
DECLARE_DYNCREATE(CMainFrame)
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMainFrame)
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CMainFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected: // control bar embedded members
CStatusBar m_wndStatusBar;
// Generated message map functions
protected:
//{{AFX_MSG(CMainFrame)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnCp1();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MAINFRM_H__70B3756C_5DFD_11D4_A15E_00E0189013DF__INCLUDED_)

View File

@ -1,93 +0,0 @@
========================================================================
MICROSOFT FOUNDATION CLASS LIBRARY : TstCBot
========================================================================
AppWizard has created this TstCBot application for you. This application
not only demonstrates the basics of using the Microsoft Foundation classes
but is also a starting point for writing your application.
This file contains a summary of what you will find in each of the files that
make up your TstCBot application.
TstCBot.h
This is the main header file for the application. It includes other
project specific headers (including Resource.h) and declares the
CTstCBotApp application class.
TstCBot.cpp
This is the main application source file that contains the application
class CTstCBotApp.
TstCBot.rc
This is a listing of all of the Microsoft Windows resources that the
program uses. It includes the icons, bitmaps, and cursors that are stored
in the RES subdirectory. This file can be directly edited in Microsoft
Developer Studio.
res\TstCBot.ico
This is an icon file, which is used as the application's icon. This
icon is included by the main resource file TstCBot.rc.
res\TstCBot.rc2
This file contains resources that are not edited by Microsoft
Developer Studio. You should place all resources not
editable by the resource editor in this file.
TstCBot.clw
This file contains information used by ClassWizard to edit existing
classes or add new classes. ClassWizard also uses this file to store
information needed to create and edit message maps and dialog data
maps and to create prototype member functions.
/////////////////////////////////////////////////////////////////////////////
For the main frame window:
MainFrm.h, MainFrm.cpp
These files contain the frame class CMainFrame, which is derived from
CFrameWnd and controls all SDI frame features.
/////////////////////////////////////////////////////////////////////////////
AppWizard creates one document type and one view:
TstCBotDoc.h, TstCBotDoc.cpp - the document
These files contain your CTstCBotDoc class. Edit these files to
add your special document data and to implement file saving and loading
(via CTstCBotDoc::Serialize).
TstCBotView.h, TstCBotView.cpp - the view of the document
These files contain your CTstCBotView class.
CTstCBotView objects are used to view CTstCBotDoc objects.
/////////////////////////////////////////////////////////////////////////////
Other standard files:
StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named TstCBot.pch and a precompiled types file named StdAfx.obj.
Resource.h
This is the standard header file, which defines new resource IDs.
Microsoft Developer Studio reads and updates this file.
/////////////////////////////////////////////////////////////////////////////
Other notes:
AppWizard uses "TODO:" to indicate parts of the source code you
should add to or customize.
If your application uses MFC in a shared DLL, and your application is
in a language other than the operating system's current language, you
will need to copy the corresponding localized resources MFC40XXX.DLL
from the Microsoft Visual C++ CD-ROM onto the system or system32 directory,
and rename it to be MFCLOC.DLL. ("XXX" stands for the language abbreviation.
For example, MFC40DEU.DLL contains resources translated to German.) If you
don't do this, some of the UI elements of your application will remain in the
language of the operating system.
/////////////////////////////////////////////////////////////////////////////

View File

@ -1,68 +0,0 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by TstCBot.rc
//
#define IDD_ABOUTBOX 100
#define IDR_MAINFRAME 128
#define IDR_TSTCBOTYPE 129
#define IDD_DIALOG1 130
#define IDD_CONSOLE 131
#define IDC_EDIT1 1000
#define TX_TYPENAMES 1000
#define IDC_STATIC1 1001
#define IDC_EDIT2 1002
#define TX_OPENPAR 5000
#define TX_CLOSEPAR 5001
#define TX_NOTBOOL 5002
#define TX_UNDEFVAR 5003
#define TX_BADLEFT 5004
#define TX_ENDOF 5005
#define TX_OUTCASE 5006
#define TX_NOTERM 5007
#define TX_CLOSEBLK 5008
#define TX_ELSEWITHOUTIF 5009
#define TX_OPENBLK 5010
#define TX_BADTYPE 5011
#define TX_REDEFVAR 5012
#define TX_BAD2TYPE 5013
#define TX_UNDEFCALL 5014
#define TX_MISDOTS 5015
#define TX_WHILE 5016
#define TX_BREAK 5017
#define TX_LABEL 5018
#define TX_NOLABEL 5019
#define TX_NOCASE 5020
#define TX_BADNUM 5021
#define TX_VOID 5022
#define TX_NOTYP 5023
#define TX_NOVAR 5024
#define TX_NOFONC 5025
#define TX_OVERPARAM 5026
#define TX_REDEF 5027
#define TX_LOWPARAM 5028
#define TX_BADPARAM 5029
#define TX_NUMPARAM 5030
#define TX_NOITEM 5031
#define TX_DOT 5032
#define TX_NOCONST 5033
#define TX_REDEFCLASS 5034
#define TX_DIVZERO 6000
#define TX_NOTINIT 6001
#define TX_BADTHROW 6002
#define TX_NORETVAL 6003
#define TX_NORUN 6004
#define TX_NOCALL 6005
#define ID_CP1 32771
#define ID_EXE 32772
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_3D_CONTROLS 1
#define _APS_NEXT_RESOURCE_VALUE 132
#define _APS_NEXT_COMMAND_VALUE 32775
#define _APS_NEXT_CONTROL_VALUE 1002
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@ -1,6 +0,0 @@
// stdafx.cpp : source file that includes just the standard includes
// TstCBot.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"

View File

@ -1,26 +0,0 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#if !defined(AFX_STDAFX_H__70B3756A_5DFD_11D4_A15E_00E0189013DF__INCLUDED_)
#define AFX_STDAFX_H__70B3756A_5DFD_11D4_A15E_00E0189013DF__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC OLE automation classes
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__70B3756A_5DFD_11D4_A15E_00E0189013DF__INCLUDED_)

View File

@ -1,189 +0,0 @@
; CLW file contains information for the MFC ClassWizard
[General Info]
Version=1
LastClass=CTstCBotView
LastTemplate=CDialog
NewFileInclude1=#include "stdafx.h"
NewFileInclude2=#include "TstCBot.h"
LastPage=0
ClassCount=7
Class1=CTstCBotApp
Class2=CTstCBotDoc
Class3=CTstCBotView
Class4=CMainFrame
ResourceCount=6
Resource1=IDD_ABOUTBOX
Resource2=IDR_MAINFRAME
Class5=CAboutDlg
Resource3=IDD_ABOUTBOX (French (France))
Resource4=IDD_CONSOLE
Class6=CBotErrorDlg
Resource5=IDD_DIALOG1 (French (Switzerland))
Class7=CBotConsoleDlg
Resource6=IDR_MAINFRAME (French (France))
[CLS:CTstCBotApp]
Type=0
HeaderFile=TstCBot.h
ImplementationFile=TstCBot.cpp
Filter=N
[CLS:CTstCBotDoc]
Type=0
HeaderFile=TstCBotDoc.h
ImplementationFile=TstCBotDoc.cpp
Filter=N
BaseClass=CDocument
VirtualFilter=DC
LastObject=CTstCBotDoc
[CLS:CTstCBotView]
Type=0
HeaderFile=TstCBotView.h
ImplementationFile=TstCBotView.cpp
Filter=C
BaseClass=CView
VirtualFilter=VWC
LastObject=CTstCBotView
[CLS:CMainFrame]
Type=0
HeaderFile=MainFrm.h
ImplementationFile=MainFrm.cpp
Filter=T
BaseClass=CFrameWnd
VirtualFilter=fWC
LastObject=CMainFrame
[CLS:CAboutDlg]
Type=0
HeaderFile=TstCBot.cpp
ImplementationFile=TstCBot.cpp
Filter=D
[DLG:IDD_ABOUTBOX]
Type=1
Class=CAboutDlg
ControlCount=4
Control1=IDC_STATIC,static,1342177283
Control2=IDC_STATIC,static,1342308480
Control3=IDC_STATIC,static,1342308352
Control4=IDOK,button,1342373889
[MNU:IDR_MAINFRAME]
Type=1
Class=CMainFrame
Command1=ID_FILE_NEW
Command2=ID_FILE_OPEN
Command3=ID_FILE_SAVE
Command4=ID_FILE_SAVE_AS
Command5=ID_FILE_MRU_FILE1
Command6=ID_APP_EXIT
Command7=ID_EDIT_UNDO
Command8=ID_EDIT_CUT
Command9=ID_EDIT_COPY
Command10=ID_EDIT_PASTE
Command11=ID_VIEW_STATUS_BAR
Command12=ID_CP1
Command13=ID_EXE
Command14=ID_APP_ABOUT
CommandCount=14
[ACL:IDR_MAINFRAME]
Type=1
Class=CMainFrame
Command1=ID_CP1
Command2=ID_FILE_NEW
Command3=ID_FILE_OPEN
Command4=ID_FILE_SAVE
Command5=ID_EXE
Command6=ID_EDIT_UNDO
Command7=ID_EDIT_CUT
Command8=ID_EXE
Command9=ID_CP1
Command10=ID_EXE
CommandCount=10
[MNU:IDR_MAINFRAME (French (France))]
Type=1
Class=?
Command1=ID_FILE_NEW
Command2=ID_FILE_OPEN
Command3=ID_FILE_SAVE
Command4=ID_FILE_SAVE_AS
Command5=ID_FILE_MRU_FILE1
Command6=ID_APP_EXIT
Command7=ID_EDIT_UNDO
Command8=ID_EDIT_CUT
Command9=ID_EDIT_COPY
Command10=ID_EDIT_PASTE
Command11=ID_VIEW_STATUS_BAR
Command12=ID_CP1
Command13=ID_EXE
Command14=ID_APP_ABOUT
CommandCount=14
[ACL:IDR_MAINFRAME (French (France))]
Type=1
Class=?
Command1=ID_CP1
Command2=ID_FILE_NEW
Command3=ID_FILE_OPEN
Command4=ID_FILE_SAVE
Command5=ID_EXE
Command6=ID_EDIT_UNDO
Command7=ID_EDIT_CUT
Command8=ID_EXE
Command9=ID_CP1
Command10=ID_EXE
CommandCount=10
[DLG:IDD_ABOUTBOX (French (France))]
Type=1
Class=CAboutDlg
ControlCount=4
Control1=IDC_STATIC,static,1342177283
Control2=IDC_STATIC,static,1342308480
Control3=IDC_STATIC,static,1342308352
Control4=IDOK,button,1342373889
[CLS:CBotErrorDlg]
Type=0
HeaderFile=BotErrorDlg.h
ImplementationFile=BotErrorDlg.cpp
BaseClass=CDialog
Filter=D
VirtualFilter=dWC
LastObject=CBotErrorDlg
[DLG:IDD_DIALOG1 (French (Switzerland))]
Type=1
ControlCount=4
Control1=IDOK,button,1342242817
Control2=IDC_EDIT1,edit,1352728708
Control3=IDC_STATIC,static,1342308352
Control4=IDC_STATIC1,static,1342308352
[DLG:IDD_CONSOLE]
Type=1
Class=CBotConsoleDlg
ControlCount=4
Control1=IDC_STATIC,static,1342308352
Control2=IDC_EDIT2,edit,1350631552
Control3=IDOK,button,1342242817
Control4=IDC_EDIT1,edit,1352734724
[CLS:CBotConsoleDlg]
Type=0
HeaderFile=BotConsoleDlg.h
ImplementationFile=BotConsoleDlg.cpp
BaseClass=CDialog
Filter=D
VirtualFilter=dWC
LastObject=IDOK

View File

@ -1,412 +0,0 @@
// TstCBot.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "TstCBot.h"
#include "MainFrm.h"
#include "TstCBotDoc.h"
#include "TstCBotView.h"
#include "CMyThread.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
////////////////////////////////////////////////////////////////////
// routine show()
// utilisable depuis le programme écrit en CBot
// exécution
BOOL rShow( CBotVar* pVar, CBotVar* pResult, int& Exception )
{
CString s;
if ( pVar == NULL )
{
Exception = 22; return FALSE;
}
while ( pVar != NULL )
{
CString ss;
ss.LoadString( TX_TYPENAMES + pVar->RetType() );
s += ss + " ";
ss = pVar->RetName();
if (ss.IsEmpty()) ss = "<sans nom>";
s += ss + " = ";
s += pVar->RetValString();
s += "\n";
pVar = pVar->RetNext();
}
AfxMessageBox(s, MB_OK|MB_ICONINFORMATION);
// if ( pResult && pResult->RetType() == CBotTypInt) pResult->SetValInt(123);
return TRUE; // pas d'interruption
}
int cShow( CBotVar* &pVar, CBotString& RetClass)
{
if ( pVar == NULL ) return 22;
return CBotTypInt; // tous paramètres acceptés, un entier en retour
}
int cErr( CBotVar* &pVar, CBotString& RetClass)
{
pVar = pVar->RetNext(); // avance le pointeur sur l'erreur
return 6666;
}
////////////////////////////////////////////////////////////////////
// routine print()
// utilisable depuis le programme écrit en CBot
// exécution
BOOL rPrintLn( CBotVar* pVar, CBotVar* pResult, int& Exception )
{
CString s;
CTstCBotApp* pApp = (CTstCBotApp*)AfxGetApp();
CEdit* pEdit = pApp->m_pConsole;
if (pEdit == NULL) return TRUE;
pEdit->GetWindowText(s);
while ( pVar != NULL )
{
if ( !s.IsEmpty() ) s += "\r\n";
s += pVar->RetValString();
pVar = pVar->RetNext();
}
pEdit->SetWindowText(s);
pEdit->SetSel(s.GetLength(), s.GetLength());
pEdit->SetFocus();
return TRUE; // pas d'interruption
}
BOOL rPrint( CBotVar* pVar, CBotVar* pResult, int& Exception )
{
CString s;
CTstCBotApp* pApp = (CTstCBotApp*)AfxGetApp();
CEdit* pEdit = pApp->m_pConsole;
if (pEdit == NULL) return TRUE;
pEdit->GetWindowText(s);
while ( pVar != NULL )
{
if ( !s.IsEmpty() ) s += " ";
s += pVar->RetValString();
pVar = pVar->RetNext();
}
pEdit->SetWindowText(s);
pEdit->SetSel(s.GetLength(), s.GetLength());
pEdit->SetFocus();
return TRUE; // pas d'interruption
}
int cPrint( CBotVar* &pVar, CBotString& RetClass)
{
return 0; // tous paramètres acceptés, un entier en retour
}
//////////////////////////////////////////////////////////////////
// class CPoint pour essayer
// exécution
BOOL rCPoint( CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception )
{
CString s;
if ( pVar == NULL )return TRUE; // constructeur sans paramètres est ok
if ( pVar->RetType() > CBotTypDouble )
{
Exception = 6023; return FALSE;
}
CBotVar* pX = pThis->RetItem("x");
if ( pX == NULL )
{
Exception = 6024; return FALSE;
}
pX->SetValFloat( pVar->RetValFloat() );
pVar = pVar->RetNext();
if ( pVar == NULL )
{
Exception = 6022; return FALSE;
}
if ( pVar->RetType() > CBotTypDouble )
{
Exception = 6023; return FALSE;
}
CBotVar* pY = pThis->RetItem("y");
if ( pY == NULL )
{
Exception = 6024; return FALSE;
}
pY->SetValFloat( pVar->RetValFloat() );
pVar = pVar->RetNext();
if ( pVar != NULL )
{
Exception = 6025; return FALSE;
}
return TRUE; // pas d'interruption
}
int cCPoint( CBotVar* pThis, CBotVar* &pVar, CBotString& RetClass)
{
// l'objet doit être de la classe CPoint
if ( !pThis->IsElemOfClass("CPoint") ) return 6021;
// ok si aucun paramètres !
if ( pVar == NULL ) return 0;
// paramètre de type numérique svp
if ( pVar->RetType() > CBotTypDouble ) return 6023;
pVar = pVar->RetNext();
// il doit y avoir un second paramètre
if ( pVar == NULL ) return 6022;
// également de type numérique
if ( pVar->RetType() > CBotTypDouble )return 6023;
pVar = pVar->RetNext();
// et pas plus de 2 paramètres svp
if ( pVar != NULL ) return 6025;
return 0; // cette fonction retourne void
}
// méthode déterminant l'opposé
BOOL rOppose( CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception )
{
CString s;
if ( pVar != NULL ) // pas de paramètre
{
Exception = 6025; return FALSE;
}
CBotVar* pvar = pThis->RetItemList(); // demande la chaîne des items
// tous les paramètres sont des nombres
while (pvar != NULL)
{
pvar->SetValFloat( -pvar->RetValFloat() );
pvar = pvar->RetNext();
}
pResult->Copy(pThis);
return TRUE; // pas d'interruption
}
int cOppose( CBotVar* pThis, CBotVar* &pVar, CBotString& RetClass)
{
// l'objet doit être de la classe CPoint
if ( !pThis->IsElemOfClass("CPoint") ) return 6021;
RetClass = "CPoint"; // l'objet rendu est de cette class
// ok si aucun paramètres !
if ( pVar == NULL ) return CBotTypClass; // le paramètre retourné est une instance de la classe
return TX_OVERPARAM; // ça va pas
}
/////////////////////////////////////////////////////////////////////////////
// CTstCBotApp
BEGIN_MESSAGE_MAP(CTstCBotApp, CWinApp)
//{{AFX_MSG_MAP(CTstCBotApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTstCBotApp construction
CTstCBotApp::CTstCBotApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CTstCBotApp object
CTstCBotApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CTstCBotApp initialization
BOOL CTstCBotApp::InitInstance()
{
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
// Change the registry key under which our settings are stored.
// You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CTstCBotDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CTstCBotView));
AddDocTemplate(pDocTemplate);
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The one and only window has been initialized, so show and update it.
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
///////////////////////////////////
// défini la fonction "show()"
// --------------------------------
CBotProgram::AddFunction("show", rShow, cShow);
CBotProgram::AddFunction("err", rShow, cErr);
CBotProgram::AddFunction("print", rPrint, cPrint);
CBotProgram::AddFunction("println", rPrintLn, cPrint);
///////////////////////////////////
// définie la classe globale CPoint
// --------------------------------
CBotClass* m_pClassPoint;
m_pClassPoint = new CBotClass("CPoint", NULL);
// ajoute le composant ".x"
m_pClassPoint->AddItem("x", CBotTypFloat);
// ajoute le composant ".y"
m_pClassPoint->AddItem("y", CBotTypFloat);
// ajoute le constructeur pour cette classe
m_pClassPoint->AddFunction("CPoint", rCPoint, cCPoint);
// ajoute la méthode Opposé
m_pClassPoint->AddFunction("Opposé", rOppose, cOppose);
//////////////////////////////////////////////////////////////////
// compile un bout de programme pour voir s'il est bien accessible
// depuis un autre "module"
CBotProgram* p = new CBotProgram;
CBotStringArray Liste;
p->Compile(" public void MonProgram( ) { show (\"mon programme\") ;}", Liste );
// l'objet n'est pas détruit et plus référencé
// je sais c'est pas bien
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
// No message handlers
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// App command to run the dialog
void CTstCBotApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// CTstCBotApp commands

View File

@ -1,180 +0,0 @@
# Microsoft Developer Studio Project File - Name="TstCBot" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 5.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=TstCBot - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "TstCBot.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "TstCBot.mak" CFG="TstCBot - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "TstCBot - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "TstCBot - Win32 Debug" (based on "Win32 (x86) Application")
!MESSAGE
# Begin Project
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "TstCBot - Win32 Release"
# PROP BASE Use_MFC 6
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 6
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /FR /Yu"stdafx.h" /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
# ADD BASE RSC /l 0x40c /d "NDEBUG" /d "_AFXDLL"
# ADD RSC /l 0x40c /d "NDEBUG" /d "_AFXDLL"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
# ADD LINK32 /nologo /subsystem:windows /machine:I386
!ELSEIF "$(CFG)" == "TstCBot - Win32 Debug"
# PROP BASE Use_MFC 6
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 6
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /FR /Yu"stdafx.h" /FD /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
# ADD BASE RSC /l 0x40c /d "_DEBUG" /d "_AFXDLL"
# ADD RSC /l 0x40c /d "_DEBUG" /d "_AFXDLL"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
# ADD LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
!ENDIF
# Begin Target
# Name "TstCBot - Win32 Release"
# Name "TstCBot - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\BotConsoleDlg.cpp
# End Source File
# Begin Source File
SOURCE=.\MainFrm.cpp
# End Source File
# Begin Source File
SOURCE=.\StdAfx.cpp
# ADD CPP /Yc"stdafx.h"
# End Source File
# Begin Source File
SOURCE=.\TstCBot.cpp
# End Source File
# Begin Source File
SOURCE=.\TstCBot.rc
!IF "$(CFG)" == "TstCBot - Win32 Release"
!ELSEIF "$(CFG)" == "TstCBot - Win32 Debug"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\TstCBotDoc.cpp
# End Source File
# Begin Source File
SOURCE=.\TstCBotView.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\BotConsoleDlg.h
# End Source File
# Begin Source File
SOURCE=.\MainFrm.h
# End Source File
# Begin Source File
SOURCE=.\Resource.h
# End Source File
# Begin Source File
SOURCE=.\StdAfx.h
# End Source File
# Begin Source File
SOURCE=.\TstCBot.h
# End Source File
# Begin Source File
SOURCE=.\TstCBotDoc.h
# End Source File
# Begin Source File
SOURCE=.\TstCBotView.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
# Begin Source File
SOURCE=.\res\TstCBot.ico
# End Source File
# Begin Source File
SOURCE=.\res\TstCBot.rc2
# End Source File
# Begin Source File
SOURCE=.\res\TstCBotDoc.ico
# End Source File
# End Group
# Begin Source File
SOURCE=.\ReadMe.txt
# End Source File
# End Target
# End Project

View File

@ -1,62 +0,0 @@
// TstCBot.h : main header file for the TSTCBOT application
//
#if !defined(AFX_TSTCBOT_H__70B37568_5DFD_11D4_A15E_00E0189013DF__INCLUDED_)
#define AFX_TSTCBOT_H__70B37568_5DFD_11D4_A15E_00E0189013DF__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
#include "..\CBotDll.h"
class CMyThread;
/////////////////////////////////////////////////////////////////////////////
// CTstCBotApp:
// See TstCBot.cpp for the implementation of this class
//
class CTstCBotApp : public CWinApp
{
public:
CTstCBotApp();
CMyThread* m_pThread;
CWnd* m_pView;
CEdit* m_pConsole;
CBotStringArray m_Liste;
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CTstCBotApp)
public:
virtual BOOL InitInstance();
//}}AFX_VIRTUAL
// Implementation
//{{AFX_MSG(CTstCBotApp)
afx_msg void OnAppAbout();
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_TSTCBOT_H__70B37568_5DFD_11D4_A15E_00E0189013DF__INCLUDED_)
#define WM_STARTPROG WM_APP + 0
#define WM_ENDPROG WM_APP + 1

View File

@ -1,471 +0,0 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// French (France) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)
#ifdef _WIN32
LANGUAGE LANG_FRENCH, SUBLANG_FRENCH
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"#define _AFX_NO_SPLITTER_RESOURCES\r\n"
"#define _AFX_NO_OLE_RESOURCES\r\n"
"#define _AFX_NO_TRACKER_RESOURCES\r\n"
"#define _AFX_NO_PROPERTY_RESOURCES\r\n"
"\r\n"
"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)\r\n"
"#ifdef _WIN32\r\n"
"LANGUAGE 12, 1\r\n"
"#pragma code_page(1252)\r\n"
"#endif\r\n"
"#include ""res\\TstCBot.rc2"" // non-Microsoft Visual C++ edited resources\r\n"
"#include ""l.fra\\afxres.rc"" // Standard components\r\n"
"#endif\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDR_MAINFRAME ICON DISCARDABLE "res\\TstCBot.ico"
IDR_TSTCBOTYPE ICON DISCARDABLE "res\\TstCBotDoc.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Menu
//
IDR_MAINFRAME MENU PRELOAD DISCARDABLE
BEGIN
POPUP "&Fichier"
BEGIN
MENUITEM "&Nouveau\tCtrl+N", ID_FILE_NEW
MENUITEM "&Ouvrir...\tCtrl+O", ID_FILE_OPEN
MENUITEM "&Enregistrer\tCtrl+S", ID_FILE_SAVE
MENUITEM "En&registrer sous...", ID_FILE_SAVE_AS
MENUITEM SEPARATOR
MENUITEM "Fichier récent", ID_FILE_MRU_FILE1, GRAYED
MENUITEM SEPARATOR
MENUITEM "&Quitter", ID_APP_EXIT
END
POPUP "&Edition"
BEGIN
MENUITEM "&Annuler\tCtrl+Z", ID_EDIT_UNDO
MENUITEM SEPARATOR
MENUITEM "&Couper\tCtrl+X", ID_EDIT_CUT
MENUITEM "&Copier\tCtrl+C", ID_EDIT_COPY
MENUITEM "C&oller\tCtrl+V", ID_EDIT_PASTE
END
POPUP "&Affichage"
BEGIN
MENUITEM "Barre d'é&tat", ID_VIEW_STATUS_BAR
END
POPUP "&Tests"
BEGIN
MENUITEM "&Compile\tAlt+C", ID_CP1
MENUITEM "&Execute\tAlt+V", ID_EXE
END
POPUP "&?"
BEGIN
MENUITEM "&A propos de TstCBot...", ID_APP_ABOUT
END
END
/////////////////////////////////////////////////////////////////////////////
//
// Accelerator
//
IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE
BEGIN
"C", ID_CP1, VIRTKEY, ALT, NOINVERT
"N", ID_FILE_NEW, VIRTKEY, CONTROL, NOINVERT
"O", ID_FILE_OPEN, VIRTKEY, CONTROL, NOINVERT
"S", ID_FILE_SAVE, VIRTKEY, CONTROL, NOINVERT
"V", ID_EXE, VIRTKEY, ALT, NOINVERT
VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT, NOINVERT
VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT, NOINVERT
VK_F5, ID_EXE, VIRTKEY, NOINVERT
VK_F7, ID_CP1, VIRTKEY, NOINVERT
"X", ID_EXE, VIRTKEY, ALT, NOINVERT
END
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_ABOUTBOX DIALOG DISCARDABLE 0, 0, 217, 55
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "A propos de TstCBot"
FONT 8, "MS Sans Serif"
BEGIN
ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20
LTEXT "TstCBot version 1.0",IDC_STATIC,40,10,119,8,SS_NOPREFIX
LTEXT "Copyright (C) 1900",IDC_STATIC,40,25,119,8
DEFPUSHBUTTON "OK",IDOK,178,7,32,14,WS_GROUP
END
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040C04B0"
BEGIN
VALUE "CompanyName", "\0"
VALUE "FileDescription", "Application MFC TstCBot\0"
VALUE "FileVersion", "1, 0, 0, 1\0"
VALUE "InternalName", "TstCBot\0"
VALUE "LegalCopyright", "Copyright (C) 1900\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "TstCBot.EXE\0"
VALUE "ProductName", "Application TstCBot\0"
VALUE "ProductVersion", "1, 0, 0, 1\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Traduction", 0x40c, 1200
END
END
#endif // !_MAC
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_ABOUTBOX, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 210
TOPMARGIN, 7
BOTTOMMARGIN, 48
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE PRELOAD DISCARDABLE
BEGIN
IDR_MAINFRAME "TstCBot\n\nTstCBo\n\n\nTstCBot.Document\nTstCBo Document"
END
STRINGTABLE PRELOAD DISCARDABLE
BEGIN
AFX_IDS_APP_TITLE "TstCBot"
AFX_IDS_IDLEMESSAGE "Prêt"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_INDICATOR_EXT "EXT"
ID_INDICATOR_CAPS "MAJ"
ID_INDICATOR_NUM "NUM"
ID_INDICATOR_SCRL "DEF"
ID_INDICATOR_OVR "ECR"
ID_INDICATOR_REC "ENR"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_FILE_NEW "Crée un nouveau document\nNouveau"
ID_FILE_OPEN "Ouvre un document existant\nOuvrir"
ID_FILE_CLOSE "Ferme le document actif\nFermer"
ID_FILE_SAVE "Enregistre le document actif\nEnregistrer"
ID_FILE_SAVE_AS "Enregistre le document actif sous un nouveau nom\nEnregistrer sous"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_APP_ABOUT "Affiche des informations sur le programme, le numéro de version et le copyright\nA propos de"
ID_APP_EXIT "Ferme l'application ; propose d'enregistrer les documents\nQuitter"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_FILE_MRU_FILE1 "Ouvre ce document"
ID_FILE_MRU_FILE2 "Ouvre ce document"
ID_FILE_MRU_FILE3 "Ouvre ce document"
ID_FILE_MRU_FILE4 "Ouvre ce document"
ID_FILE_MRU_FILE5 "Ouvre ce document"
ID_FILE_MRU_FILE6 "Ouvre ce document"
ID_FILE_MRU_FILE7 "Ouvre ce document"
ID_FILE_MRU_FILE8 "Ouvre ce document"
ID_FILE_MRU_FILE9 "Ouvre ce document"
ID_FILE_MRU_FILE10 "Ouvre ce document"
ID_FILE_MRU_FILE11 "Ouvre ce document"
ID_FILE_MRU_FILE12 "Ouvre ce document"
ID_FILE_MRU_FILE13 "Ouvre ce document"
ID_FILE_MRU_FILE14 "Ouvre ce document"
ID_FILE_MRU_FILE15 "Ouvre ce document"
ID_FILE_MRU_FILE16 "Ouvre ce document"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_NEXT_PANE "Passe au volet de fenêtre suivant\nVolet suivant"
ID_PREV_PANE "Revient au volet précédent\nVolet précédent"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_WINDOW_SPLIT "Fractionne la fenêtre active en deux volets\nFractionner"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_EDIT_CLEAR "Efface la sélection\nEffacer"
ID_EDIT_CLEAR_ALL "Efface tout\nEffacer tout"
ID_EDIT_COPY "Copie la sélection et la place dans le Presse-papiers\nCopier"
ID_EDIT_CUT "Supprime la sélection et la place dans le Presse-papiers\nCopier"
ID_EDIT_FIND "Recherche le texte spécifié\nRechercher"
ID_EDIT_PASTE "Insère le contenu du Presse-papiers\nColler"
ID_EDIT_REPEAT "Répète la dernière action\nRépéter"
ID_EDIT_REPLACE "Remplace le texte spécifique par un texte différent\nRemplacer"
ID_EDIT_SELECT_ALL "Sélectionne le document entier\nSélectionner tout"
ID_EDIT_UNDO "Annule la dernière action\nAnnuler"
ID_EDIT_REDO "Rétablit l'action précédemment annulée\nRétablir"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_VIEW_STATUS_BAR "Affiche ou masque la barre d'état\nBarre d'état"
END
STRINGTABLE DISCARDABLE
BEGIN
AFX_IDS_SCSIZE "Change la taille de la fenêtre"
AFX_IDS_SCMOVE "Change la position de la fenêtre"
AFX_IDS_SCMINIMIZE "Réduit la fenêtre en icône"
AFX_IDS_SCMAXIMIZE "Agrandit la fenêtre au format de l'écran"
AFX_IDS_SCNEXTWINDOW "Passe à la fenêtre de document suivante"
AFX_IDS_SCPREVWINDOW "Passe à la fenêtre de document précédente"
AFX_IDS_SCCLOSE "Ferme la fenêtre active et propose l'enregistrement des documents"
END
STRINGTABLE DISCARDABLE
BEGIN
AFX_IDS_SCRESTORE "Restaure la fenêtre à sa taille d'origine"
AFX_IDS_SCTASKLIST "Active la liste des tâches"
END
STRINGTABLE DISCARDABLE
BEGIN
TX_TYPENAMES "les différents types"
1001 "Byte"
1002 "Short"
1003 "Char"
1004 "Int"
1005 "Long"
1006 "Real"
1007 "Double"
END
STRINGTABLE DISCARDABLE
BEGIN
1008 "Boolean"
1009 "Class"
1010 "String"
END
STRINGTABLE DISCARDABLE
BEGIN
TX_OPENPAR "Il manque une parenthèse ouvrante."
TX_CLOSEPAR "Il manque une parenthèse fermante."
TX_NOTBOOL "L'expression doit être un boolean."
TX_UNDEFVAR "Variable non déclarée."
TX_BADLEFT "Assignation impossible."
TX_ENDOF "Instruction non terminée."
TX_OUTCASE "Instruction ""case"" hors d'un bloc ""switch""."
TX_NOTERM "Instructions après la fin."
END
STRINGTABLE DISCARDABLE
BEGIN
TX_CLOSEBLK "Il manque la fin du bloc."
TX_ELSEWITHOUTIF "Instruction ""else"" sans ""if"" correspondant."
TX_OPENBLK "Début d'un bloc attendu."
TX_BADTYPE "Mauvais type de résultat pour l'assignation."
TX_REDEFVAR "Redéfinition d'une variable."
TX_BAD2TYPE "Les deux opérandes ne sont pas de types compatibles."
TX_UNDEFCALL "Routine inconnue."
TX_MISDOTS "Séparateur "" : "" attendu."
TX_WHILE "Manque le mot ""while""."
TX_BREAK "Instruction ""break"" en dehors d'une boucle."
TX_LABEL "Un label ne peut se placer que devant un ""for"", un ""while"", un ""do"" ou un ""switch""."
TX_NOLABEL "Cette étiquette n'existe pas"
TX_NOCASE "Manque une instruction ""case""."
TX_BADNUM "Un nombre est attendu."
TX_VOID "Paramètre void."
TX_NOTYP "Déclaration de type attendu"
END
STRINGTABLE DISCARDABLE
BEGIN
TX_DIVZERO "Division par zéro."
TX_NOTINIT "Variable non initialisée."
TX_BADTHROW "Valeur négative refusée pour ""throw""."
TX_NORETVAL "La fonction n'a pas retourné de résultat"
TX_NORUN "Pas de fonction en exécution"
TX_NOCALL "Appel d'une fonction inexistante"
END
STRINGTABLE DISCARDABLE
BEGIN
TX_NOVAR "Nom d'une variable attendu"
TX_NOFONC "Nom de la fonction attendu."
TX_OVERPARAM "Trop de paramètres"
TX_REDEF "Cette fonction existe déjà."
TX_LOWPARAM "Pas assez de paramètres"
TX_BADPARAM "Aucune fonction de ce nom n'accepte ce(s) type(s) de paramètre(s)"
TX_NUMPARAM "Aucune fonction de ce nom n'accepte ce nombre de paramètres"
TX_NOITEM "Cet élément n'exite pas dans cette classe."
TX_DOT "L'objet n'est pas une instance d'une classe."
TX_NOCONST "Il n'y a pas de constructeur approprié."
TX_REDEFCLASS "Cette classe existe déjà."
END
#endif // French (France) resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// French (Switzerland) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRS)
#ifdef _WIN32
LANGUAGE LANG_FRENCH, SUBLANG_FRENCH_SWISS
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_CONSOLE DIALOG DISCARDABLE 0, 0, 401, 210
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "CBot Console"
FONT 8, "MS Sans Serif"
BEGIN
LTEXT "Commande :",IDC_STATIC,7,177,40,8
EDITTEXT IDC_EDIT2,7,189,329,14,ES_AUTOHSCROLL
DEFPUSHBUTTON "Exécute",IDOK,344,189,50,14
EDITTEXT IDC_EDIT1,7,7,387,167,ES_MULTILINE | ES_READONLY |
ES_WANTRETURN | WS_VSCROLL
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_CONSOLE, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 394
TOPMARGIN, 7
BOTTOMMARGIN, 203
END
END
#endif // APSTUDIO_INVOKED
#endif // French (Switzerland) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)
#ifdef _WIN32
LANGUAGE 12, 1
#pragma code_page(1252)
#endif
#include "res\TstCBot.rc2" // non-Microsoft Visual C++ edited resources
#include "l.fra\afxres.rc" // Standard components
#endif
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@ -1,83 +0,0 @@
// TstCBotDoc.cpp : implementation of the CTstCBotDoc class
//
#include "stdafx.h"
#include "TstCBot.h"
#include "TstCBotDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTstCBotDoc
IMPLEMENT_DYNCREATE(CTstCBotDoc, CDocument)
BEGIN_MESSAGE_MAP(CTstCBotDoc, CDocument)
//{{AFX_MSG_MAP(CTstCBotDoc)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTstCBotDoc construction/destruction
CTstCBotDoc::CTstCBotDoc()
{
// TODO: add one-time construction code here
}
CTstCBotDoc::~CTstCBotDoc()
{
}
BOOL CTstCBotDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CTstCBotDoc serialization
void CTstCBotDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
}
else
{
// TODO: add loading code here
}
}
/////////////////////////////////////////////////////////////////////////////
// CTstCBotDoc diagnostics
#ifdef _DEBUG
void CTstCBotDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CTstCBotDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CTstCBotDoc commands

View File

@ -1,55 +0,0 @@
// TstCBotDoc.h : interface of the CTstCBotDoc class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_TSTCBOTDOC_H__70B3756E_5DFD_11D4_A15E_00E0189013DF__INCLUDED_)
#define AFX_TSTCBOTDOC_H__70B3756E_5DFD_11D4_A15E_00E0189013DF__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
class CTstCBotDoc : public CDocument
{
protected: // create from serialization only
CTstCBotDoc();
DECLARE_DYNCREATE(CTstCBotDoc)
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CTstCBotDoc)
public:
virtual BOOL OnNewDocument();
virtual void Serialize(CArchive& ar);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CTstCBotDoc();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
//{{AFX_MSG(CTstCBotDoc)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_TSTCBOTDOC_H__70B3756E_5DFD_11D4_A15E_00E0189013DF__INCLUDED_)

View File

@ -1,291 +0,0 @@
// TstCBotView.cpp : implementation of the CTstCBotView class
//
#include "stdafx.h"
#include "TstCBot.h"
#include "TstCBotDoc.h"
#include "TstCBotView.h"
#include "BotConsoleDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTstCBotView
IMPLEMENT_DYNCREATE(CTstCBotView, CView)
BEGIN_MESSAGE_MAP(CTstCBotView, CView)
//{{AFX_MSG_MAP(CTstCBotView)
ON_WM_SIZE()
ON_COMMAND(ID_CP1, OnCp1)
ON_COMMAND(ID_EXE, OnExe)
ON_COMMAND(ID_FILE_SAVE, OnFileSave)
ON_COMMAND(ID_FILE_SAVE_AS, OnFileSaveAs)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTstCBotView construction/destruction
CTstCBotView::CTstCBotView()
{
// TODO: add construction code here
m_pEdit = NULL;
m_pProg = NULL;
}
CTstCBotView::~CTstCBotView()
{
}
BOOL CTstCBotView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
void CTstCBotView::OnActivateView( BOOL bActivate, CView* pActivateView, CView* pDeactiveView )
{
if ( m_pEdit == NULL)
{
m_pEdit = new CEdit();
CRect rect;
GetClientRect( rect );
m_pEdit->Create( WS_VISIBLE|WS_BORDER|WS_TABSTOP|ES_MULTILINE|ES_WANTRETURN|ES_NOHIDESEL|ES_AUTOVSCROLL,
rect, this, IDC_EDIT1 );
m_pEdit->SetTabStops(12);
LoadEdition("CBotTest.txt");
m_pEdit->SetFocus();
}
}
/////////////////////////////////////////////////////////////////////////////
// CTstCBotView drawing
void CTstCBotView::OnDraw(CDC* pDC)
{
CTstCBotDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CTstCBotView diagnostics
#ifdef _DEBUG
void CTstCBotView::AssertValid() const
{
CView::AssertValid();
}
void CTstCBotView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CTstCBotDoc* CTstCBotView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTstCBotDoc)));
return (CTstCBotDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CTstCBotView message handlers
void CTstCBotView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
if ( m_pEdit != NULL )
{
CRect rect;
GetClientRect( rect );
m_pEdit->MoveWindow( rect );
m_pEdit->SetFocus();
}
}
void CTstCBotView::SaveEdition(const char* filename)
{
CString program;
m_pEdit->GetWindowText(program);
FILE* pf = fopen(filename, "wb");
if (pf==NULL) return;
fputs (program, pf);
fclose(pf);
}
void CTstCBotView::LoadEdition(const char* filename)
{
CString program("{ int x = 10000; while (x > 0) x = x-1; }");
FILE* pf = fopen(filename, "r");
if (pf!=NULL)
{
char buffer[10000];
program.Empty();
while (NULL != fgets (buffer, 100000, pf))
{
program += buffer;
program = program.Left(program.GetLength()-1) + "\r\n";
}
fclose(pf);
}
m_pEdit->SetWindowText(program);
}
// compile le programme
#include <stdio.h>
void CTstCBotView::OnCp1()
{
CString program;
SaveEdition("CBotTest.txt");
m_pEdit->GetWindowText(program);
CString TextError;
int code, start, end;
if ( m_pProg == NULL ) m_pProg = new CBotProgram();
CTstCBotApp* pApp = (CTstCBotApp*)AfxGetApp();
if (m_pProg->Compile(program, pApp->m_Liste))
{
CString done = "Compilation sans erreur.\nLes fonctions suivantes sont externes:\n";
for ( int i = 0; i < pApp->m_Liste.RetSize(); i++)
{
done += CString(pApp->m_Liste[i]) + "\n";
}
AfxMessageBox( done );
}
else
{
m_pProg->GetError(code, start, end);
delete m_pProg;
m_pProg = NULL;
m_pEdit->SetSel( start, end );
m_pEdit->SetFocus(); // met en évidence la partie avec problème
TextError.LoadString( code );
if (TextError.IsEmpty())
{
char buf[100];
sprintf(buf, "Erreur numéro %d.", code);
TextError = buf;
}
AfxMessageBox( TextError );
}
m_pEdit->SetFocus();
}
//////////////////////////////////////////////////////
void CTstCBotView::OnExe()
{
CTstCBotApp* pApp = (CTstCBotApp*)AfxGetApp();
if( m_pProg == NULL)
{
AfxMessageBox("Pas de programme compilé !");
return;
}
if( pApp->m_Liste.RetSize() == 0 )
{
AfxMessageBox("Aucune fonction marquée \"extern\" !");
return;
}
CBotConsoleDlg dlg;
dlg.DoModal(); // dialogue pour faire la console
if ( dlg.m_code>0 )
{
CString TextError;
m_pEdit->SetSel( dlg.m_start, dlg.m_end );
m_pEdit->SetFocus(); // met en évidence la partie avec problème
TextError.LoadString( dlg.m_code );
if (TextError.IsEmpty())
{
char buf[100];
sprintf(buf, "Erreur numéro %d.", dlg.m_code);
TextError = buf;
}
// AfxMessageBox( TextError );
}
m_pEdit->SetFocus();
return;
}
void CTstCBotView::OnFileSave()
{
// TODO: Add your command handler code here
SaveEdition("CBotTest.txt");
}
void CTstCBotView::OnFileSaveAs()
{
CFileDialog *pDlg;
CString s;
pDlg = new CFileDialog(FALSE, "TXT", NULL,
OFN_OVERWRITEPROMPT|OFN_HIDEREADONLY,
"cboxtest|*.txt", this);
if ( pDlg == NULL ) return;
if ( pDlg->DoModal() == IDOK ) // choix du fichier ...
{
SaveEdition(pDlg->GetPathName());
}
delete pDlg;
}
#if 0
void test()
{
int y,z;
for (;;);
for (x = 0; y = 1; z = 3) int q = 6;
for (int x = 0; int y = 1; int z = 3) int q = 6;
// pour voir
}
#endif

View File

@ -1,81 +0,0 @@
// TstCBotView.h : interface of the CTstCBotView class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_TSTCBOTVIEW_H__70B37570_5DFD_11D4_A15E_00E0189013DF__INCLUDED_)
#define AFX_TSTCBOTVIEW_H__70B37570_5DFD_11D4_A15E_00E0189013DF__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
class CBotProgram;
class CBotClass;
class CTstCBotView : public CView
{
protected: // create from serialization only
CTstCBotView();
DECLARE_DYNCREATE(CTstCBotView)
CEdit* m_pEdit; // texte en édition
CWnd* m_pWnd;
CBotProgram* m_pProg; // programme compilé
// Attributes
public:
CTstCBotDoc* GetDocument();
// Operations
public:
void LoadEdition(const char* name);
void SaveEdition(const char* name);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CTstCBotView)
public:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual void OnActivateView( BOOL bActivate, CView* pActivateView, CView* pDeactiveView );
protected:
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CTstCBotView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
//{{AFX_MSG(CTstCBotView)
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnCp1();
afx_msg void OnExe();
afx_msg void OnFileSave();
afx_msg void OnFileSaveAs();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#ifndef _DEBUG // debug version in TstCBotView.cpp
inline CTstCBotDoc* CTstCBotView::GetDocument()
{ return (CTstCBotDoc*)m_pDocument; }
#endif
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_TSTCBOTVIEW_H__70B37570_5DFD_11D4_A15E_00E0189013DF__INCLUDED_)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1,13 +0,0 @@
//
// TSTCBOT.RC2 - resources Microsoft Visual C++ does not edit directly
//
#ifdef APSTUDIO_INVOKED
#error this file is not editable by Microsoft Visual C++
#endif //APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
// Add manually edited resources here...
/////////////////////////////////////////////////////////////////////////////

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1,213 +0,0 @@
// test de l'interpréteur CBot, (c) D. Dumoulin 2000
Int Somme ( Int x, Int y )
{
return x + y;
}
Real Somme ( Real x, Real y )
{
return x + y;
}
void A_Faire()
{
CPoint position; // utilise une classe externe
position.x = 123.5;
position.y = -45.1;
show ( position );
}
/* Les nouveautés sont les suivantes
__________________________________________________
On peut définir des fonctions, avec la syntaxe habituelle au C
void MaFonction( Int x, Real y ) { ... }
Les caractéristiques sont pour l'instant les suivantes:
- ce programme TstCBot exécute la dernière fonction définie
- on peut définir deux fonctions du même nom,
si la liste de paramètres est différente.
Par exemple
Int Somme( Int x, Int y )
Real Somme( Real x, Real y );
Note: si la seconde n'existait pas, Somme ( 1.3, 4.8 )
serait fait sur les nombres entier 1 + 4
La priorité est donnée à la routine qui ne pert pas
de bits dans la conversion des paramètres.
- il n'y a pas d'erreur de compilation si une routine
ne retourne pas de valeur alors qu'elle devrait,
par contre il y a une erreur "correcte" à l'exécution
- il est possible d'utiliser une fonction qui est définie
plus bas dans le programme.
__________________________________________________
Tous les blocs d'instructions existent maintenant, à savoir
label :
while (condition) { instructions; break label; continue label; }
label :
do { instructions; break label; continue label; } while (condition)
label:
for (initial; condition; incrément) { instructions; break; continue }
switch ( valeur ) { case 1: instructions; case 2: break ; }
try {instructions; throw exception; } catch (exception) {instructions;}
catch (testlogique) {instructions;}
finally {instructions;}
// le bloc finally est exécuter dans tous les cas
// qu'il y ait eu exception ou non, et aussi en cas de break, continue ou return
__________________________________________________
Les "exceptions" sont juste des numéros (31 bits)
6000 = division par zéro
6001 = variable non initialisée
6002 = valeur négative pour un throw
6003 = la fonction n'a pas retourné de valeur
les autres numéros sont à disposition
(COLOBOT aura surement des numéros d'exception propre)
l'association d'un mot clef pour ces exceptions est à venir.
__________________________________________________
L'interpréteur a été un peu optimiser, une boucle de un millon de décrément
ne prend plus que
*/
void Test ()
{ // début du bloc d'instructions
Int z = 1000000;
while ( z>0 ) z--;
return;
{
// test la préséance pour les assignations
Int a = 9;
a += (a = 3);
if ( a != 12 ) 1/0; // le résultat correct est 12
Int b = 9;
b = b + (b = 3);
if (b != 12) 1/0; // même chose
// la fonction show est une fonction externe
// définie par TstCBot
// elle peut prendre un nombre quelconque de paramètres
show ( a, b );
}
{
// petit test sur les chaînes
String x = "ch." ;
String y ;
x += y = x + " de la brume.";
// concaténation de chaînes, accepte des autres types
String s = 1 + 2 + " test " + 3 + 4 ;
show( x, y, s );
// les tests sur les chaînes ne sont pas standard en Java
// mais c'est si pratique :
if ( s != "3 test 34" ) 1/0; // le résultat correct est "3 test 34"
// car 1+2 est évalué en premier entre 2 nombres
// et ensuite on additionne des chaînes "3" "4"
}
{
// teste toutes les opérations avec les entiers (32 bits)
Int a = 4;
Int b = 4;
Int c = a++ * --b; // post incrément, pré décrément
if ( c != 12 ) 1/0;
c = ++a * b--; // pré incrément, post décrément
if ( c!=18 ) 1/0;
a = a+b-a*b/a%3; // 6 + 2 - ( 6 * 2 / 6 % 3 ) -> 6
if ( a != 6 ) 1/0;
a += 2; a-=1; a*=3; a/=4; a%=3; // (6+2 -1) *3 /4 modulo 3 = 21 / 4 modulo 3 = 2
if ( a!= 2) 0/0;
if (-5 << 3 != -40) 0/0; // shift à gauche
if ( -5 >> 1 != -3) 0/0; // shift arithmétique à droite 11111011 -> 11111101 = -3
if ( -5 >>> 1 != 0x3ffffffd) 0/0; // shift non signé à droite
a = -10; // fait la même chose en assignation
a <<= 1; // -20
a >>= 2; // -5
a >>>= 1; // pert le signe
if ( a != 0x3ffffffd) 0/0; //
Int x = 5/3; // division d'entiers
if ( x != 1 ) 0/0;
Int xx = 5.0/3.0; // division de réels, assigné à un entier
if ( xx != 1 ) 0/0;
Int y = 0xF0035678;
if ( ~y != 0x0FFCA987 ) 0/0; // NOT bit à bit
if ( (0x3456 ^ 0x54f0) != 0x60A6) // XOR bit à bit
0/0;
if ( (0x23 | 0x83) != 0xA3 ) 0/0; // OR bit à bit
if ( (0x23 & 0x83) != 0x03 ) 0/0; // AND bit à bit
Int z = 0x0123;
z |= 0x8010; if ( z != 0x8133) 0/0;
z &= 0xF018; if ( z != 0x8010) 0/0;
z ^= 0xFF17; if ( z != 0x7F07) 0/0;
}
{
// test pour les booléens
Boolean a, b= true, c = false;
a = b | c & b;
if ( a != b ) 0/0;
if ( !a ) 0/0;
if ( b ^ a ) 0/0; // XOR
if ( true || 0/0<1 ) {};
if ( false && 0/0<1) {};
// a ? "vrai" : "faux";
}
{
// petit test sur les nombres réels
Real x = 1. / 3, y = 0;
if ( 3 * x != 1 ) x = x / y; // provoque une division par zéro
else y = 1.123;
}
// test de durée
// attention, le programme de test ne stoppe qu'à la fin d'exécution
// bien que la boucle est interrompue plusieures fois
// la boucle est plus rapide si elle est au début du programme !
{
Int z = 10000;
while ( z > 0 ) z = z - 1;
}
}
void t()
{
A_Faire();
show ( Somme ( 1, 2 ) );
show ( Somme ( 1., 2 ) );
show ( Somme ( 4.5, 2.7 ) );
}

View File

@ -1,43 +0,0 @@
// test de l'interpréteur CBot, (c) D. Dumoulin 2000
// pour l'instant, seule les primitives suivantes sont implémentées
// { ... ; ... ; ... } un bloc d'instructions
// int x, y = 12, z; // déclaration de nombre entier
// float a, b= 2/3, c=b+1; // déclaration de nombres réels
// boolean tst = true; // déclaration d'un booléen
// String x = "hello"; // déclaration d'une chaînes
// z = x = x * y / ( z + 1 - x ); // assignation en chaîne et les 4 opérations
// while ( x >= 0 ) x = x - 1; // boucle while, et test > >= < <= == !=
// if ( x < y ) x = x + 1; // test si
// else y = y + 1; // sinon
/* et les opérations suivantes:
+ plus unaire x = +y;
- moins unaire x = -y;
|| OU logique
&& ET logique
! NOT logique
| OU bit à bit
& ET bit à bit
^ XOR bit à bit
~ NON bit à bit
// les commentaires sont acceptés
/* y compris les commentaires
sur plusieures lignes */
{
String str ;
str = "abc" ;
show (str) ;
show( str = str + "+++" , ) ;
}

View File

@ -2,7 +2,7 @@ extern public void x()
{
float a= 1, b = 2;
a = b * ( 2 + 2 );
// print (a);
print (a);
a += 4;
// print (a);
print (a);
}