void __fastcall TPrihodForm::ButtonModifyClick(TObject &Sender) { if(!Document->Partner->ID_Partner) { ShowMessage("введите поставщика"); return; } TPrihod * p = new TPrihod(FrameList1->Query->FieldByName("id_prihod")->AsInteger); TTovar * t = new TTovar(p->ID_Tovar); float Kilxkist = 0; try { Kilxkist = StrToFloat(InputBox("введите количество:","Количество:", "1")); } catch ( ... ) { ShowMessage("введено неправильное количество!"); } if(Kilxkist <= 0) { ShowMessage("количество не может быть нулевым или минусовым"); delete p; delete t; return; } p->Kilxkist = Kilxkist; p->Save(); delete p; delete t; Refresh(); }
void __fastcall TNakladnaForm::ButtonModifyClick(TObject &Sender) { if(!Document->Partner->ID_Partner) { ShowMessage("введите покупателя"); return; } TRashod * r = new TRashod(FrameList1->Query->FieldByName("id_rashod")->AsInteger); TTovar * t = new TTovar(r->ID_Tovar,Document->Partner->ID_Partner); float Kilxkist = 0; try { Kilxkist = StrToFloat(InputBox("введите количество:","Количество:", FloatToStr(r->Kilxkist))); } catch ( ... ) { ShowMessage("введено неправильное количество!"); } r->Kilxkist = Kilxkist; r->Cina = t->CinaProdazh; if(Kilxkist <= 0) { ShowMessage("количество не может быть нулевым или минусовым"); delete r; delete t; return; } if(t->Ostatok < Kilxkist) ShowMessage("столько количества товара нету на складе"); else r->Save(); delete r; delete t; Refresh(); }
std::string CFileDialog::AskPassword(LIBSU::CLibSU &suhandler) { std::string ret; while (true) { ret = InputBox(GetTranslation("Your account doesn't have permissions to " "create the directory.\nTo create it with the root " "(administrator) account, please enter it's password below."), "", 0, '*'); if (ret.empty()) break; if (!suhandler.TestSU(ret.c_str())) { if (suhandler.GetError() == LIBSU::CLibSU::SU_ERROR_INCORRECTPASS) WarningBox(GetTranslation("Incorrect password given for root user\nPlease retype")); else { WarningBox(GetTranslation("Could not use su to gain root access.\n" "Make sure you can use su (adding the current user to the wheel group may help).")); break; } } else break; } return ret; }
void __fastcall TNakladnaForm::FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { if(Shift.Contains(ssCtrl)) if(Key == 'p' || Key == 'P' || Key == 'з' || Key == 'З' ) cxButton3Click(*Sender); if(Key == VK_F2) { if(!Document->Partner->ID_Partner) { ShowMessage("введите покупателя"); return; } TRashod * r = new TRashod(FrameList1->Query->FieldByName("id_rashod")->AsInteger); TTovar * t = new TTovar(r->ID_Tovar,Document->Partner->ID_Partner); float Cina = r->Cina; try { Cina = StrToFloat(InputBox("введите цену:","Цена:", FormatFloat("0.00",r->Cina))); } catch ( ... ) { ShowMessage("введена неправильная цена!"); delete r; delete t; return; } r->Cina = Cina; r->Save(); delete r; delete t; Refresh(); } }
//--------------------------------------------------------------------------- // ƒобавл¤ю средство измерени¤ в список void __fastcall TListInstr::N1Click(TObject *Sender) { AnsiString nameOrType= InputBox("¬ведите наименование или тип прибора", "¬ведите наименование или тип прибора:", ""); if (nameOrType.IsEmpty()) return; AnsiString monufNumber = InputBox("¬ведите заводской номер прибора", "¬ведите заводской номер прибора:", ""); if (monufNumber.IsEmpty()) return; if (!Grid->Cells[0][1].IsEmpty()) // необходимость, если хошь иметь шапку { Grid->RowCount++; } // типа добавл¤ю int k = Grid->RowCount - Grid->FixedRows; Grid->Cells[0][k] = k; // номер строки Grid->Cells[1][k] = nameOrType; // наименование или тип Grid->Cells[2][k] = monufNumber; // заводской номер }
//---------------------------------------------------------------------------- void CMorphwizardView::OnToolsSetParaNo() { if (found_paradigms.empty()) { ErrorMessage("Cannot set paradigm No to an empty found list"); return; }; POSITION pos = m_FoundList.GetFirstSelectedItemPosition(); WORD ParadigmNo = 0; if(pos != 0) { size_t index = m_FoundList.GetNextSelectedItem(pos); assert(index < found_paradigms.size()); ParadigmNo = found_paradigms[index]->second.m_FlexiaModelNo; } string s = Format("%i",ParadigmNo); if ( !InputBox("Input paradigm No:", s) ) return; ParadigmNo = atoi(s.c_str()); if (ParadigmNo >= GetWizard()->m_FlexiaModels.size()) { ErrorMessage(Format("Paradigm no %i is not found",ParadigmNo)); return; } std::string Warn = Format("The program ascribes all found words to paradigm %i . Continue?", ParadigmNo); if (::MessageBox (0, Warn.c_str(),"MorphWizard",MB_OKCANCEL ) != IDOK ) return; const CFlexiaModel &new_par = GetWizard()->m_FlexiaModels[ParadigmNo]; size_t ErrorsCount = 0; for (size_t i=0; i<found_paradigms.size(); i++) { const CFlexiaModel &old_par = GetWizard()->m_FlexiaModels[found_paradigms[i]->second.m_FlexiaModelNo]; if (found_paradigms[i]->second.m_FlexiaModelNo == ParadigmNo) continue; std::string new_flexia = new_par.get_first_flex(); std::string lemma = GetWizard()->get_lemm_string(found_paradigms[i]); std::string lemma_suffix = lemma.substr(lemma.length() - new_flexia.length()); if (new_flexia == lemma_suffix) { GetWizard()->change_prd_info(found_paradigms[i]->second, lemma, ParadigmNo,UnknownAccentModelNo,true); } else { ErrorsCount++; }; }; if (ErrorsCount > 0) { ErrorMessage (Format("This last operation cannot change lemma in %i cases.", ErrorsCount)); }; ShowFoundParadigms(); }
//--------------------------------------------------------------------------- __fastcall TChatClientWindow::TChatClientWindow (TComponent* Owner) : TForm (Owner), orb_thread_ (0) { try { nickname_ = InputBox ("Enter Nickname", "Enter the nickname you would like to use:", "noname"); if (!OpenDialog->Execute ()) throw Exception ("IOR file not selected - unable to continue"); ior_file_name_ = OpenDialog->FileName; // Retrieve the ORB. orb_ = CORBA::ORB_init (_argc, _argv); // Get reference to the Root POA CORBA::Object_var obj = orb_->resolve_initial_references ("RootPOA"); PortableServer::POA_var poa = PortableServer::POA::_narrow (obj); // Activate the POA manager PortableServer::POAManager_var mgr = poa->the_POAManager (); mgr->activate (); // Run the orb in a separate thread orb_thread_.reset (new TORBThread (orb_)); // set the orb in the receiver_i_ object. receiver_i_.orb (orb_); // read the ior from file ReadIOR (ior_file_name_); CORBA::Object_var server_object = orb_->string_to_object (ior_.c_str ()); if (CORBA::is_nil (server_object.in ())) throw Exception ("Invalid IOR " + ior_); server_ = Broadcaster::_narrow (server_object); receiver_var_ = receiver_i_._this (); // Register ourselves with the server. server_->add (receiver_var_, nickname_.c_str ()); } catch (CORBA::Exception &e) { ShowMessage ("CORBA Exception in TChatClientWindow constructor: " + String (e._rep_id ())); throw; } }
//--------------------------------------------------------------------------- void __fastcall TPrihodForm::ButtonInsertClick(TObject &Sender) { if(!Document->Partner->ID_Partner) { ShowMessage("введите поставщика"); return; } TTovarListForm * tlf = new TTovarListForm(this); tlf->ShowModal(); if(!tlf->SelectedItem) return; TTovar * t = tlf->SelectedItem; TPrihod * p; Refresh(); if(FrameList1->Query->Locate("id_tovar", t->ID_Tovar, TLocateOptions()<<loCaseInsensitive<<loPartialKey )) p = new TPrihod(FrameList1->Query->FieldByName("id_prihod")->AsInteger); else p = new TPrihod(0); p->ID_Tovar = t->ID_Tovar; p->ID_Partner = Document->Partner->ID_Partner; p->Nomer = Document->Nomer; p->DataDok = Document->DataDok; p->Cina = t->CinaZakup; float Kilxkist = 0; try { Kilxkist = StrToFloat(InputBox("введите количество:","Количество:", "1")); } catch ( ... ) { ShowMessage("введено неправильное количество!"); } if(Kilxkist <= 0) { ShowMessage("количество не может быть нулевым или минусовым"); delete p; delete t; delete tlf; return; } t->ID_Partner = Document->Partner->ID_Partner; t->Save(); p->Kilxkist += Kilxkist; p->Save(); delete p; delete t; delete tlf; Refresh(); FrameList1->Query->Last(); }
//--------------------------------------------------------------------------- void TfrmMainFormServer::AddANewModule(){ AnsiString name = InputBox("New Virtual Directory", "Enter an alias WITHOUT spaces", "ANewName"); if(name.Length() > 0){ adapter.AddANewModule(name); LoadModuleNames(); } }
main() { int Answer; float value; Answer = InputBox("Enter Distance",&value); if (Answer) printf("Operator Canceled\n"); else printf("Operator Entered Value of %.3f\n",value); }
void CMorphwizardView::OnBnClickedSetPrdComments() { POSITION pos = m_FoundList.GetFirstSelectedItemPosition(); if(pos == 0) { ErrorMessage ("No item selected"); echo("No item selected"); return; }; size_t index = m_FoundList.GetNextSelectedItem(pos); int ModelNo = found_paradigms[index]->second.m_FlexiaModelNo; string Caption = Format("Input comments to paradigm No:%i", ModelNo); InputBox(Caption.c_str(), GetWizard()->m_FlexiaModels[ModelNo].m_Comments); }
void ProfileBox::OnProfileNew() { QString name = InputBox(this, MainWindow::WINDOW_CAPTION, tr("Enter a name for the new profile:"), ""); if(name.isEmpty()) return; name = name.toAscii().toPercentEncoding(); QString filename = GetApplicationUserDir(m_type) + "/" + name + ".conf"; if(!QFileInfo(filename).exists() || MessageBox(QMessageBox::Warning, this, MainWindow::WINDOW_CAPTION, tr("A profile with the same name already exists. Are you sure that you want to replace it?"), BUTTON_YES | BUTTON_NO, BUTTON_YES) == BUTTON_YES) { { QSettings settings(filename, QSettings::IniFormat); m_save_callback(&settings, m_userdata); } LoadProfiles(); SetProfile(FindProfile(name)); UpdateProfileFields(); } }
void __fastcall TfrmMainFormServer::RenameDirectory1Click(TObject *Sender) { if(lstModules->ItemIndex < 1){ return; } AnsiString oldName = lstModules->Items->Strings[lstModules->ItemIndex]; AnsiString newName = InputBox("Rename Virtual Directory", "Enter an alias WITHOUT spaces", oldName); if(newName.Length() > 0){ adapter.RenameModule(oldName, newName); LoadModuleNames(); adapter.SaveConfig(); } }
void __fastcall TfrmMain::btnPMClick(TObject *Sender) { AnsiString Msg; TSimpleClient* Client; TIdPeerThread * threadptr; Msg = InputBox("Private Message", "What is the message", ""); Msg = Trim(Msg); Msg = edSyopName->Text + "> " + Msg; if ((Msg != "")&&(lbClients->ItemIndex != -1)) { Client =(TSimpleClient*) Clients->Items[lbClients->ItemIndex]; if (dynamic_cast<TSimpleClient*>(Client)) {threadptr=( TIdPeerThread*)Client->Thread; if (dynamic_cast<TIdPeerThread*>(threadptr)) threadptr->Connection->WriteLn(Msg); } } }
bool CFileDialog::CoreHandleKey(chtype key) { if (CDialog::CoreHandleKey(key)) return true; if (key == KEY_F(2)) { std::string newdir = InputBox(GetTranslation("Enter name of new directory"), "", 1024); if (newdir.empty()) return true; if (newdir[0] != '/') newdir = m_Directory + '/' + newdir; try { if (MKDirNeedsRoot(newdir)) { LIBSU::CLibSU suhandler; std::string passwd = AskPassword(suhandler); MKDirRecRoot(newdir, suhandler, passwd.c_str()); passwd.assign(passwd.length(), 0); } else MKDirRec(newdir); OpenDir(newdir); } catch(Exceptions::CExIO &e) { WarningBox(e.what()); } return true; } return false; }
//--------------------------------------------------------------------------- void __fastcall TframTag::btnWriteDeviceClick(TObject *Sender) { AnsiString value; pmc_value_t strVal, val; value = InputBox( "输入要写的数值", (char*)CTagName(m_TagName.sname.tag), "" ); if(value.Length() == 0){ return; } set_value_type(strVal.Flags, dt_string); strVal.Value.str = value.c_str(); val.Flags = m_Tag.s.Flags; pmc_type_cast(&strVal, &val); if(proxy_write_tags(1, &m_TagName, &val.Value) ){ m_Hint = "写入成功"; }else{ m_Hint = "写入失败"; } }
void __fastcall Tfrmgestionproductos::btnaumentarClick(TObject *Sender) { frmgestionproductos->locateTableByField(frmdatosproducto->Table1, "ID", DBEdit1->Text); AnsiString amountStr = InputBox("Actualizar cajas","CODIGO: "+frmdatosproducto->EditCODIGO->Text+"\nDESCRIPCION: "+frmdatosproducto->EditDESCRIPCION->Text+"\n\nCantidad de Cajas:",""); int amount = 0; try { amount = amountStr.ToInt(); } catch (EConvertError &e) { Application->MessageBox(("'" + amountStr + "' No es un valor de numero entero valido").c_str(), "Error",MB_OK | MB_ICONERROR); return; } try { if (amount > 0) { frmgestionproductos->addAmountByID(amount, DBEdit1->Text); Application->MessageBox("Cantidad actualizada correctamente","OK",MB_OK | MB_ICONINFORMATION); actualizar_consulta(); } else { Application->MessageBox("Cantidad debe ser mayor a 0 (cero)","Error",MB_OK | MB_ICONERROR); } } catch(...) { Application->MessageBox("Cantidad no Valida, no se actualiza la cantidad","Error",MB_OK | MB_ICONERROR); } }
void __fastcall Tfrm_BelongFunction::st_functionDblClick(TObject *Sender) { int row,col;double tem,temp1;AnsiString tem1; row = st_function->Row; col = st_function->Col; if(row==1) { switch(col) { case 0: { tem1=InputBox("Set up function","Input funtion expression please",st_function->Cells[0][row]); //if(IsValidExpress(tem1)) { st_function->Cells[0][row]=tem1; } break; } } AnsiString str = "["+st_function->Cells[1][row]+","+st_function->Cells[2][row]+"]"; m_strExpress=st_function->Cells[0][row]; m_strFunc=m_strExpress+str; } }
void __fastcall TfrmMain::btnKillClientClick(TObject *Sender) { AnsiString Msg; TSimpleClient* Client; TIdPeerThread* peerthread; Msg = InputBox("Disconnect message", "Enter a reason for the disconnect", ""); Msg = Trim(Msg); Msg = edSyopName->Text + "> " + Msg; if ((Msg != "")&&(lbClients->ItemIndex != -1)) { Client = (TSimpleClient*)Clients->Items[lbClients->ItemIndex]; peerthread=(TIdPeerThread*)Client->Thread; peerthread->Connection->WriteLn(Msg); try { peerthread->Connection->Disconnect(); } catch (...) { } } }
/*COM1 0x3F8 COM2 0x2F8 COM3 0X3E8 COM4 0X2E8*/ #define BufferSize 1000 void init_port();/*PORT SETTING*/ void main() { int gd=VGA,gm=VGAHI;/*InIt Graphics Driver*/ long int HRead,BRead;/*file stream handler and number of bytes read*/ char RBuffer[BufferSize];/*read buffer*/ unsigned long int FileSize=0;/*file size*/ unsigned long int NoOfByD=0;/*number of byte done*/ unsigned long int NumBuff1000;/*number of buffers.*/ int GotFromPort;/*to store data received from port*/ unsigned long int CurPos=0;/*pointer position in file*/ unsigned int i,g; char FileName[30];/*FILE NAME*/ char FileSizeC[30];/*file size in char form*/ char NoOfBuffC[30];/* no of buffer in char form*/ char x[1];/*to convert int to num from CP.*/ int KeyInput=0,sta=1; initgraph(&gd,&gm,"\\tc\\bgi");/*init graphics*/ cleardevice(); init_port();/*Initilize the COM port for communication*/ MainWindow("COM PORT COMMUNICATION UTILITY"); Boxes(30,60,360,180,0,"SELECT"); Show(); setcolor(14); outtextxy(Left+60,Top+30,"COM PORT Communication Utility."); outtextxy(450,430,"Sameer Rajendra Dubey"); outtextxy(450,450,"T.Y.B.Sc ELECTRONICS"); outtextxy(450,440,"ROLL NUMBER : 317"); Menu(1); for(;;) { KeyInput=getch(); if(KeyInput == 27) { exit(0); } else if(KeyInput == 80)/*Down arrow key*/ { switch(sta) { case 1: { Menu(2); sta=2; break; } case 2: { Menu(3); sta=3; break; } case 3: { Menu(4); sta=4; break; } case 4: { Menu(1); sta=1; break; } } } else if(KeyInput==72)/*Uparrow key*/ { switch(sta) { case 1: { Menu(4); sta=4; break; } case 2: { Menu(1); sta=1; break; } case 3: { Menu(2); sta=2; break; } case 4: { Menu(3); sta=3; break; } } } else if(KeyInput == 13)/*enter key*/ { if(sta==4) { cleardevice(); closegraph(); exit(0); } else { break; } } } if(sta==1)/*recieve file*/ { int c,ch; gotoxy(14,10); InputBox("Recieve File"); scanf("%s",&FileName); HRead=sopen(FileName,O_RDWR|O_BINARY|O_CREAT,SH_DENYNO,S_IREAD|S_IWRITE);/*OPEN FILE*/ outtextxy(Left+10,Top+120,"This terminal is ready to recieve a file."); setcolor(14); outtextxy(Left+10,Top+140,"when done press Esc to Exit"); c=inport(PORT1+5);/*CHECK IF RECIEVE DATA*/ if(c&1) { ch=inport(PORT1); } outportb(PORT1,100);/*SEND CHARACTER 'd' TO REMOTE TERMINAL.*/ for(;;) /*start copy*/ { c=inportb(PORT1+5); if(c&1) { ch=inport(PORT1); x[0]=ch; BRead=write(HRead,x,1); outportb(PORT1,100); } if(kbhit()) { char T=getch(); if(T == 27) { close(HRead); cleardevice(); closegraph(); exit(0); } } } } else if(sta == 2) { char choice; Top=260; Left=80; for(;;)/*Do until we get a valid file name */ { gotoxy(14,10); MainWindow("COM PORT UTILITY"); InputBox("Send File."); scanf("%s",&FileName); HRead=open(FileName,O_RDONLY|O_BINARY); FileSize=filelength(HRead); if(HRead>0)/*valid file*/ { int c=0; if(FileSize>BufferSize)/*calculate the number of buffers.*/ { NumBuff1000=(FileSize/BufferSize); } else { NumBuff1000=1; } if(NumBuff1000*BufferSize<FileSize) { ++NumBuff1000; } min=0;/*assign min max values to status bar*/ max=NumBuff1000; Boxes(30,60,300,180,0,"Send File"); Show(); setcolor(15); outtextxy(Left+10,Top+30,"File Name:"); outtextxy(Left+10,Top+40,"File Size:"); outtextxy(Left+10,Top+50,"Number Of Buffer:"); setcolor(14); outtextxy(Left+150,Top+30,FileName); ltoa(FileSize,FileSizeC,10); ltoa(NumBuff1000,NoOfBuffC,10); outtextxy(Left+150,Top+50,NoOfBuffC); outtextxy(Left+150,Top+40,FileSizeC); outtextxy(Left+10,Top+80,"after making other terminal"); outtextxy(Left+10,Top+90,"Ready press any key to start."); setcolor(15); ShowBar(Left+170,200,10,150); Refresh(0); KeyInput=getch(); if(KeyInput == 27) { cleardevice(); closegraph(); exit(0); } for(i=1;i<=NumBuff1000;i++)/*all buffers send one by one */ { CurPos=tell(HRead);/*get current pos of pointer*/ BRead=read(HRead,RBuffer,BufferSize); CurPos+=BufferSize; lseek(HRead,CurPos,SEEK_SET);/*update ptr*/ CurPos=tell(HRead); g=0; ShowBar(Left+170,200,10,150); Refresh(i); do { c=inportb(PORT1+5);/*CHECK THE DATA*/ if(c&1) { GotFromPort=inport(PORT1);/*get data*/ if(GotFromPort==100)/*if we get d*/ { outportb(PORT1,RBuffer[g]);/*send char to serial port*/ NoOfByD++; g++; } } }while(g<BRead); } /*end for*/ break; }/*end if (valid file)*/ else { Boxes(80,260,450,120,4," Error !!!"); Show(); setcolor(15); outtextxy(Left+10,Top+30,"incorrect file name or file does not exist."); outtextxy(Left+10,Top+40,"press any key to reenter file name or Esc to Cancel"); outtextxy(Left+10,Top+90,"Esc-Exit"); choice=getch(); if(choice==27) { break; } } }/*end for(;;)*/ }/*end of menu if*/ else if(sta==3) { int c,ch; char UserName1[30],UserName2[30]=""; int GotName=0,GaveName=0;/*flags*/ int INBuffer[100],OUTBuffer[100];/*output BUFFERS*/ int INPtr=0,OUTPtr=0; int v=0,flag=0,sl; char s; int i; closegraph(); clrscr(); printf("%c",201); for(i=1;i<=78;i++) { printf("%c",205); } printf("%c%c",187,186); gotoxy(29,2); printf("COM PORT CHAT UTILITY"); gotoxy(80,2); printf("%c%c",186,200); for(i=1;i<=78;i++) { printf("%c",(205)); } printf("%c",(188)); i=0; printf("\nenter your name :"); scanf("%s",&UserName1); sl=strlen(UserName1); do { if(GotName && GaveName) { if(!flag) { printf("\n%s:",UserName1); flag=1; } c=inportb(PORT1+5);/*check to see if char has been recieved.*/ if(c & 1) { ch=inportb(PORT1);/*IF SO ,then get char*/ if(ch==13) { printf("\n%s:",UserName2); for(i=0;i<INPtr-1;i++) { printf("%c",(INBuffer[i])); } INPtr=0; printf("\n%s:",UserName1); }/*end of our data,as we got the name.*/ else { INBuffer[INPtr]=ch; INPtr++; } }/*&c*/ }/*G&G*/ if(kbhit()) { ch=getch();/*if key pressed,get char*/ if((ch == 13) && GaveName && GotName) { for(i=0;i<=OUTPtr;i++) { outportb(PORT1,OUTBuffer[i]); delay(1); } outportb(PORT1,13); printf("\n%s:",UserName1); OUTPtr=0; } else if(GaveName && GotName) { OUTBuffer[OUTPtr]=ch; OUTPtr++; printf("%c",ch); } } if(!GotName)/*we want the name of the user on other computer*/ { c=inportb(PORT1+5);/*check to see if char has been recieved.*/ if(c&1) { ch=inportb(PORT1);/*IF SO THE GET CHAR*/ if(ch==13) { i=0; printf("\n user on remote computer:%s",UserName2); printf("\n press Esc to Exit"); GotName=1; }/*end of our data, as we got the name*/ else { s=ch; UserName2[i]=s;/*store name*/ i++; } } }/*end of got name*/ if(!GaveName) { outportb(PORT1,UserName1[v]);/*send name char by char*/ v++; if(v == sl) { outportb(PORT1,13); GaveName=1; } } }while(ch!=27);/*Quit when Esc(ASC27) is pressed*/ } closegraph();/*end of chat part*/ }
void aux_HOOK(CAstSig &ast, const AstNode *pnode, const AstNode *p) { string HookName; const AstNode *args; if (pnode->str[0] == '#') { HookName = pnode->str+1; args = p; } else { const char *fnsigs[] = { "(name_string, ...)", 0}; HookName = ast.ComputeString(p); checkNumArgs(pnode, p, fnsigs, 1, 0); args = p->next; } CSignals first; char buf[512]; if (ast.CallbackHook && ast.CallbackHook(ast, pnode, p)==0) ; else if (HookName == "PLAY") { const char *fnsigs[] = { "(signal [, async_flag])", "(\"stop\", handle_scalar)", 0}; checkNumArgs(pnode, args, fnsigs, 1, 2); first = ast.Compute(args); unsigned long second = 0; if (args->next) { ast.Compute(args->next); if (!ast.Sig.IsScalar()) throw CAstException(pnode, args->next, fnsigs, "argument must be a scalar."); second = (unsigned long)(ast.Sig.value()+(ast.Sig.value()<0?-.5:.5)); } int flag = 0; if (first.IsString()) { string cmd = first.string(); std::transform(cmd.begin(), cmd.end(), cmd.begin(), ::tolower); void *pvoid = (void *)second; if (cmd == "stop") TerminatePlay(pvoid); else if (cmd == "pause") PauseResumePlay(pvoid, 0); else if (cmd == "resume") PauseResumePlay(pvoid, 1); else throw CAstException(args, "Unknown command in the string -", cmd); return; } char *errstr = buf; // second == 0:Synchronous, 1:Asynchronous, 2:Loop void *res = first.PlayArray(0, (second==0)?0:WM_USER+293, NULL, (second==2)?-1:0, errstr); if (!res) throw CAstException(pnode, "PlayArray() failed:", errstr); ast.Sig.SetValue((double)(unsigned long)res); } else if (HookName == "INPUT") { const char *fnsigs[] = { "(message_string [, title_string])", 0}; checkNumArgs(pnode, args, fnsigs, 1, 2); string msg, title; msg = ast.ComputeString(args); if (args->next) title = ast.ComputeString(args->next); else { ostringstream caption; caption << "Line " << pnode->line; title = caption.str(); } buf[0] = '\0'; InputBox(title.c_str(), msg.c_str(), buf, sizeof(buf)); ast.Sig.UpdateBuffer((int)strlen(buf)); for (int i=0; buf[i]; ++i) ast.Sig.buf[i] = buf[i]; } else if (HookName == "PIPE") { const char *fnsigs[] = { "(message_string [, node_name_string [, pipe_name_string]])", 0}; checkNumArgs(pnode, args, fnsigs, 1, 3); #define SIGNAL_INTERFACE_PIPENAME "CochlearAudioSignalInterfacePipe" string pipemsg = ast.ComputeString(args); string nodename = "."; string pipename = SIGNAL_INTERFACE_PIPENAME; if (args->next) { nodename = ast.ComputeString(args->next); if (args->next->next) pipename = ast.ComputeString(args->next->next); } pipename = "\\\\" + nodename + "\\pipe\\" + pipename; char reply[50000] = ""; unsigned long nRead; if (!CallNamedPipe(pipename.c_str(), (LPVOID)pipemsg.c_str(), (DWORD)pipemsg.size()+1, reply, (DWORD)sizeof(reply), &nRead, NMPWAIT_WAIT_FOREVER)) { char *errstr = buf; GetLastErrorStr(errstr); throw CAstException(pnode, "CallNamedPipe(" + pipename + ") failed:", errstr); } reply[nRead]='\0'; ast.Sig.UpdateBuffer((int)nRead); for (int i=0; reply[i]; ++i) ast.Sig.buf[i] = reply[i]; } else if (HookName == "ELAPSE") { const char *fnsigs[] = { "( )", 0}; checkNumArgs(pnode, args, fnsigs, 0, 0); ast.Sig.SetValue(GetTickCount() - ast.Tick0); } else if (HookName == "SLEEP") { const char *fnsigs[] = { "(millisecond)", 0}; checkNumArgs(pnode, args, fnsigs, 1, 1); ast.Compute(args); if (!ast.Sig.IsScalar()) throw CAstException(pnode, args, fnsigs, "argument must be a scalar."); int n = round(ast.Sig.value()); Sleep(n); } else throw CAstException(pnode, "Undefined HOOK name:", HookName); };
//--------------------------------------------------------------------------- void __fastcall TNakladnaForm::ButtonInsertClick(TObject &Sender) { if(!Document->Partner->ID_Partner) { ShowMessage("введите покупателя"); return; } TTovarListForm * tlf = new TTovarListForm(this); tlf->ShowModal(); if(!tlf->SelectedItem) return; TTovar * t = new TTovar(tlf->SelectedItem->ID_Tovar, Document->Partner->ID_Partner); if(!t->CinaProdazh) { delete t; t = tlf->SelectedItem; } TRashod * r; Refresh(); if(FrameList1->Query->Locate("id_tovar", t->ID_Tovar, TLocateOptions()<<loCaseInsensitive<<loPartialKey )) r = new TRashod(FrameList1->Query->FieldByName("id_rashod")->AsInteger); else r = new TRashod(0); r->ID_Tovar = t->ID_Tovar; r->ID_Partner = Document->Partner->ID_Partner; r->Nomer = Document->Nomer; r->DataDok = Document->DataDok; float procent = cxSpinEditProcent->Value; // if(procent > 0) r->Cina = t->CinaProdazh-(t->CinaProdazh*(procent/(100+procent))); // else // r->Cina = t->CinaProdazh; float Kilxkist = 0; try { Kilxkist = StrToFloat(InputBox("введите количество:","Количество:", "1")); } catch ( ... ) { ShowMessage("введено неправильное количество!"); } if(Kilxkist <= 0) { ShowMessage("количество не может быть нулевым или минусовым"); delete r; delete t; return; } r->Kilxkist += Kilxkist; if(t->Ostatok < Kilxkist) ShowMessage("столько количества товара нету на складе"); else r->Save(); delete r; delete t; delete tlf; Refresh(); FrameList1->Query->Last(); }