anyKode Marilou
ContentsIndexHome
PreviousUpNext
Exemple

Exemple d'un programme MODA en C++ CLI et C# (.Net Framework):

C++

//Visual .Net 2005 Managed C++ syntax:

// Moda2005CPPManaged.cpp : main project file.

#include "stdafx.h"
#include "Windows.h"
#include "conio.h"

using namespace System;
using namespace Moda;

int main(array<System::String ^> ^args)
{
String ^RobotName="/robot1";
String ^ModaServerAddr="localhost";

Moda::Connection ^connection=gcnew Moda::Connection(true);

if(connection->Connect(ModaServerAddr))
    {
    _cprintf("Connection ok \r\n");
    Moda::RobotPHX ^robot=connection->QueryRobotPHX(RobotName);
    if(robot)
        {
        _cprintf("robot found\r\n");
        }
    else
        {
        _cprintf("robot not found\r\n");
        }
    }
else
    {
    _cprintf("Unable to connect\r\n");
    }

connection->Disconnect();
_getch();
return 0;
}
//...

C#

//Visual .Net 2005 Managed C# syntax:

using System;
using System.Collections.Generic;
using System.Text;

namespace Moda2005CS
    {
    class Program
        {
        static void Main(string[] args)
            {
            Moda.Connection connection=new Moda.Connection(true);
            if(connection.Connect("localhost"))
                {
                Console.WriteLine("Connection ok");
                Moda.RobotPHX robot=connection.QueryRobotPHX("/mon Robot");
                if(robot!=null)
                    {
                    Console.WriteLine("robot found");
                    }
                else
                    {
                    Console.WriteLine("robot not found");
                    }
                }
            else
                {
                Console.WriteLine("Unable to connect");
                }
            connection.Disconnect();
            }
       }
   }
//...

Documentation v4.7 (18/01/2015), Copyright (c) 2015 anyKode. All rights reserved.
What do you think about this topic? Send feedback!