Показать сообщение отдельно
Старый 22.12.2006, 12:43   #3  
slava is offline
slava
сибиряк
Самостоятельные клиенты AX
 
468 / 23 (1) +++
Регистрация: 28.12.2001
Адрес: Москва
X++:
Boolean getDataFromScaner()
{
    boolean         error;
    DLL             dll     = new DLL('stdCipherLab');
    DLLFunction     func;
    boolean         ret;
    int             res;
    real            rr;
    int             a;
    Binary          b;//       = new Binary(res);
    str             st1, st2, st3, st4, st5, st6, st7, st8, errSt;
    Binary          struct1 = new Binary(4),
                    struct2 = new Binary(4),
                    struct3 = new Binary(4),
                    struct4 = new Binary(4),
                    struct5 = new Binary(4),
                    struct6 = new Binary(4),
                    struct7 = new Binary(4),
                    struct8 = new Binary(4),
                    err     = new Binary(4);
    boolean         currentState;
    ASCIIIO                         file;
    ;

    if (AA_TradeSetup::find(winapi::getComputerName()))
    {

    file = new ASCIIIO("c:\\scanerData.txt", "W");
    file.write("");

    func    = new DLLFunction(dll, 'stdCheckComm');
    func.arg();
    func.call();
    /*
    func    = new DLLFunction(dll, 'stdCloseComm');
    func.arg();
    res = func.call();
    */
    func    = new DLLFunction(dll, 'stdOpenComm');
    func.returns(ExtTypes::DWord);
    func.arg(ExtTypes::DWord, ExtTypes::DWord, ExtTypes::DWord);//, ExtTypes::DWord);
      res = func.call(AA_TradeSetup::find(winapi::getComputerName()).TSDPort, AA_TradeSetup::find(winapi::getComputerName()).TSDSpeed, 1);

    if (res)
     {
        func    = new DLLFunction(dll, 'stdGetCurrentState');
        func.returns(ExtTypes::DWord);
        func.arg();//
        currentState = func.call();
        if (currentState)
         {
            func    = new DLLFunction(dll, 'stdGetDataCount');
            func.returns(ExtTypes::DWord);
            func.arg(ExtTypes::DWord);
            rr = func.call(0);
            if (rr)
             {
              func    = new DLLFunction(dll, 'stdDocToFile');
              func.returns(ExtTypes::DWord);
              func.arg(ExtTypes::DWord, ExtTypes::String);
              res = func.call(0,'c:\\scanerData.txt');

                func    = new DLLFunction(dll, 'stdGetDataCount');
                func.returns(ExtTypes::DWord);
                func.arg(ExtTypes::DWord);
                rr = func.call(0);
                if (rr)
                {
                  func    = new DLLFunction(dll, 'stdClearDoc');
                  func.returns(ExtTypes::DWord);
                  func.arg(ExtTypes::DWord);
                  res = func.call(0);
                }

              func    = new DLLFunction(dll, 'stdCloseComm');
              func.returns(ExtTypes::DWord);
              func.arg();
              res = func.call();

              dll.finalize();
             } // if rr
             else
             {
                  func    = new DLLFunction(dll, 'stdCloseComm');
                  func.returns(ExtTypes::DWord);
                  func.arg();
                  res = func.call();
                  dll.finalize();
             }
         }
         else
         {
         Info(strfmt('%1',
                    (currentState ? "Готов к работе" : "Не в режиме главного меню")));
      //  slava  return false; // Alex, 09/02-06 -->
         }
     }
     else
     {
     Info(strfmt('%1',
               "Не могу открыть порт"));
 // slava    return false; // Alex, 09/02-06 -->
     }
    }
return true;
}
Приемрно так. Как-то работает. Класс я Вам выслал по почте.
__________________
С уважением, Вячеслав.