void __fastcall TMainForm::SGnewSetEditText(TObject *Sender, int ACol, int ARow, const AnsiString Value){ if (ACol == 3 && Value.Length()>=1){WriteToMemory(ARow-1, Value);} }
// редактирование информации о КХР bool TController::editKHR() { // происходит проверка на заполненность полей if(Trim(formKHR->edtOrderNum->Text) == "" || Trim(formKHR->edtKHRNum->Text) == "" || Trim(formKHR->edtName->Text) == "" || Trim(formKHR->edtShort->Text) == "") { // какие-то данные не заполнены //ShowMessage("Не все данные заполнены!"); return false; } string nfile; selectedKHR->szOrder = STR(formKHR->edtOrderNum->Text); selectedKHR->szNumber = STR(formKHR->edtKHRNum->Text); selectedKHR->szTitle = STR(formKHR->edtName->Text); selectedKHR->dtStartDate = formKHR->dtStartDate->Date; selectedKHR->szFileName = STR(formKHR->edtShort->Text); selectedKHR->selected = true; for (unsigned int i=0; i < selectedKHR->Executors.size(); i++) delete selectedKHR->Executors[i]; selectedKHR->Executors.clear(); for (unsigned int i=0; i < selectedKHR->Signatures.size(); i++) delete selectedKHR->Signatures[i]; selectedKHR->Signatures.clear(); int execid = 1; for(int i=0; i < formKHR->sgExecutors->RowCount; i++) { if (Trim(formKHR->sgExecutors->Cells[0][i])!="") { TExecutor *exec = new TExecutor; exec->id = execid++; AnsiString tt = formKHR->sgExecutors->Cells[0][i]; // exec->szName = formKHR->sgExecutors->Cells[0][i].c_str(); exec->szName = tt.c_str(); selectedKHR->Executors.push_back(exec); } } for(int i=0; i < formKHR->sgSigns->RowCount; i++) { if (Trim(formKHR->sgSigns->Cells[0][i])!=""&&Trim(formKHR->sgSigns->Cells[1][i])!="") { TSignature *sig = new TSignature; sig->szChair = STR(formKHR->sgSigns->Cells[0][i]); sig->szName = STR(formKHR->sgSigns->Cells[1][i]); selectedKHR->Signatures.push_back(sig); } } formKHR->edtOrderNum -> Text = ""; formKHR->edtKHRNum -> Text = ""; formKHR->edtName -> Text = ""; for(int i=0; i < formKHR->sgSigns->RowCount; i++) { formKHR->sgSigns->Cells[0][i]=""; formKHR->sgSigns->Cells[1][i]=""; } for(int i=0; i < formKHR->sgExecutors->RowCount; i++) formKHR->sgExecutors->Cells[0][i]=""; clearSelected(); formKHR->Close(); showAll(); return true; }
/*#$% ============================================================== 通信回線をオープンしスレッドをアクティブにする -------------------------------------------------------------- PortName : 回線の名前 pCP : COMMPARAのポインタ(ヌルの時はデフォルトで初期化) pWnd : メッセージ送信先のウインドウクラスのポインタ(ヌルの時はメインフレームウインドウ) nID : データ受信時のメッセージID RBufSize : 受信バッファのサイズ(default=2048) TBufSize : 送信バッファのサイズ(default=2048) -------------------------------------------------------------- TRUE/FALSE -------------------------------------------------------------- ============================================================== */ BOOL __fastcall CCradio::Open(CRADIOPARA *cp, HWND hwnd, UINT uMsg, UINT nID) { if( m_CreateON == TRUE ) Close(); m_RigHz = m_FreqHz = 0; m_TxAbort = FALSE; m_PSKGNRId = 0; m_OpenGNR = 0; if( !strcmpi(cp->StrPort, "PSKGNR") || !strcmpi(cp->StrPort, "WD5GNR") || !strcmpi(cp->StrPort, "LOGGER")){ m_PSKGNRId = ::RegisterWindowMessage("PSKGNRFUNC"); m_CreateON = TRUE; if( RADIO.openGNR && (!RADIO.cmdGNR.IsEmpty()) && (strcmpi(cp->StrPort, "LOGGER")) ){ if( FindWindow("ThunderRT6Main", NULL) == NULL ){ ::WinExec(RADIO.cmdGNR.c_str(), SW_HIDE); m_OpenGNR = 1; } } return m_CreateON; } m_fHnd = ::CreateFile(cp->StrPort, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); if( m_fHnd == INVALID_HANDLE_VALUE ){ AnsiString as = "\\\\.\\"; as += cp->StrPort; m_fHnd = ::CreateFile(as.c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); } m_wHnd = hwnd; m_uMsg = uMsg; m_ID = nID; if( m_fHnd == INVALID_HANDLE_VALUE ) goto _mmr; // setup device buffers if( ::SetupComm( m_fHnd, DWORD(RADIO_COMBUFSIZE), DWORD(RADIO_COMBUFSIZE) ) == FALSE ){ ::CloseHandle(m_fHnd); _mmr:; m_pRadio = new CMMRadio(hwnd, uMsg); if( m_pRadio->Open(cp->StrPort) ){ m_CreateON = TRUE; Priority = tpLower; Resume(); // スレッドの実行 return TRUE; } else { delete m_pRadio; m_pRadio = NULL; return FALSE; } } // purge any information in the buffer ::PurgeComm( m_fHnd, PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_RXCLEAR ); // set up for overlapped I/O COMMTIMEOUTS TimeOut; TimeOut.ReadIntervalTimeout = 0xffffffff; TimeOut.ReadTotalTimeoutMultiplier = 0; TimeOut.ReadTotalTimeoutConstant = 0; TimeOut.WriteTotalTimeoutMultiplier = 0; TimeOut.WriteTotalTimeoutConstant = 20000; // TimeOut.WriteTotalTimeoutConstant = 1; if( !::SetCommTimeouts( m_fHnd, &TimeOut ) ){ ::CloseHandle( m_fHnd ); return FALSE; } ::GetCommState( m_fHnd, &m_dcb ); m_dcb.BaudRate = cp->BaudRate; m_dcb.fBinary = TRUE; m_dcb.ByteSize = USHORT(cp->BitLen ? 8 : 7); const UCHAR _tp[]={NOPARITY, EVENPARITY, ODDPARITY}; m_dcb.Parity = _tp[cp->Parity]; const UCHAR _ts[]={ONESTOPBIT,TWOSTOPBITS}; m_dcb.StopBits = _ts[cp->Stop]; if( cp->usePTT ){ m_dcb.fRtsControl = RTS_CONTROL_DISABLE; // 送信禁止 m_dcb.fDtrControl = DTR_CONTROL_DISABLE; // 送信禁止 } else { m_dcb.fRtsControl = RTS_CONTROL_ENABLE; } m_dcb.fOutxCtsFlow = (cp->flwCTS && !cp->usePTT) ? TRUE : FALSE; m_dcb.fInX = m_dcb.fOutX = cp->flwXON ? TRUE : FALSE; m_dcb.XonChar = 0x11; m_dcb.XoffChar = 0x13; m_dcb.fParity = FALSE; m_dcb.EvtChar = 0x0d; // dummy setting // m_dcb.fTXContinueOnXoff = TRUE; m_dcb.XonLim = USHORT(RADIO_COMBUFSIZE/4); // 1/4 of RBufSize m_dcb.XoffLim = USHORT(RADIO_COMBUFSIZE*3/4); // 3/4 of RBufSize m_dcb.DCBlength = sizeof( DCB ); if( !::SetCommState( m_fHnd, &m_dcb ) ){ ::CloseHandle( m_fHnd ); return FALSE; } // get any early notifications if( !::SetCommMask( m_fHnd, EV_RXFLAG ) ){ ::CloseHandle(m_fHnd); return FALSE; } m_CreateON = TRUE; Priority = tpLower; Resume(); // スレッドの実行 return TRUE; }
//--------------------------------------------------------------------------- void __fastcall TParallelPort::OKClick(TObject *Sender) { if (OutFile) { fclose(OutFile); OutFile=NULL; } if (ComPort->Connected) ComPort->Close(); switch(ComPortList->ItemIndex) { case 0: Port=PORTNOTHING; break; case 1: Port=PORTFILE; OutFile=fopen((OutputFileEdit->Text).c_str(), "wb"); break; case 2: Port=PORTTCPIP; ClientSocket->Host = TCPAddress->Text; ClientSocket->Port = atoi((TCPPort->Text).c_str()); if ((ClientSocket->Host != "") && (ClientSocket->Port!=0)) ClientSocket->Open(); break; default: AnsiString Port=ComPortList->Items->Strings[ComPortList->ItemIndex]; if (Port.SubString(1,3)=="LPT") { Port=PORTFILE; OutFile=fopen(Port.c_str(), "wb"); } else { Port=PORTRS232; ComPort->Port=Port; switch(DataBits->ItemIndex) { case 0: ComPort->DataBits = dbFive; break; case 1: ComPort->DataBits = dbSix; break; case 2: ComPort->DataBits = dbSeven; break; case 3: ComPort->DataBits = dbEight; break; default: ComPort->DataBits = dbEight; break; } switch(StopBits->ItemIndex) { case 0: ComPort->StopBits = sbOneStopBit; break; case 1: ComPort->StopBits = sbOne5StopBits; break; case 2: ComPort->StopBits = sbTwoStopBits; break; default: ComPort->StopBits = sbOneStopBit; break; } switch(Parity->ItemIndex) { case 0: ComPort->Parity->Bits = prNone; ComPort->Parity->Check=false; break; case 1: ComPort->Parity->Bits = prOdd; ComPort->Parity->Check=true; break; case 2: ComPort->Parity->Bits = prEven; ComPort->Parity->Check=true; break; case 3: ComPort->Parity->Bits = prMark; ComPort->Parity->Check=true; break; case 4: ComPort->Parity->Bits = prSpace; ComPort->Parity->Check=true; break; } ComPort->BaudRate=brCustom; if (BaudRate->ItemIndex==0) ComPort->CustomBaudRate=atoi((BaudRate->Items->Strings[BaudRate->ItemIndex]).c_str()); try { ComPort->Open(); } catch(EComPort &E) { AnsiString Msg = "Could not open port "; Msg += ComPortList->Items->Strings[ComPortList->ItemIndex]; if (Sender) Application->MessageBox(Msg.c_str(),"Error", MB_OK | MB_ICONERROR); } } break; } if (ComPort->Connected) ComPort->ClearBuffer(true,true); Close(); }
void TConfDlg::SaveConfig(const AnsiString &File) { HANDLE file; DWORD type,Written; int i; CHostRef *host; AnsiString FailedName="NONE"; file = CreateFileA(File.c_str(),GENERIC_WRITE,0,0,CREATE_ALWAYS, FILE_FLAG_SEQUENTIAL_SCAN,0); if(file == INVALID_HANDLE_VALUE) { Application->MessageBox("Cannot create file!","Error",MB_OK|MB_ICONERROR); return; } // Remove the configuration from hosts // That do not have an individual configuration for(i =0;i<LastList->Count;++i) { host = (CHostRef*)(LastList->Objects[i]); if(host) host->RemoveConfigRefs(); } FailedName="MAGIC"; type = MAGIC; if(!WriteFile(file,&type,sizeof(DWORD),&Written,0)) goto Remove; FailedName="FILE_VERSION"; type = FILE_VERSION; if(!WriteFile(file,&type,sizeof(DWORD),&Written,0)) goto Remove; FailedName="Plugin"; if(!WritePlugin(file,PluginManager.GetActualPlugin())) goto Remove; FailedName = "WriteConfigData"; if(!WriteConfigData(file,&GlobalConfig)) goto Remove; FailedName="WriteHost"; for(i=0;i<LastList->Count;++i) { if(!WriteHost(file,(HostData*)*(CHostRef*)LastList->Objects[i])) goto Remove; } //SI: 13.06.05 Write Account at last position //SI: 14.06.05 save without Write Account possible FailedName="WriteAccount"; //if(!WriteAccount(file,&GlobalConfig)) goto Remove; if(!WriteAccount(file,&GlobalConfig)) Application->MessageBox("Could not save account information in config!","Error",MB_ICONERROR|MB_OK);; type = TYPE_NONE; WriteFile(file,&type,sizeof(DWORD),&Written,0); CloseHandle(file); for(i=0;i<LastList->Count;++i) { host=(CHostRef*)LastList->Objects[i]; // If the host has no individual configuration then // set a reference to the global config. host->SetConfigRef(&GlobalConfig); } return; Remove: CloseHandle(file); DeleteFileA(File.c_str()); FailedName = FailedName + " failed. Could not save config!"; Application->MessageBox(FailedName.c_str(),"Error",MB_ICONERROR|MB_OK); return; }
//--------------------------------------------------------------------------- void __fastcall TOptDialog::SaveOpt(AnsiString file) { AnsiString ProxyAddrE_Text=ProxyAddrE->Text; AnsiString ExSatsE_Text=ExSatsE->Text; AnsiString FieldSep_Text=FieldSep->Text; AnsiString RovAnt_Text=RovAnt->Text,RefAnt_Text=RefAnt->Text; AnsiString SatPcvFile_Text=SatPcvFile->Text; AnsiString AntPcvFile_Text=AntPcvFile->Text; AnsiString StaPosFile_Text=StaPosFile->Text; AnsiString GeoidDataFile_Text=GeoidDataFile->Text; AnsiString DCBFile_Text=DCBFile->Text; AnsiString LocalDir_Text=LocalDir->Text; int itype[]={STR_SERIAL,STR_TCPCLI,STR_TCPSVR,STR_NTRIPCLI,STR_FILE,STR_FTP,STR_HTTP}; int otype[]={STR_SERIAL,STR_TCPCLI,STR_TCPSVR,STR_NTRIPSVR,STR_FILE}; TEdit *editu[]={RovPos1,RovPos2,RovPos3}; TEdit *editr[]={RefPos1,RefPos2,RefPos3}; char buff[1024],*p,id[32],comment[256],s[64]; int sat,ex; prcopt_t prcopt=prcopt_default; solopt_t solopt=solopt_default; filopt_t filopt={""}; for (int i=0;i<8;i++) { strtype[i]=i<3?itype[MainForm->Stream[i]]:otype[MainForm->Stream[i]]; strfmt[i]=MainForm->Format[i]; if (!MainForm->StreamC[i]) { strtype[i]=STR_NONE; strcpy(strpath[i],""); } else if (strtype[i]==STR_SERIAL) { strcpy(strpath[i],MainForm->Paths[i][0].c_str()); } else if (strtype[i]==STR_FILE) { strcpy(strpath[i],MainForm->Paths[i][2].c_str()); } else if (strtype[i]<=STR_NTRIPCLI) { strcpy(strpath[i],MainForm->Paths[i][1].c_str()); } else if (strtype[i]<=STR_HTTP) { strcpy(strpath[i],MainForm->Paths[i][3].c_str()); } } nmeareq =MainForm->NmeaReq; nmeapos[0]=MainForm->NmeaPos[0]; nmeapos[1]=MainForm->NmeaPos[1]; svrcycle =SvrCycleE ->Text.ToInt(); timeout =TimeoutTimeE->Text.ToInt(); reconnect =ReconTimeE ->Text.ToInt(); nmeacycle =NmeaCycleE ->Text.ToInt(); buffsize =SvrBuffSizeE->Text.ToInt(); navmsgsel =NavSelectS ->ItemIndex; strcpy(proxyaddr,ProxyAddrE_Text.c_str()); fswapmargin =FileSwapMarginE->Text.ToInt(); prcopt.sbassatsel=SbasSatE->Text.ToInt(); prcopt.mode =PosMode ->ItemIndex; prcopt.nf =Freq ->ItemIndex+1; prcopt.soltype =Solution ->ItemIndex; prcopt.elmin =str2dbl(ElMask ->Text)*D2R; prcopt.dynamics =DynamicModel->ItemIndex; prcopt.tidecorr =TideCorr ->ItemIndex; prcopt.ionoopt =IonoOpt ->ItemIndex; prcopt.tropopt =TropOpt ->ItemIndex; prcopt.sateph =SatEphem ->ItemIndex; if (ExSatsE->Text!="") { strcpy(buff,ExSatsE_Text.c_str()); for (p=strtok(buff," ");p;p=strtok(NULL," ")) { if (*p=='+') {ex=2; p++;} else ex=1; if (!(sat=satid2no(p))) continue; prcopt.exsats[sat-1]=ex; } } prcopt.navsys = (NavSys1->Checked?SYS_GPS:0)| (NavSys2->Checked?SYS_GLO:0)| (NavSys3->Checked?SYS_GAL:0)| (NavSys4->Checked?SYS_QZS:0)| (NavSys5->Checked?SYS_SBS:0)| (NavSys6->Checked?SYS_CMP:0); prcopt.posopt[0]=PosOpt1->Checked; prcopt.posopt[1]=PosOpt2->Checked; prcopt.posopt[2]=PosOpt3->Checked; prcopt.posopt[3]=PosOpt4->Checked; prcopt.posopt[4]=PosOpt5->Checked; prcopt.modear =AmbRes ->ItemIndex; prcopt.glomodear=GloAmbRes ->ItemIndex; prcopt.thresar[0]=str2dbl(ValidThresAR->Text); prcopt.maxout =str2dbl(OutCntResetAmb->Text); prcopt.minfix =str2dbl(FixCntHoldAmb->Text); prcopt.minlock =str2dbl(LockCntFixAmb->Text); prcopt.elmaskar =str2dbl(ElMaskAR ->Text)*D2R; prcopt.elmaskhold=str2dbl(ElMaskHold->Text)*D2R; prcopt.maxtdiff =str2dbl(MaxAgeDiff ->Text); prcopt.maxgdop =str2dbl(RejectGdop ->Text); prcopt.maxinno =str2dbl(RejectThres->Text); prcopt.thresslip=str2dbl(SlipThres ->Text); prcopt.niter =str2dbl(NumIter ->Text); prcopt.syncsol =SyncSol->ItemIndex; if (prcopt.mode==PMODE_MOVEB&&BaselineConst->Checked) { prcopt.baseline[0]=str2dbl(BaselineLen->Text); prcopt.baseline[1]=str2dbl(BaselineSig->Text); } solopt.posf =SolFormat ->ItemIndex; solopt.timef =TimeFormat ->ItemIndex==0?0:1; solopt.times =TimeFormat ->ItemIndex==0?0:TimeFormat->ItemIndex-1; solopt.timeu =str2dbl(TimeDecimal ->Text); solopt.degf =LatLonFormat->ItemIndex; strcpy(solopt.sep,FieldSep_Text.c_str()); solopt.outhead =OutputHead ->ItemIndex; solopt.outopt =OutputOpt ->ItemIndex; solopt.datum =OutputDatum ->ItemIndex; solopt.height =OutputHeight->ItemIndex; solopt.geoid =OutputGeoid ->ItemIndex; solopt.nmeaintv[0]=str2dbl(NmeaIntv1->Text); solopt.nmeaintv[1]=str2dbl(NmeaIntv2->Text); solopt.trace =DebugTrace ->ItemIndex; solopt.sstat =DebugStatus ->ItemIndex; prcopt.eratio[0]=str2dbl(MeasErrR1->Text); prcopt.eratio[1]=str2dbl(MeasErrR2->Text); prcopt.err[1] =str2dbl(MeasErr2->Text); prcopt.err[2] =str2dbl(MeasErr3->Text); prcopt.err[3] =str2dbl(MeasErr4->Text); prcopt.err[4] =str2dbl(MeasErr5->Text); prcopt.sclkstab =str2dbl(SatClkStab->Text); prcopt.prn[0] =str2dbl(PrNoise1->Text); prcopt.prn[1] =str2dbl(PrNoise2->Text); prcopt.prn[2] =str2dbl(PrNoise3->Text); prcopt.prn[3] =str2dbl(PrNoise4->Text); prcopt.prn[4] =str2dbl(PrNoise5->Text); if (RovAntPcv->Checked) strcpy(prcopt.anttype[0],RovAnt_Text.c_str()); if (RefAntPcv->Checked) strcpy(prcopt.anttype[1],RefAnt_Text.c_str()); prcopt.antdel[0][0]=str2dbl(RovAntE->Text); prcopt.antdel[0][1]=str2dbl(RovAntN->Text); prcopt.antdel[0][2]=str2dbl(RovAntU->Text); prcopt.antdel[1][0]=str2dbl(RefAntE->Text); prcopt.antdel[1][1]=str2dbl(RefAntN->Text); prcopt.antdel[1][2]=str2dbl(RefAntU->Text); prcopt.rovpos=RovPosTypeP->ItemIndex<3?0:4; prcopt.refpos=RefPosTypeP->ItemIndex<3?0:4; if (prcopt.rovpos==0) GetPos(RovPosTypeP->ItemIndex,editu,prcopt.ru); if (prcopt.refpos==0) GetPos(RefPosTypeP->ItemIndex,editr,prcopt.rb); strcpy(filopt.satantp,SatPcvFile_Text.c_str()); strcpy(filopt.rcvantp,AntPcvFile_Text.c_str()); strcpy(filopt.stapos, StaPosFile_Text.c_str()); strcpy(filopt.geoid, GeoidDataFile_Text.c_str()); strcpy(filopt.dcb, DCBFile_Text.c_str()); strcpy(filopt.tempdir,LocalDir_Text.c_str()); time2str(utc2gpst(timeget()),s,0); sprintf(comment,"RTKNAVI options (%s, v.%s)",s,VER_RTKLIB); setsysopts(&prcopt,&solopt,&filopt); if (!saveopts(file.c_str(),"w",comment,sysopts)|| !saveopts(file.c_str(),"a","",rcvopts)) return; }
//--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebCreateItemClick(TObject *Sender) { AnsiString folder = STools->Current()->ViewGetCurrentItem(true); STools->Current()->AppendItem(folder.c_str()); }
void TfrmText::InsertLine(const AnsiString& line) { if (!line.IsEmpty()) mmText->Lines->Insert(mmText->CaretPos.y,line); }
//--------------------------------------------------------------------------- AnsiString __fastcall TfrmSearch::AnalyseScript() { AnsiString Script; AnsiString s; for(int n = 0;n < SkyEdit2->Lines->Count;n++) { s = SkyEdit2->Lines->Strings[n]; s = AnsiReplaceStr(AnsiReplaceStr(AnsiReplaceStr(AnsiReplaceStr(s,"\n"," "),"\r"," ")," "," "),"\t"," "); if(s.SubString(1,1) == "'" || s.SubString(1,4).LowerCase() == "rem "||s.SubString(1,4).LowerCase() == "rem\t") //注释行 continue; Script = Script + " " + SkyEdit2->Lines->Strings[n]; } Script = AnsiReplaceStr(AnsiReplaceStr(AnsiReplaceStr(Script,"\n"," "),"\r"," "),"\t"," "); AnsiString LowerCaseScript = Script.LowerCase(); AnsiString ParamString; TBillField * BillField; AnsiString LowerCaseFieldName; AnsiString ParamName; int Pos; for(int n = 0;n < BillFile->FieldCount;n++) { BillField = BillFile->GetBillField(n); LowerCaseFieldName = BillField->FieldName.LowerCase(); Pos = LowerCaseScript.Pos(LowerCaseFieldName); if(Pos < 1) continue; //ParamName = BillField->FieldName.LowerCase(); if(ParamString == "") //ParamString = ParamString + ParamName; ParamString = ParamString + BillField->FieldName; else //ParamString = ParamString + "," + ParamName; ParamString = ParamString + "," + BillField->FieldName; //将原字符串中的字段名替换为ParamName int k = 1; while(k <= LowerCaseScript.Length()) { if(LowerCaseScript.SubString(k,LowerCaseFieldName.Length()) == LowerCaseFieldName) { Script = StuffString(Script,k,LowerCaseFieldName.Length(),BillField->FieldName); LowerCaseScript = StuffString(LowerCaseScript,k,LowerCaseFieldName.Length(),LowerCaseFieldName); } ++k; } MatchFieldList->AddObject(BillField->FieldName,(TObject *)BillField); } ParamString = "(" + ParamString + ")"; Script = "'执行过程\nFunction MatchBill" + ParamString + "\n" + "if " + Script + " then \n"\ " MatchBill = 1\n"\ "else\n MatchBill = 0\n"\ "end if\n"\ "End Function"; SkyEdit1->Text = Script; //脚本语法检查 TScriptControl * ScriptControl = new TScriptControl(this); ScriptControl->Language = "VBScript"; ScriptControl->AllowUI = false; LPSAFEARRAY Params; //传递给脚本的参数 Params = SafeArrayCreateVector(VT_VARIANT, 0, MatchFieldList->Count); VARIANT * pData = NULL; SafeArrayAccessData(Params, (void **)&pData); //锁定数据 TList * ParamList = new TList; //参数列表 VARIANT * pDataTmp; for(int n = 0;n < MatchFieldList->Count;n++) { pDataTmp = new VARIANT; pDataTmp->vt = VT_BSTR; ParamList->Add((TObject *)pDataTmp); } ScriptControl->AddCode(WideString(Script).c_bstr()); bool ScriptSucceed; ScriptControl->Error->get_Number(); ScriptSucceed = ScriptControl->Error->Number == 0; if(!ScriptSucceed)//ScriptControl->Error->Number > 0) { MessageBox(Handle,("查询脚本错误:第 " + AnsiString(ScriptControl->Error->Line) \ + " 行,第 " + AnsiString(ScriptControl->Error->Column) \ + "列出现错误 " + AnsiString(ScriptControl->Error->Number) \ + " (" + AnsiString(ScriptControl->Error->Description) + ")").c_str(),"错误",MB_OK | MB_ICONSTOP); //ScriptSucceed = false; } else { //生成参数列表 for(int p = 0;p < MatchFieldList->Count;p++) { pDataTmp = (VARIANT *)ParamList->Items[p]; switch(((TBillField *)MatchFieldList->Objects[p])->SortType) { case SORT_AS_STR: pDataTmp->bstrVal = SysAllocString(L"000"); break; case SORT_AS_DATETIME: pDataTmp->bstrVal = SysAllocString(L"2000-01-01 00:00:00"); break; case SORT_AS_NUMBER: pDataTmp->bstrVal = SysAllocString(L"1000"); break; case SORT_AS_CURRENCY: pDataTmp->bstrVal = SysAllocString(L"2.18"); break; } * (pData + p) = * pDataTmp; } //执行脚本 try { int Found = ScriptControl->Run(WideString("MatchBill").c_bstr(),&Params); if(Found != 0 && Found != 1) { MessageBox(Handle,"脚本没有返回预期的0或1","脚本编译错误",MB_OK | MB_ICONSTOP); ScriptSucceed = false; } else ScriptSucceed = true; } catch(Exception & E) { ScriptSucceed = false; } if(!ScriptSucceed && ScriptControl->Error->Number != 0) MessageBox(Handle,("查询脚本错误:\n"\ "第 " + AnsiString(ScriptControl->Error->Line) \ + " 行,第 " + AnsiString(ScriptControl->Error->Column) \ + "列出现错误\n " + AnsiString(ScriptControl->Error->Number) \ + " (" + AnsiString(ScriptControl->Error->Description) + ")").c_str(),"脚本编译错误",MB_OK | MB_ICONSTOP); //释放字符串占用的空间 for(int p = 0;p < MatchFieldList->Count;p++) { pDataTmp = (VARIANT *)ParamList->Items[p]; SysFreeString(pDataTmp->bstrVal); } SafeArrayUnaccessData(Params); for(int n = 0;n < ParamList->Count;n++) { delete (VARIANT *)ParamList->Items[n]; } delete ParamList; delete ScriptControl; } if(ScriptSucceed) return Script; else return ""; }
//-------------------------------------------------------------------------- // Loads all the editor settings from file. True and false settings are saved // as 1 and 0. // If the contents of settings.dat to not match expected then default values // are used. void __fastcall TOptions::LoadSettings() { try { const int SIZE = 256; AnsiString str; str = ExtractFilePath(Application->ExeName) + "settings.dat"; char fileName[SIZE]; strcpy(fileName, str.c_str()); // fileName is path + settings.dat defaultSettings(); // start with default settings if(FileExists(fileName)) //check if settings file exists { //if it did then load all the settings char buffer[SIZE+1]; char temp[SIZE+1]; //temp storage unsigned int index; //looping index ifstream File(fileName); //open settings file // read and set flags from file File.getline(buffer, SIZE); //first line contains version number File.getline(buffer, SIZE); // 'generate list' setting if (!strcmp(&buffer[1],"$generate list")) { // if expected setting if(buffer[0] == '1') { listFlag = true; chkGenList->Checked = true; } else { listFlag = false; chkGenList->Checked = false; } } File.getline(buffer, SIZE); // 'generate s-record' setting if (!strcmp(&buffer[1],"$generate s-record")) { // if expected setting if(buffer[0] == '1') { objFlag = true; chkGenSRec->Checked = true; } else { objFlag = false; chkGenSRec->Checked = false; } } File.getline(buffer, SIZE); // 'save before assemble' setting if (!strcmp(&buffer[1],"$save then assemble")) { // if expected setting if(buffer[0] == '1') { bSave = true; chkSave->Checked = true; } else { bSave = false; chkSave->Checked = false; } } File.getline(buffer, SIZE); // 'Show Warnings' setting if (!strcmp(&buffer[1],"$show warnings")) { // if expected setting if(buffer[0] == '1') { WARflag = true; chkShowWarnings->Checked = true; } else { WARflag = false; chkShowWarnings->Checked = false; } } File.getline(buffer, SIZE); // 'cross reference' setting if (!strcmp(&buffer[1],"$cross reference")) { // if expected setting if(buffer[0] == '1') { CREflag = true; chkCrossRef->Checked = true; } else { CREflag = false; chkCrossRef->Checked = false; } } File.getline(buffer, SIZE); // 'macro expanded setting' setting if (!strcmp(&buffer[1],"$macros expanded")) { // if expected setting if(buffer[0] == '1') { MEXflag = true; chkMacEx->Checked = true; } else { MEXflag = false; chkMacEx->Checked = false; } } File.getline(buffer, SIZE); // 'structured assembly expanded setting' setting if (!strcmp(&buffer[1],"$structured expand")) { // if expected setting if(buffer[0] == '1') { SEXflag = true; chkStrucEx->Checked = true; } else { SEXflag = false; chkStrucEx->Checked = false; } } File.getline(buffer, SIZE); // 'constants expanded setting' setting if (!strcmp(&buffer[1],"$constants expand")) { // if expected setting if(buffer[0] == '1') { CEXflag = true; chkConstantsEx->Checked = true; } else { CEXflag = false; chkConstantsEx->Checked = false; } } index = 0; File.getline(buffer, SIZE); // 'font name' setting while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$font name")) { // if expected setting EditorOptionsForm->cbFont->Text = temp; } File.getline(buffer, SIZE); // 'font size' setting index = 0; //reset looping index while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$font size")) { // if expected setting EditorOptionsForm->cbSize->Text = temp; } File.getline(buffer, SIZE); // Tab Type setting if (!strcmp(&buffer[1],"$tab type")) { // if expected setting if(buffer[0] == '0') { EditorOptionsForm->AssemblyTabs->Checked = true; EditorOptionsForm->FixedTabs->Checked = false; tabType = Assembly; } else { EditorOptionsForm->AssemblyTabs->Checked = false; EditorOptionsForm->FixedTabs->Checked = true; tabType = Fixed; } } File.getline(buffer, SIZE); // Fixed Tab Size index = 0; while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$fixed tab size")) { // if expected setting EditorOptionsForm->FixedTabSize->Value = atoi(temp); } File.getline(buffer, SIZE); // maximizedEdit setting if (!strcmp(&buffer[1],"$maximized edit")) { // if expected setting if(buffer[0] == '1') { maximizedEdit = true; } else { maximizedEdit = false; } } File.getline(buffer, SIZE); // autoIndent setting if (!strcmp(&buffer[1],"$auto indent")) { // if expected setting if(buffer[0] == '1') { autoIndent = true; EditorOptionsForm->AutoIndent->Checked = true; } else { autoIndent = false; EditorOptionsForm->AutoIndent->Checked = false; } } File.getline(buffer, SIZE); // realTabs setting if (!strcmp(&buffer[1],"$real tabs")) { // if expected setting if(buffer[0] == '1') { realTabs = true; EditorOptionsForm->RealTabs->Checked = true; } else { realTabs = false; EditorOptionsForm->RealTabs->Checked = false; } } File.getline(buffer, SIZE); // Bitfield setting if (!strcmp(&buffer[1],"$assemble bit field")) { // if expected setting if(buffer[0] == '1') { BITflag = true; chkBitfield->Checked = true; } else { BITflag = false; chkBitfield->Checked = false; } } File.getline(buffer, SIZE); // 'Main Form Top' setting index = 0; while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$main top")) { // if expected setting Main->Top = atoi(temp); } File.getline(buffer, SIZE); // 'Main Form Left' setting index = 0; while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$main left")) { // if expected setting Main->Left = atoi(temp); } File.getline(buffer, SIZE); // 'Main Form Height' setting index = 0; while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$main height")) { // if expected setting Main->Height = atoi(temp); } File.getline(buffer, SIZE); // 'Main Form Width' setting index = 0; while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$main width")) { // if expected setting Main->Width = atoi(temp); } // Syntax Highlight stuff File.getline(buffer,SIZE); index = 0; while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$code color")) { // if expected setting codeStyle.color = (TColor)atoi(temp); } File.getline(buffer,SIZE); index = 0; while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$code bold")) { // if expected setting codeStyle.bold = atoi(temp); } File.getline(buffer,SIZE); index = 0; while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$code italic")) { // if expected setting codeStyle.italic = atoi(temp); } File.getline(buffer,SIZE); index = 0; while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$code underline")) { // if expected setting codeStyle.underline = atoi(temp); } File.getline(buffer,SIZE); index = 0; while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$unknown color")) { // if expected setting unknownStyle.color = (TColor)atoi(temp); } File.getline(buffer,SIZE); index = 0; while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$unknown bold")) { // if expected setting unknownStyle.bold = atoi(temp); } File.getline(buffer,SIZE); index = 0; while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$unknown italic")) { // if expected setting unknownStyle.italic = atoi(temp); } File.getline(buffer,SIZE); index = 0; while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$unknown underline")) { // if expected setting unknownStyle.underline = atoi(temp); } File.getline(buffer,SIZE); index = 0; while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$directive color")) { // if expected setting directiveStyle.color = (TColor)atoi(temp); } File.getline(buffer,SIZE); index = 0; while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$directive bold")) { // if expected setting directiveStyle.bold = atoi(temp); } File.getline(buffer,SIZE); index = 0; while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$directive italic")) { // if expected setting directiveStyle.italic = atoi(temp); } File.getline(buffer,SIZE); index = 0; while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$directive underline")) { // if expected setting directiveStyle.underline = atoi(temp); } File.getline(buffer,SIZE); index = 0; while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$comment color")) { // if expected setting commentStyle.color = (TColor)atoi(temp); } File.getline(buffer,SIZE); index = 0; while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$comment bold")) { // if expected setting commentStyle.bold = atoi(temp); } File.getline(buffer,SIZE); index = 0; while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$comment italic")) { // if expected setting commentStyle.italic = atoi(temp); } File.getline(buffer,SIZE); index = 0; while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$comment underline")) { // if expected setting commentStyle.underline = atoi(temp); } File.getline(buffer,SIZE); index = 0; while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$label color")) { // if expected setting labelStyle.color = (TColor)atoi(temp); } File.getline(buffer,SIZE); index = 0; while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$label bold")) { // if expected setting labelStyle.bold = atoi(temp); } File.getline(buffer,SIZE); index = 0; while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$label italic")) { // if expected setting labelStyle.italic = atoi(temp); } File.getline(buffer,SIZE); index = 0; while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$label underline")) { // if expected setting labelStyle.underline = atoi(temp); } File.getline(buffer,SIZE); index = 0; while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$structure color")) { // if expected setting structureStyle.color = (TColor)atoi(temp); } File.getline(buffer,SIZE); index = 0; while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$structure bold")) { // if expected setting structureStyle.bold = atoi(temp); } File.getline(buffer,SIZE); index = 0; while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$structure italic")) { // if expected setting structureStyle.italic = atoi(temp); } File.getline(buffer,SIZE); index = 0; while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$structure underline")) { // if expected setting structureStyle.underline = atoi(temp); } File.getline(buffer,SIZE); index = 0; while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$error color")) { // if expected setting errorStyle.color = (TColor)atoi(temp); } File.getline(buffer,SIZE); index = 0; while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$error bold")) { // if expected setting errorStyle.bold = atoi(temp); } File.getline(buffer,SIZE); index = 0; while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$error italic")) { // if expected setting errorStyle.italic = atoi(temp); } File.getline(buffer,SIZE); index = 0; while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$error underline")) { // if expected setting errorStyle.underline = atoi(temp); } File.getline(buffer,SIZE); index = 0; while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$text color")) { // if expected setting textStyle.color = (TColor)atoi(temp); } File.getline(buffer,SIZE); index = 0; while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$text bold")) { // if expected setting textStyle.bold = atoi(temp); } File.getline(buffer,SIZE); index = 0; while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$text italic")) { // if expected setting textStyle.italic = atoi(temp); } File.getline(buffer,SIZE); index = 0; while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$text underline")) { // if expected setting textStyle.underline = atoi(temp); } File.getline(buffer,SIZE); index = 0; while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$highlight disabled")) { // if expected setting highlightDisabled = atoi(temp); } File.getline(buffer, SIZE); // Print w/Black if (!strcmp(&buffer[1],"$print w/black")) { // if expected setting if(buffer[0] == '1') EditorOptionsForm->PrintBlack->Checked = true; else EditorOptionsForm->PrintBlack->Checked = false; } File.getline(buffer,SIZE); index = 0; while(buffer[index] != '$' && index < SIZE) { temp[index] = buffer[index]; index++; } temp[index] = '\0'; if (!strcmp(&buffer[index],"$background color")) { // if expected setting backColor = (TColor)atoi(temp); } File.close(); } // endif } catch( ... ) { MessageDlg("Error loading editor settings",mtInformation, TMsgDlgButtons() << mbOK,0); return; } }
//-------------------------------------------------------------------------- void __fastcall TOptions::defaultSettings() // default settings { try { AnsiString str; str = ExtractFilePath(Application->ExeName) + "settings.dat"; char fileName[256]; strcpy(fileName, str.c_str()); // fileName is path + settings.dat listFlag = chkGenList->Checked; objFlag = chkGenSRec->Checked; bSave = chkSave->Checked; WARflag = chkShowWarnings->Checked; CREflag = chkCrossRef->Checked; MEXflag = chkMacEx->Checked; SEXflag = chkStrucEx->Checked; CEXflag = chkConstantsEx->Checked; if (EditorOptionsForm->FixedTabs->Checked) tabType = Fixed; else tabType = Assembly; autoIndent = EditorOptionsForm->AutoIndent->Checked; realTabs = EditorOptionsForm->RealTabs->Checked; BITflag = chkBitfield->Checked; codeStyle.color = DEFAULT_CODE_COLOR; codeStyle.bold = false; codeStyle.italic = false; codeStyle.underline = false; unknownStyle.color = DEFAULT_UNKNOWN_COLOR; unknownStyle.bold = false; unknownStyle.italic = false; unknownStyle.underline = false; directiveStyle.color = DEFAULT_DIRECTIVE_COLOR; directiveStyle.bold = false; directiveStyle.italic = false; directiveStyle.underline = false; commentStyle.color = DEFAULT_COMMENT_COLOR; commentStyle.bold = false; commentStyle.italic = false; commentStyle.underline = false; labelStyle.color = DEFAULT_LABEL_COLOR; labelStyle.bold = false; labelStyle.italic = false; labelStyle.underline = false; structureStyle.color = DEFAULT_STRUCTURE_COLOR; structureStyle.bold = false; structureStyle.italic = false; structureStyle.underline = false; errorStyle.color = DEFAULT_ERROR_COLOR; errorStyle.bold = false; errorStyle.italic = false; errorStyle.underline = false; textStyle.color = DEFAULT_TEXT_COLOR; textStyle.bold = false; textStyle.italic = false; textStyle.underline = false; highlightDisabled = false; backColor = DEFAULT_BACK_COLOR; } catch( ... ) { MessageDlg("Error configuring default editor settings",mtInformation, TMsgDlgButtons() << mbOK,0); return; } }
void __fastcall TOptions::SaveSettings() //saves editor settings to file, true & false settings are saved as 1 and 0 { maximizedEdit = false; //grab active mdi child TTextStuff *Active = (TTextStuff*)Main->ActiveMDIChild; if (Active) { if (Active->WindowState == wsMaximized) maximizedEdit = true; } try { AnsiString str; str = ExtractFilePath(Application->ExeName) + "settings.dat"; char fileName[256]; strcpy(fileName, str.c_str()); // fileName is path + settings.dat ofstream File(fileName); //open settings file if (EditorOptionsForm->AssemblyTabs->Checked) tabType = Assembly; else tabType = Fixed; //save all assembler and editor flags File << "$Settings for " << TITLE << " DO NOT EDIT THIS FILE!!!!\n" << listFlag << "$generate list\n" << objFlag << "$generate s-record\n" << bSave << "$save then assemble\n" << chkShowWarnings->Checked << "$show warnings\n" << chkCrossRef->Checked << "$cross reference\n" << chkMacEx->Checked << "$macros expanded\n" << chkStrucEx->Checked << "$structured expand\n" << chkConstantsEx->Checked << "$constants expand\n" << EditorOptionsForm->cbFont->Text.c_str() << "$font name\n" << EditorOptionsForm->cbSize->Text.c_str() << "$font size\n" << tabType << "$tab type\n" << EditorOptionsForm->FixedTabSize->Value << "$fixed tab size\n" << maximizedEdit << "$maximized edit\n" << autoIndent << "$auto indent\n" << realTabs << "$real tabs\n" << chkBitfield->Checked << "$assemble bit field\n" << Main->Top << "$main top\n" << Main->Left << "$main left\n" << Main->Height << "$main height\n" << Main->Width << "$main width\n" << codeStyle.color << "$code color\n" << codeStyle.bold << "$code bold\n" << codeStyle.italic << "$code italic\n" << codeStyle.underline << "$code underline\n" << unknownStyle.color << "$unknown color\n" << unknownStyle.bold << "$unknown bold\n" << unknownStyle.italic << "$unknown italic\n" << unknownStyle.underline << "$unknown underline\n" << directiveStyle.color << "$directive color\n" << directiveStyle.bold << "$directive bold\n" << directiveStyle.italic << "$directive italic\n" << directiveStyle.underline << "$directive underline\n" << commentStyle.color << "$comment color\n" << commentStyle.bold << "$comment bold\n" << commentStyle.italic << "$comment italic\n" << commentStyle.underline << "$comment underline\n" << labelStyle.color << "$label color\n" << labelStyle.bold << "$label bold\n" << labelStyle.italic << "$label italic\n" << labelStyle.underline << "$label underline\n" << structureStyle.color << "$structure color\n" << structureStyle.bold << "$structure bold\n" << structureStyle.italic << "$structure italic\n" << structureStyle.underline << "$structure underline\n" << errorStyle.color << "$error color\n" << errorStyle.bold << "$error bold\n" << errorStyle.italic << "$error italic\n" << errorStyle.underline << "$error underline\n" << textStyle.color << "$text color\n" << textStyle.bold << "$text bold\n" << textStyle.italic << "$text italic\n" << textStyle.underline << "$text underline\n" << highlightDisabled << "$highlight disabled\n" << EditorOptionsForm->PrintBlack->Checked << "$print w/black\n" << backColor << "$background color\n"; File.close(); } catch( ... ) { MessageDlg("Error saving editor settings",mtInformation, TMsgDlgButtons() << mbOK,0); return; } }
int AnsiString::operator <=(AnsiString S) { return operator <=(S.c_str()); }
bool TEventLauncher::Load(cParser *parser) { // wczytanie wyzwalacza zdarzeñ AnsiString str; std::string token; parser->getTokens(); *parser >> dRadius; // promieñ dzia³ania if (dRadius > 0.0) dRadius *= dRadius; // do kwadratu, pod warunkiem, ¿e nie jest ujemne parser->getTokens(); // klawisz steruj¹cy *parser >> token; str = AnsiString(token.c_str()); if (str != "none") { if (str.Length() == 1) iKey = VkKeyScan(str[1]); // jeden znak jest konwertowany na kod klawisza else iKey = str.ToIntDef(0); // a jak wiêcej, to jakby numer klawisza jest } parser->getTokens(); *parser >> DeltaTime; if (DeltaTime < 0) DeltaTime = -DeltaTime; // dla ujemnego zmieniamy na dodatni else if (DeltaTime > 0) { // wartoœæ dodatnia oznacza wyzwalanie o okreœlonej godzinie iMinute = int(DeltaTime) % 100; // minuty s¹ najm³odszymi cyframi dziesietnymi iHour = int(DeltaTime - iMinute) / 100; // godzina to setki DeltaTime = 0; // bez powtórzeñ WriteLog("EventLauncher at " + IntToStr(iHour) + ":" + IntToStr(iMinute)); // wyœwietlenie czasu } parser->getTokens(); *parser >> token; asEvent1Name = AnsiString(token.c_str()); // pierwszy event parser->getTokens(); *parser >> token; asEvent2Name = AnsiString(token.c_str()); // drugi event if ((asEvent2Name == "end") || (asEvent2Name == "condition")) { // drugiego eventu mo¿e nie byæ, bo s¹ z tym problemy, ale ciii... str = asEvent2Name; // rozpoznane s³owo idzie do dalszego przetwarzania asEvent2Name = "none"; // a drugiego eventu nie ma } else { // gdy s¹ dwa eventy parser->getTokens(); *parser >> token; str = AnsiString(token.c_str()); } if (str == AnsiString("condition")) { // obs³uga wyzwalania warunkowego parser->getTokens(); *parser >> token; asMemCellName = AnsiString(token.c_str()); parser->getTokens(); *parser >> token; SafeDeleteArray(szText); szText = new char[256]; strcpy(szText, token.c_str()); if (token.compare("*") != 0) //*=nie braæ command pod uwagê iCheckMask |= conditional_memstring; parser->getTokens(); *parser >> token; if (token.compare("*") != 0) //*=nie braæ wartoœci 1. pod uwagê { iCheckMask |= conditional_memval1; str = AnsiString(token.c_str()); fVal1 = str.ToDouble(); } else fVal1 = 0; parser->getTokens(); *parser >> token; if (token.compare("*") != 0) //*=nie braæ wartoœci 2. pod uwagê { iCheckMask |= conditional_memval2; str = AnsiString(token.c_str()); fVal2 = str.ToDouble(); } else fVal2 = 0; parser->getTokens(); // s³owo zamykaj¹ce *parser >> token; }
//--------------------------------------------------------------------------- void __fastcall TOptDialog::GetOpt(void) { TEdit *editu[]={RovPos1,RovPos2,RovPos3}; TEdit *editr[]={RefPos1,RefPos2,RefPos3}; AnsiString s; PosMode ->ItemIndex=PrcOpt.mode; Freq ->ItemIndex=PrcOpt.nf-1>NFREQ-1?NFREQ-1:PrcOpt.nf-1; ElMask ->Text =s.sprintf("%.0f",PrcOpt.elmin*R2D); DynamicModel ->ItemIndex=PrcOpt.dynamics; TideCorr ->ItemIndex=PrcOpt.tidecorr; IonoOpt ->ItemIndex=PrcOpt.ionoopt; TropOpt ->ItemIndex=PrcOpt.tropopt; SatEphem ->ItemIndex=PrcOpt.sateph; AmbRes ->ItemIndex=PrcOpt.modear; GloAmbRes ->ItemIndex=PrcOpt.glomodear; ValidThresAR ->Text =s.sprintf("%.1f",PrcOpt.thresar[0]); OutCntResetAmb->Text =s.sprintf("%d", PrcOpt.maxout); LockCntFixAmb->Text =s.sprintf("%d", PrcOpt.minlock); FixCntHoldAmb->Text =s.sprintf("%d", PrcOpt.minfix); ElMaskAR ->Text =s.sprintf("%.0f",PrcOpt.elmaskar*R2D); ElMaskHold ->Text =s.sprintf("%.0f",PrcOpt.elmaskhold*R2D); MaxAgeDiff ->Text =s.sprintf("%.1f",PrcOpt.maxtdiff); RejectGdop ->Text =s.sprintf("%.1f",PrcOpt.maxgdop); RejectThres ->Text =s.sprintf("%.1f",PrcOpt.maxinno); SlipThres ->Text =s.sprintf("%.3f",PrcOpt.thresslip); NumIter ->Text =s.sprintf("%d", PrcOpt.niter); SyncSol ->ItemIndex=PrcOpt.syncsol; ExSatsE ->Text =ExSats; NavSys1 ->Checked =PrcOpt.navsys&SYS_GPS; NavSys2 ->Checked =PrcOpt.navsys&SYS_GLO; NavSys3 ->Checked =PrcOpt.navsys&SYS_GAL; NavSys4 ->Checked =PrcOpt.navsys&SYS_QZS; NavSys5 ->Checked =PrcOpt.navsys&SYS_SBS; NavSys6 ->Checked =PrcOpt.navsys&SYS_CMP; PosOpt1 ->Checked =PrcOpt.posopt[0]; PosOpt2 ->Checked =PrcOpt.posopt[1]; PosOpt3 ->Checked =PrcOpt.posopt[2]; PosOpt4 ->Checked =PrcOpt.posopt[3]; PosOpt5 ->Checked =PrcOpt.posopt[4]; SolFormat ->ItemIndex=SolOpt.posf; TimeFormat ->ItemIndex=SolOpt.timef==0?0:SolOpt.times+1; TimeDecimal ->Text =s.sprintf("%d",SolOpt.timeu); LatLonFormat ->ItemIndex=SolOpt.degf; FieldSep ->Text =SolOpt.sep; OutputHead ->ItemIndex=SolOpt.outhead; OutputOpt ->ItemIndex=SolOpt.outopt; OutputDatum ->ItemIndex=SolOpt.datum; OutputHeight ->ItemIndex=SolOpt.height; OutputGeoid ->ItemIndex=SolOpt.geoid; NmeaIntv1 ->Text =s.sprintf("%.2g",SolOpt.nmeaintv[0]); NmeaIntv2 ->Text =s.sprintf("%.2g",SolOpt.nmeaintv[1]); DebugStatus ->ItemIndex=DebugStatusF; DebugTrace ->ItemIndex=DebugTraceF; BaselineConst->Checked =BaselineC; BaselineLen->Text =s.sprintf("%.3f",Baseline[0]); BaselineSig->Text =s.sprintf("%.3f",Baseline[1]); MeasErrR1 ->Text =s.sprintf("%.1f",PrcOpt.eratio[0]); MeasErrR2 ->Text =s.sprintf("%.1f",PrcOpt.eratio[1]); MeasErr2 ->Text =s.sprintf("%.3f",PrcOpt.err[1]); MeasErr3 ->Text =s.sprintf("%.3f",PrcOpt.err[2]); MeasErr4 ->Text =s.sprintf("%.3f",PrcOpt.err[3]); MeasErr5 ->Text =s.sprintf("%.3f",PrcOpt.err[4]); PrNoise1 ->Text =s.sprintf("%.2E",PrcOpt.prn[0]); PrNoise2 ->Text =s.sprintf("%.2E",PrcOpt.prn[1]); PrNoise3 ->Text =s.sprintf("%.2E",PrcOpt.prn[2]); PrNoise4 ->Text =s.sprintf("%.2E",PrcOpt.prn[3]); PrNoise5 ->Text =s.sprintf("%.2E",PrcOpt.prn[4]); SatClkStab ->Text =s.sprintf("%.2E",PrcOpt.sclkstab); RovPosTypeP ->ItemIndex=RovPosTypeF; RefPosTypeP ->ItemIndex=RefPosTypeF; RovAntPcv ->Checked =RovAntPcvF; RefAntPcv ->Checked =RefAntPcvF; RovAnt ->Text =RovAntF; RefAnt ->Text =RefAntF; RovAntE ->Text =s.sprintf("%.4f",RovAntDel[0]); RovAntN ->Text =s.sprintf("%.4f",RovAntDel[1]); RovAntU ->Text =s.sprintf("%.4f",RovAntDel[2]); RefAntE ->Text =s.sprintf("%.4f",RefAntDel[0]); RefAntN ->Text =s.sprintf("%.4f",RefAntDel[1]); RefAntU ->Text =s.sprintf("%.4f",RefAntDel[2]); SetPos(RovPosTypeP->ItemIndex,editu,RovPos); SetPos(RefPosTypeP->ItemIndex,editr,RefPos); SatPcvFile ->Text =SatPcvFileF; AntPcvFile ->Text =AntPcvFileF; StaPosFile ->Text =StaPosFileF; GeoidDataFile->Text =GeoidDataFileF; DCBFile ->Text =DCBFileF; EOPFile ->Text =EOPFileF; TLEFile ->Text =TLEFileF; TLESatFile ->Text =TLESatFileF; LocalDir ->Text =LocalDirectory; ReadAntList(); SvrCycleE ->Text =s.sprintf("%d",SvrCycle); TimeoutTimeE ->Text =s.sprintf("%d",TimeoutTime); ReconTimeE ->Text =s.sprintf("%d",ReconTime); NmeaCycleE ->Text =s.sprintf("%d",NmeaCycle); FileSwapMarginE->Text =s.sprintf("%d",FileSwapMargin); SvrBuffSizeE ->Text =s.sprintf("%d",SvrBuffSize); SolBuffSizeE ->Text =s.sprintf("%d",SolBuffSize); SavedSolE ->Text =s.sprintf("%d",SavedSol); NavSelectS ->ItemIndex=NavSelect; SbasSatE ->Text =s.sprintf("%d",PrcOpt.sbassatsel); ProxyAddrE ->Text =ProxyAddr; MoniPortE ->Text =s.sprintf("%d",MoniPort); SolBuffSizeE ->Text =s.sprintf("%d",SolBuffSize); PanelStackE ->ItemIndex=PanelStack; FontLabel->Font->Assign(PosFont); FontLabel->Caption=FontLabel->Font->Name+s.sprintf(" %dpt",FontLabel->Font->Size); UpdateEnable(); }
int WINAPI WinMain(HINSTANCE hInstance, // instance HINSTANCE hPrevInstance, // previous instance LPSTR lpCmdLine, // command line parameters int nCmdShow) // window show state { MSG msg; // windows message structure BOOL done = FALSE; // bool variable to exit loop fullscreen = true; DecimalSeparator = '.'; /* //Ra: tutaj to nie dzia³a - zwraca NULL //najpierw ustalmy wersjê OpenGL AnsiString glver=((char*)glGetString(GL_VERSION)); while (glver.LastDelimiter(".")>glver.Pos(".")) glver=glver.SubString(1,glver.LastDelimiter(".")-1); //obciêcie od drugiej kropki try {Global::fOpenGL=glver.ToDouble();} catch (...) {Global::fOpenGL=0.0;} Global::bOpenGL_1_5=(Global::fOpenGL>=1.5); */ DeleteFile("errors.txt"); // usuniêcie starego Global::LoadIniFile("eu07.ini"); // teraz dopiero mo¿na przejrzeæ plik z ustawieniami Global::InitKeys("keys.ini"); // wczytanie mapowania klawiszy - jest na sta³e // hunter-271211: ukrywanie konsoli if (Global::iWriteLogEnabled & 2) { AllocConsole(); SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN); } AnsiString str = lpCmdLine; // parametry uruchomienia if (!str.IsEmpty()) { // analizowanie parametrów TQueryParserComp *Parser; Parser = new TQueryParserComp(NULL); Parser->TextToParse = lpCmdLine; Parser->First(); while (!Parser->EndOfFile) { str = Parser->GetNextSymbol().LowerCase(); if (str == AnsiString("-s")) { // nazwa scenerii str = Parser->GetNextSymbol().LowerCase(); strcpy(Global::szSceneryFile, str.c_str()); } else if (str == AnsiString("-v")) { // nazwa wybranego pojazdu str = Parser->GetNextSymbol().LowerCase(); Global::asHumanCtrlVehicle = str; } else if (str == AnsiString("-modifytga")) { // wykonanie modyfikacji wszystkich plików TGA Global::iModifyTGA = -1; // specjalny tryb wykonania totalnej modyfikacji } else if (str == AnsiString("-e3d")) { // wygenerowanie wszystkich plików E3D if (Global::iConvertModels > 0) Global::iConvertModels = -Global::iConvertModels; // specjalny tryb else Global::iConvertModels = -7; // z optymalizacj¹, bananami i prawid³owym Opacity } else Error( "Program usage: EU07 [-s sceneryfilepath] [-v vehiclename] [-modifytga] [-e3d]", !Global::iWriteLogEnabled); } delete Parser; // ABu 050205: tego wczesniej nie bylo } /* MC: usunalem tymczasowo bo sie gryzlo z nowym parserem - 8.6.2003 AnsiString csp=AnsiString(Global::szSceneryFile); csp=csp.Delete(csp.Pos(AnsiString(strrchr(Global::szSceneryFile,'/')))+1,csp.Length()); Global::asCurrentSceneryPath=csp; */ fullscreen = Global::bFullScreen; WindowWidth = Global::iWindowWidth; WindowHeight = Global::iWindowHeight; Bpp = Global::iBpp; if (Bpp != 32) Bpp = 16; // create our OpenGL window if (!CreateGLWindow(Global::asHumanCtrlVehicle.c_str(), WindowWidth, WindowHeight, Bpp, fullscreen)) return 0; // quit if window was not created SetForegroundWindow(hWnd); // McZapkie: proba przeplukania klawiatury Console *pConsole = new Console(); // Ra: nie wiem, czy ma to sens, ale jakoœ zainicjowac trzeba while (Console::Pressed(VK_F10)) Error("Keyboard buffer problem - press F10"); // na Windows 98 lubi siê to pojawiaæ int iOldSpeed, iOldDelay; SystemParametersInfo(SPI_GETKEYBOARDSPEED, 0, &iOldSpeed, 0); SystemParametersInfo(SPI_GETKEYBOARDDELAY, 0, &iOldDelay, 0); SystemParametersInfo(SPI_SETKEYBOARDSPEED, 20, NULL, 0); // SystemParametersInfo(SPI_SETKEYBOARDDELAY,10,NULL,0); if (!joyGetNumDevs()) WriteLog("No joystick"); if (Global::iModifyTGA < 0) { // tylko modyfikacja TGA, bez uruchamiania symulacji Global::iMaxTextureSize = 64; //¿eby nie zamulaæ pamiêci World.ModifyTGA(); // rekurencyjne przegl¹danie katalogów } else { if (Global::iConvertModels < 0) { Global::iConvertModels = -Global::iConvertModels; World.CreateE3D("models\\"); // rekurencyjne przegl¹danie katalogów World.CreateE3D("dynamic\\", true); } // po zrobieniu E3D odpalamy normalnie sceneriê, by j¹ zobaczyæ // else //{//g³ówna pêtla programu Console::On(); // w³¹czenie konsoli while (!done) // loop that runs while done=FALSE { if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) // is there a message waiting? { if (msg.message == WM_QUIT) // have we received a quit message? done = TRUE; // if so else // if not, deal with window messages { // if (msg.message==WM_CHAR) // World.OnKeyDown(msg.wParam); TranslateMessage(&msg); // translate the message DispatchMessage(&msg); // dispatch the message } } else // if there are no messages { // draw the scene, watch for quit messages // DrawGLScene() // if (!pause) // if (Global::bInactivePause?Global::bActive:true) //tak nie, bo spada z góry if (World.Update()) // Was There A Quit Received? SwapBuffers(hDC); // Swap Buffers (Double Buffering) else done = true; //[F10] or DrawGLScene signalled a quit } } Console::Off(); // wy³¹czenie konsoli (komunikacji zwrotnej) } SystemParametersInfo(SPI_SETKEYBOARDSPEED, iOldSpeed, NULL, 0); SystemParametersInfo(SPI_SETKEYBOARDDELAY, iOldDelay, NULL, 0); delete pConsole; // deaktywania sterownika // shutdown KillGLWindow(); // kill the window return (msg.wParam); // exit the program }
//--------------------------------------------------------------------------- void __fastcall TOptDialog::LoadOpt(AnsiString file) { int itype[]={STR_SERIAL,STR_TCPCLI,STR_TCPSVR,STR_NTRIPCLI,STR_FILE,STR_FTP,STR_HTTP}; int otype[]={STR_SERIAL,STR_TCPCLI,STR_TCPSVR,STR_NTRIPSVR,STR_FILE}; TEdit *editu[]={RovPos1,RovPos2,RovPos3}; TEdit *editr[]={RefPos1,RefPos2,RefPos3}; AnsiString s; char buff[1024]="",*p,id[32]; int sat; prcopt_t prcopt=prcopt_default; solopt_t solopt=solopt_default; filopt_t filopt={""}; resetsysopts(); if (!loadopts(file.c_str(),sysopts)|| !loadopts(file.c_str(),rcvopts)) return; getsysopts(&prcopt,&solopt,&filopt); for (int i=0;i<8;i++) { MainForm->StreamC[i]=strtype[i]!=STR_NONE; MainForm->Stream[i]=STR_NONE; for (int j=0;j<(i<3?7:5);j++) { if (strtype[i]!=(i<3?itype[j]:otype[j])) continue; MainForm->Stream[i]=j; break; } if (i<5) MainForm->Format[i]=strfmt[i]; if (strtype[i]==STR_SERIAL) { MainForm->Paths[i][0]=strpath[i]; } else if (strtype[i]==STR_FILE) { MainForm->Paths[i][2]=strpath[i]; } else if (strtype[i]<=STR_NTRIPCLI) { MainForm->Paths[i][1]=strpath[i]; } else if (strtype[i]<=STR_HTTP) { MainForm->Paths[i][3]=strpath[i]; } } MainForm->NmeaReq=nmeareq; MainForm->NmeaPos[0]=nmeapos[0]; MainForm->NmeaPos[1]=nmeapos[1]; SbasSatE ->Text =s.sprintf("%d",prcopt.sbassatsel); PosMode ->ItemIndex =prcopt.mode; Freq ->ItemIndex =prcopt.nf>NFREQ-1?NFREQ-1:prcopt.nf-1; Solution ->ItemIndex =prcopt.soltype; ElMask ->Text =s.sprintf("%.0f",prcopt.elmin*R2D); DynamicModel ->ItemIndex =prcopt.dynamics; TideCorr ->ItemIndex =prcopt.tidecorr; IonoOpt ->ItemIndex =prcopt.ionoopt; TropOpt ->ItemIndex =prcopt.tropopt; SatEphem ->ItemIndex =prcopt.sateph; ExSatsE ->Text =""; for (sat=1,p=buff;sat<=MAXSAT;sat++) { if (!prcopt.exsats[sat-1]) continue; satno2id(sat,id); p+=sprintf(p,"%s%s%s",p==buff?"":" ",prcopt.exsats[sat-1]==2?"+":"",id); } ExSatsE ->Text =buff; NavSys1 ->Checked =prcopt.navsys&SYS_GPS; NavSys2 ->Checked =prcopt.navsys&SYS_GLO; NavSys3 ->Checked =prcopt.navsys&SYS_GAL; NavSys4 ->Checked =prcopt.navsys&SYS_QZS; NavSys5 ->Checked =prcopt.navsys&SYS_SBS; NavSys6 ->Checked =prcopt.navsys&SYS_CMP; PosOpt1 ->Checked =prcopt.posopt[0]; PosOpt2 ->Checked =prcopt.posopt[1]; PosOpt3 ->Checked =prcopt.posopt[2]; PosOpt4 ->Checked =prcopt.posopt[3]; PosOpt5 ->Checked =prcopt.posopt[4]; AmbRes ->ItemIndex =prcopt.modear; GloAmbRes ->ItemIndex =prcopt.glomodear; ValidThresAR ->Text =s.sprintf("%.1f",prcopt.thresar[0]); OutCntResetAmb->Text =s.sprintf("%d" ,prcopt.maxout ); FixCntHoldAmb->Text =s.sprintf("%d" ,prcopt.minfix ); LockCntFixAmb->Text =s.sprintf("%d" ,prcopt.minlock ); ElMaskAR ->Text =s.sprintf("%.0f",prcopt.elmaskar*R2D); ElMaskHold ->Text =s.sprintf("%.0f",prcopt.elmaskhold*R2D); MaxAgeDiff ->Text =s.sprintf("%.1f",prcopt.maxtdiff ); RejectGdop ->Text =s.sprintf("%.1f",prcopt.maxgdop ); RejectThres ->Text =s.sprintf("%.1f",prcopt.maxinno ); SlipThres ->Text =s.sprintf("%.3f",prcopt.thresslip); NumIter ->Text =s.sprintf("%d", prcopt.niter ); SyncSol ->ItemIndex =prcopt.syncsol; BaselineLen ->Text =s.sprintf("%.3f",prcopt.baseline[0]); BaselineSig ->Text =s.sprintf("%.3f",prcopt.baseline[1]); BaselineConst->Checked =prcopt.baseline[0]>0.0; SolFormat ->ItemIndex =solopt.posf; TimeFormat ->ItemIndex =solopt.timef==0?0:solopt.times+1; TimeDecimal ->Text =s.sprintf("%d",solopt.timeu); LatLonFormat ->ItemIndex =solopt.degf; FieldSep ->Text =solopt.sep; OutputHead ->ItemIndex =solopt.outhead; OutputOpt ->ItemIndex =solopt.outopt; OutputDatum ->ItemIndex =solopt.datum; OutputHeight ->ItemIndex =solopt.height; OutputGeoid ->ItemIndex =solopt.geoid; NmeaIntv1 ->Text =s.sprintf("%.2g",solopt.nmeaintv[0]); NmeaIntv2 ->Text =s.sprintf("%.2g",solopt.nmeaintv[1]); DebugTrace ->ItemIndex =solopt.trace; DebugStatus ->ItemIndex =solopt.sstat; MeasErrR1 ->Text =s.sprintf("%.1f",prcopt.eratio[0]); MeasErrR2 ->Text =s.sprintf("%.3f",prcopt.eratio[1]); MeasErr2 ->Text =s.sprintf("%.3f",prcopt.err[1]); MeasErr3 ->Text =s.sprintf("%.3f",prcopt.err[2]); MeasErr4 ->Text =s.sprintf("%.3f",prcopt.err[3]); MeasErr5 ->Text =s.sprintf("%.3f",prcopt.err[4]); SatClkStab ->Text =s.sprintf("%.2E",prcopt.sclkstab); PrNoise1 ->Text =s.sprintf("%.2E",prcopt.prn[0]); PrNoise2 ->Text =s.sprintf("%.2E",prcopt.prn[1]); PrNoise3 ->Text =s.sprintf("%.2E",prcopt.prn[2]); PrNoise4 ->Text =s.sprintf("%.2E",prcopt.prn[3]); PrNoise5 ->Text =s.sprintf("%.2E",prcopt.prn[4]); RovAntPcv ->Checked =*prcopt.anttype[0]; RefAntPcv ->Checked =*prcopt.anttype[1]; RovAnt ->Text =prcopt.anttype[0]; RefAnt ->Text =prcopt.anttype[1]; RovAntE ->Text =s.sprintf("%.4f",prcopt.antdel[0][0]); RovAntN ->Text =s.sprintf("%.4f",prcopt.antdel[0][1]); RovAntU ->Text =s.sprintf("%.4f",prcopt.antdel[0][2]); RefAntE ->Text =s.sprintf("%.4f",prcopt.antdel[1][0]); RefAntN ->Text =s.sprintf("%.4f",prcopt.antdel[1][1]); RefAntU ->Text =s.sprintf("%.4f",prcopt.antdel[1][2]); RovPosTypeP ->ItemIndex =prcopt.rovpos==0?0:3; RefPosTypeP ->ItemIndex =prcopt.refpos==0?0:3; RovPosTypeF =RovPosTypeP->ItemIndex; RefPosTypeF =RefPosTypeP->ItemIndex; SetPos(RovPosTypeP->ItemIndex,editu,prcopt.ru); SetPos(RefPosTypeP->ItemIndex,editr,prcopt.rb); SatPcvFile ->Text =filopt.satantp; AntPcvFile ->Text =filopt.rcvantp; StaPosFile ->Text =filopt.stapos; GeoidDataFile->Text =filopt.geoid; DCBFile ->Text =filopt.dcb; LocalDir ->Text =filopt.tempdir; ReadAntList(); UpdateEnable(); }
inline int GetPos(const AnsiString& s, const AnsiString& p) { return s.AnsiPos(p); }
//--------------------------------------------------------------------------- void __fastcall TDM::ListaExterna(PHDataSource *DS, PHTable *Tabela, AnsiString CampoOrig, short Elemento, AnsiString CampoConsul, short Sistema) { AnsiString Codigo = ""; AnsiString Chave; AnsiString Diretorio; AnsiString NomeSistema; if(Sistema) { Diretorio = DadosEmpresa(EMPRESAS_LOCALSCPH,vg.EmpresaAtual,0); NomeSistema = "SCPH"; } else { Diretorio = DadosEmpresa(EMPRESAS_LOCALEFPH,vg.EmpresaAtual,0); NomeSistema = "EFPH"; } Diretorio = IncludeTrailingBackslash(Diretorio); if(Diretorio != "") { PHDataSource *_PHDS1; try { _PHDS1 = new PHDataSource(NULL); _PHDS1->Name = "DSListaExterna"; _PHDS1->Tabela = Tabela; if(_PHDS1->Tabela->DiretorioTipo == tdPrincipal) { Diretorio = DiretorioPrincipal(Diretorio); } _PHDS1->DiretorioTipo = tdsExplicito; _PHDS1->Diretorio = Diretorio; TLista *L1 = new TLista(this); try { L1->Caption = "Lista: " + _PHDS1->Tabela->NomeOpcao; L1->PHDS->Tabela = _PHDS1->Tabela; L1->PHDS->DiretorioTipo = _PHDS1->DiretorioTipo; L1->PHDS->Diretorio = _PHDS1->Diretorio; L1->PHDS->IndiceNome = _PHDS1->Tabela->IndiceConsulta; L1->PHDS->FiltrVis = true; L1->PHDS->FiltroExpr = _PHDS1->FiltroExpr; L1->PHDS->Filtrado = _PHDS1->Filtrado; L1->PHDS->FiltrVis = true; L1->PHDS->DestaqueExpr = _PHDS1->DestaqueExpr; L1->PHDS->Destacado = _PHDS1->Destacado; L1->PHDS->DiaNomeArq = _PHDS1->DiaNomeArq; L1->PHDS->MesNomeArq = _PHDS1->MesNomeArq; L1->PHDS->AnoNomeArq = _PHDS1->AnoNomeArq; if(_PHDS1->OnFiltro) { L1->PHDS->OnFiltro = _PHDS1->OnFiltro; } L1->PHDS->Open(true); int CR = L1->PHDS->CountReg() + 1; if(CR >= 2) { L1->PHGrid1->RowCount = CR; } else { throw Exception("Não foi possível montar Lista para Consulta. Verifique o 'Local " + NomeSistema + "' no Cadastro de Empresas."); } L1->PHGrid1->AjustaColunas(0); L1->PHGrid1->Row = 1; Chave = DS->GT(CampoOrig,Elemento); if(Chave.Trim() != "") { L1->PHDS->BuscaKeyBD(CampoConsul,Chave,true,true); L1->PHGrid1->Row = L1->PHDS->Ponteiro + 1; } L1->ShowModal(); if(L1->Retorno) { Codigo = L1->PHDS->GV(CampoConsul); if(Codigo.Trim() != "") { DS->Edit(); DS->SV(CampoOrig,Elemento,Codigo); } } } __finally { L1->PHDS->Close(); if(L1) { delete L1; } L1 = NULL; } } __finally { _PHDS1->Close(); delete _PHDS1; } }
/* ======================================================================================================================= ======================================================================================================================= */ void __fastcall TFormMoore::Button2Click(TObject *Sender) { /*~~~~~~~*/ bool Es; /*~~~~~~~*/ cont++; if(cont <= AFe1sin.Length()) { /*~~~~~~*/ int E = 0; /*~~~~~~*/ for(int j = 0; j < 11; j++) { if(AFea[cont * 2 - 1] == ' ') { if(Estados[j].Nombre == AFea[cont * 2]) { E = j; j = 11; } } else { if ( (Estados[j].Nombre[Estados[j].Nombre.Length()] == AFea[cont * 2]) && (Estados[j].Nombre[Estados[j].Nombre.Length() - 1] == AFea[cont * 2 - 1]) ) { E = j; j = 11; } } } for(int i = 1; i < 17; i++) { Es = true; if(Estados[E].Enlace[i][1][1] != AFe1[cont * 2]) { Es = false; } if(Entradas > 1) { if(Estados[E].Enlace[i][1][2] != AFe2[cont * 2]) { Es = false; } } if(Entradas > 2) { if(Estados[E].Enlace[i][1][3] != AFe3[cont * 2]) { Es = false; } } if(Entradas > 3) { if(Estados[E].Enlace[i][1][4] != AFe4[cont * 2]) { Es = false; } } if(Entradas > 4) { if(Estados[E].Enlace[i][1][5] != AFe5[cont * 2]) { Es = false; } } if(Es == true) { /*~~~~~~*/ int I = 0; /*~~~~~~*/ for(int j = 0; j < 11; j++) { if(Estados[j].Nombre == Estados[E].Enlace[i][2]) { I = j; j = 11; } } if(Estados[I].Nombre.Length() == 1) { AFes = AFes + " " + Estados[I].Nombre; } else { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ AnsiString V = Estados[I].Nombre; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ AFes = AFes + V[V.Length() - 1] + V[V.Length()]; } AFea = AFea + AFes[cont * 2 - 1] + AFes[cont * 2]; AFs1 = AFs1 + " " + Estados[I].Salida[1]; if(Salidas > 1) { AFs2 = AFs2 + " " + Estados[I].Salida[2]; } if(Salidas > 2) { AFs3 = AFs3 + " " + Estados[I].Salida[3]; } if(Salidas > 3) { AFs4 = AFs4 + " " + Estados[I].Salida[4]; } if(Salidas > 4) { AFs5 = AFs5 + " " + Estados[I].Salida[5]; } FormMoore->Fea->Text = AFea; FormMoore->Fs1->Text = AFs1; FormMoore->Fs2->Text = AFs2; FormMoore->Fs3->Text = AFs3; FormMoore->Fs4->Text = AFs4; FormMoore->Fs5->Text = AFs5; FormMoore->Fes->Text = AFes; i = 17; } } } }
void IMAPSort::CacheHeaderFields_(std::shared_ptr<IMAPConnection> pConnection, const std::vector<std::pair<int, std::shared_ptr<Message> > > &vecMessages, const std::map<__int64, String > &databaseMetaData, SortField &sortField, std::map<__int64, String> &mapHeaderFields) { mapHeaderFields.clear(); String sHeaderField; switch (sortField) { case From: sHeaderField = "From"; break; case Subject: sHeaderField = "Subject"; break; case To: sHeaderField = "To"; break; case CC: sHeaderField = "CC"; break; case Date: sHeaderField = "Date"; break; } // Cache the header field for all messages. bool bTrimLeadingSpecialCharacters = (sortField == From || sortField == To || sortField == CC); std::vector<std::pair<int, std::shared_ptr<Message> > >::const_iterator iter = vecMessages.begin(); std::vector<std::pair<int, std::shared_ptr<Message> > >::const_iterator iterEnd = vecMessages.end(); for (; iter != iterEnd; iter++) { // Fetch message. const std::shared_ptr<Message> p1 = (*iter).second; String sFieldValue = ""; // Read message and parse out the value from the header. std::map<__int64, String >::const_iterator dbMetaIter = databaseMetaData.find(p1->GetID()); if (dbMetaIter == databaseMetaData.end()) { String fileName = PersistentMessage::GetFileName(pConnection->GetAccount(), p1); AnsiString sHeader = PersistentMessage::LoadHeader(fileName); MimeHeader oHeader;oHeader.Load(sHeader, sHeader.GetLength()); sFieldValue = oHeader.GetUnicodeFieldValue(sHeaderField); if (sortField == Date) { DateTime dt = Time::GetDateTimeFromMimeHeader(sFieldValue); sFieldValue = Time::GetTimeStampFromDateTime(dt); } } else { sFieldValue = (*dbMetaIter).second; } if (sortField == Date && sFieldValue.IsEmpty()) { /* * RFC 5256 "2.2. Sent Date" chapter. If the sent date cannot be determined (a Date: header is missing or cannot be parsed), * the INTERNALDATE for that message is used as the sent date. */ sFieldValue = p1->GetCreateTime(); } // Convert the string to upper case. The sorting should be // case insensitive. Otherwise b will come before A. sFieldValue.ToUpper(); // Remove leading ". If we sort on From, "Test" should come in // same position as Test. (quotes / no quotes) if (bTrimLeadingSpecialCharacters) { sFieldValue.TrimLeft(_T("\"")); sFieldValue.TrimLeft(_T("<")); } // Cache the header mapHeaderFields[p1->GetID()] = sFieldValue; } }
/* ======================================================================================================================= ======================================================================================================================= */ void __fastcall TFormMoore::Button1Click(TObject *Sender) { /*~~~~~~~~~~~~~~~~~~~~*/ bool Correcto = true; /*~~~~~~~~~~~~~~~~~~~~*/ FormMoore->Button4->Enabled = true; AFe1sin = ""; AFe2sin = ""; AFe3sin = ""; AFe4sin = ""; AFe5sin = ""; AFe1sin = FormMoore->Fe1->Text; for(int i = 1; i <= AFe1sin.Length(); i++) { if((AFe1sin[i] != '0') & (AFe1sin[i] != '1')) { Correcto = false; i = AFe1sin.Length() + 1; } } if(Entradas > 1) { AFe2sin = FormMoore->Fe2->Text; if(AFe2sin.Length() != AFe1sin.Length()) { Correcto = false; } for(int i = 1; i <= AFe2sin.Length(); i++) { if((AFe2sin[i] != '0') & (AFe2sin[i] != '1')) { Correcto = false; i = AFe2sin.Length() + 1; } } } if(Entradas > 2) { AFe3sin = FormMoore->Fe3->Text; if(AFe3sin.Length() != AFe2sin.Length()) { Correcto = false; } for(int i = 1; i <= AFe3sin.Length(); i++) { if((AFe3sin[i] != '0') & (AFe3sin[i] != '1')) { Correcto = false; i = AFe3sin.Length() + 1; } } } if(Entradas > 3) { AFe4sin = FormMoore->Fe4->Text; if(AFe4sin.Length() != AFe3sin.Length()) { Correcto = false; } for(int i = 1; i <= AFe4sin.Length(); i++) { if((AFe4sin[i] != '0') & (AFe4sin[i] != '1')) { Correcto = false; i = AFe4sin.Length() + 1; } } } if(Entradas > 4) { AFe5sin = FormMoore->Fe5->Text; if(AFe5sin.Length() != AFe4sin.Length()) { Correcto = false; } for(int i = 1; i <= AFe5sin.Length(); i++) { if((AFe5sin[i] != '0') & (AFe5sin[i] != '1')) { Correcto = false; i = AFe5sin.Length() + 1; } } } if(AFe1sin.Length() > 24) { Correcto = false; } if(Correcto == false) { Application->MessageBox ( "Las entradas deben ser ceros y unos,de la misma longitud y no mayor que 24", NULL, MB_OK ); } if(Correcto == true) { for(int i = 1; i <= AFe1sin.Length(); i++) { AFe1 = AFe1 + " " + AFe1sin[i]; if(Entradas > 1) { AFe2 = AFe2 + " " + AFe2sin[i]; } if(Entradas > 2) { AFe3 = AFe3 + " " + AFe3sin[i]; } if(Entradas > 3) { AFe4 = AFe4 + " " + AFe4sin[i]; } if(Entradas > 4) { AFe5 = AFe5 + " " + AFe5sin[i]; } } FormMoore->Fe1->Text = AFe1; FormMoore->Fe2->Text = AFe2; FormMoore->Fe3->Text = AFe3; FormMoore->Fe4->Text = AFe4; FormMoore->Fe5->Text = AFe5; FormMoore->Fe1->ReadOnly = true; FormMoore->Fe2->ReadOnly = true; FormMoore->Fe3->ReadOnly = true; FormMoore->Fe4->ReadOnly = true; FormMoore->Fe5->ReadOnly = true; FormMoore->Button2->Enabled = true; FormMoore->Button1->Enabled = false; if(Estados[0].Nombre.Length() == 1) { AFea = AFea + " " + Estados[0].Nombre[1]; } else { AFea = AFea + Estados[0].Nombre[Estados[0].Nombre.Length() - 1] + Estados[0].Nombre[Estados[0].Nombre.Length()]; } FormMoore->Fea->Text = AFea; AFs1 = AFs1 + " " + Estados[0].Salida[1]; FormMoore->Fs1->Text = AFs1; if(Salidas > 1) { AFs2 = AFs2 + " " + Estados[0].Salida[2]; FormMoore->Fs2->Text = AFs2; } if(Salidas > 2) { AFs3 = AFs3 + " " + Estados[0].Salida[3]; FormMoore->Fs3->Text = AFs3; } if(Salidas > 3) { AFs4 = AFs4 + " " + Estados[0].Salida[4]; FormMoore->Fs4->Text = AFs4; } if(Salidas > 4) { AFs5 = AFs5 + " " + Estados[0].Salida[5]; FormMoore->Fs5->Text = AFs5; } } }
//--------------------------------------------------------------------------- BOOL TConfDlg::LoadConfig(const AnsiString &File) { HANDLE file; DWORD type, fileversion; HostData *actData; char PlgName[30]="NONE",*N = PlgName; int i; bool ignoreContext=false; file = CreateFileA(File.c_str(),GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN,0); if(file == INVALID_HANDLE_VALUE) { Application->MessageBox("Cannot open file!","Error",MB_OK|MB_ICONERROR); return FALSE; } type = ReadType(file); if(type != MAGIC) { CloseHandle(file); Application->MessageBox("Invalid file format!", "Error",MB_OK|MB_ICONERROR); return FALSE; } fileversion = ReadType(file); if(fileversion != FILE_VERSION) { i = Application->MessageBox("Wrong file version! Try anyway?","Error",MB_YESNO|MB_ICONERROR); if (i == ID_NO) { CloseHandle(file); return FALSE; } } // This should not happen... while(SelectedBox->Items->Count) { RemoveSelHost(0,true); } for(i=0;i<LastList->Count;++i) { delete LastList->Objects[i]; LastList->Objects[i] = 0; } LastList->Clear(); actData = &GlobalConfig; FreeProcData(actData); SetHostAccount(actData,0); do { type = ReadType(file); switch(type) { case TYPE_CONFIG: ReadConfigData(file,actData,fileversion); if(ignoreContext) FreeContext(actData); break; case TYPE_ACCOUNT: ReadAccount(file,actData); break; case TYPE_ACCOUNT_ENCRYPTED: ReadAccountEncrypted(file,actData); break; case TYPE_HOST: actData = 0; ReadHost(file,&actData); if(actData) { CopyStateData(actData,(*Servers)[actData->Name]); LastList->AddObject(actData->Name,new CHostRef(actData)); } break; case TYPE_PLUGIN: ReadString(file,&N); if(!PluginManager.SetActualPlugin(PlgName)) ignoreContext = true; break; case TYPE_VERSION: case TYPE_GLOBAL: case TYPE_NONE: default: break; } } while(type != TYPE_NONE); CloseHandle(file); return TRUE; }
void TForm1::AnalyseOneFunction(int &FunctionCount, int NumberOfCalls, AnsiString FunctionString, std::ofstream &OutFile) { AnsiString Prelim = "./"; for(int x=0;x<5000;x++) { DupNumArray[x] = -1; MissingNumArray[x] = -1; } Label1->Caption = "Analysing function: " + FunctionString + " (" + AnsiString(FunctionCount + 1) + "/" + AnsiString(NumberOfCalls) + ")"; Form1->Repaint(); int DupNumArrayIndex = 0; for(int x=0;x<NumFiles;x++) { AnsiString FullFileName = Prelim + FileString[x]; std::ifstream InFile(FullFileName.c_str()); if(InFile == 0) { ShowMessage("Input file failed to open - " + FileString[x]); return; } char Buffer[5000]; bool EndOfFile = false; while(!EndOfFile) { InFile.getline(Buffer, 5000); AnsiString OneLine(Buffer); for(int x = 1; x< OneLine.Length() - FunctionString.Length() + 1;x++) { if(OneLine.SubString(x,FunctionString.Length() + 1) == FunctionString + '(') //rule out other functions that contain the sought function name (allow to be preceded by space, !, ., > or ( {if((x == 1) || (OneLine[x-1] < '"') || (OneLine[x-1] == '.') || (OneLine[x-1] == '>') || (OneLine[x-1] == '(')) { AnsiString NumberLineStr = OneLine.SubString(x + FunctionString.Length() + 1,OneLine.Length() - (x + FunctionString.Length() + 1)); AnsiString NumberString = ""; while((NumberLineStr.Length() > 0) && ((NumberLineStr[1] <= '9') && (NumberLineStr[1] >= '0'))) { NumberString+= NumberLineStr[1]; NumberLineStr.Delete(1,1); } if(NumberString != "") { int Number = NumberString.ToInt(); DupNumArray[DupNumArrayIndex] = Number; DupNumArrayIndex++; } } } } if(InFile.eof()) { EndOfFile = true; } } InFile.close(); } //Label1->Caption = "Array analysis started for function " + FunctionString; //Form1->Repaint(); int MaxIndex = -1;//so first brings it to 0 int MaxNumber = -1; for(int x=0;x<5000;x++) { if(DupNumArray[x] > -1) { MaxIndex++; if(DupNumArray[x] > MaxNumber) MaxNumber = DupNumArray[x]; } else break; } for(int x=0;x<MaxIndex+1;x++) { MissingNumArray[x] = DupNumArray[x]; } //check for duplicates for(int x=0;x<MaxIndex + 1;x++) { int CheckNumber = DupNumArray[x]; if(CheckNumber == -1) continue; int RepeatCount = 0; for(int y=x+1;y<MaxIndex + 1;y++) { if(DupNumArray[y] == CheckNumber) { RepeatCount++; DupNumArray[y] = -1;//so it isn't counted again if appears more than twice in all } } if(RepeatCount > 0) { AnsiString MessageString = "Number " + AnsiString(CheckNumber) + " repeated " + AnsiString(RepeatCount) + " times in function " + FunctionString; if(Screen) { int button = Application->MessageBox(MessageString.c_str(), "", MB_OKCANCEL); if (button == IDCANCEL) { BreakFlag = true; return; } } if(Print) OutFile << MessageString.c_str() << CHAR(13) << CHAR(10); } } //now check for missing numbers if(CheckBox1->Checked) { int IncNumber = 0; bool FoundFlag=false; while(IncNumber <= MaxNumber) { FoundFlag = false; for(int x=0;x<MaxIndex + 1;x++) { if(MissingNumArray[x] == IncNumber) { FoundFlag = true; break; } } if(!FoundFlag) { AnsiString MessageString = "Number " + AnsiString(IncNumber) + " missing for function " + FunctionString; if(Screen) { int button = Application->MessageBox(MessageString.c_str(), "", MB_OKCANCEL); if (button == IDCANCEL) { BreakFlag = true; return; } } if(Print) OutFile << MessageString.c_str() << CHAR(13) << CHAR(10); } IncNumber++; } } FunctionCount++; }
const AnsiString & __fastcall AnsiString::operator +=(const AnsiString & rhs) { Data.append(rhs.c_str(), rhs.size()); return *this; }
//--------------------------------------------------------------------------- void __fastcall TFormClientRep::ProcHistory(bool All) { AnsiString Title = "ѕросмотр истории изменени¤"; AnsiString FldKey = WrkGData->FieldKey; AnsiString TableName = GetPiece(FldKey,"_ID",1).UpperCase(); int ID = WrkGData->WrkDSet->FieldByName(FldKey)->AsInteger; AnsiString FieldNames; AnsiString TitleNames; AnsiString SS; TDBGridEh* Grid = WrkGData->WrkGrid; TStringList* FieldNamesList = new TStringList(); TStringList* TitleNamesList = new TStringList(); AnsiString AllFieldNames; if (All) { TDBGridColumnsEh* Columns = Grid->Columns; int Cnt = Columns->Count; AnsiString S; bool KeyIncduded = true; for (int i = 0; i < Cnt; i++) { TColumnEh* Column = Columns->Items[i]; if (Column->Visible) { AnsiString X = ","+TranslateName(Column->FieldName); if (!AllFieldNames.Pos(X)) { AllFieldNames += X; FieldNames += X ; SS = Column->Title->Caption; TitleNames += "," + GetPiece(SS, "|",1); SS = GetPiece(SS, "|",2); if (SS != "") TitleNames += "-> " + SS; if (FieldNames.Length() > 230 || TitleNames.Length() > 200) { KeyIncduded = KeyIncduded || FieldNames.Pos("," + FldKey); FieldNames = FieldNames.SubString(2,1000); TitleNames = TitleNames.SubString(2,1000); FieldNames = FieldNames.UpperCase(); FieldNamesList->Add(FieldNames); TitleNamesList->Add(TitleNames); FieldNames = ""; TitleNames = ""; } } } } if (!KeyIncduded) { FieldNames = "," +FldKey + FieldNames + ",STATUS"; TitleNames = ",N записи" + TitleNames + ",—осто¤ние"; } else { FieldNames = FieldNames + ",STATUS"; TitleNames = TitleNames + ",—осто¤ние"; } FieldNames = FieldNames.SubString(2,1000); TitleNames = TitleNames.SubString(2,1000); FieldNames = FieldNames.UpperCase(); FieldNamesList->Add(FieldNames); TitleNamesList->Add(TitleNames); FieldNames = ""; TitleNames = ""; Title = Title + " всех видимых полей"; } else { TColumnEh* Column = Grid->Columns->Items[Grid->Col - 1]; FieldNames = TranslateName(Column->FieldName); SS = Column->Title->Caption; TitleNames = GetPiece(SS, "|",1); SS = GetPiece(SS, "|",2); if (SS != "") TitleNames += "-> " + SS; Title = Title + " пол¤ > "+ TitleNames + " <"; FieldNames = FieldNames.UpperCase(); FieldNamesList->Add(FieldNames); TitleNamesList->Add(TitleNames); } RestValue RestData; if (SimpleSelHistoryID(this, 0,Title,TableName,ID,FieldNamesList,TitleNamesList,RestData)) { // RestoreValue(RestData,!All); } }
// Заполнение информации по трудоёмкости по исполнителям void TController::fillVolume(int num) { if(vKHRList[num]->Works.size() != 0) { int allVolumes = 0; // число кварталов, которые идёт КХР // последняя дата работы - последний срок TDateTime end = Model->getLastDate(vKHRList[num]); // необходимо определить начало работы: квартал и год TDateTime begin = vKHRList[num]->dtStartDate; Word dyear, dmonth, dday; // данные для начала работы Word eyear, emonth, eday; // данные по окончанию КХР begin.DecodeDate(&dyear, &dmonth, &dday); end.DecodeDate(&eyear, &emonth, &eday); int begQ = Model->getQuart(StrToInt(dmonth)); // квартал начала работ int endQ = Model->getQuart(StrToInt(emonth)); // квартал окончания работ int kbeg = StrToInt(dyear); // год начала работ int kend = StrToInt(eyear); // год окончания работ if(kbeg==kend) allVolumes = endQ - begQ + 1; // если год совпадает else allVolumes = (4-begQ+1)/*год начала*/ + 4*(kend-kbeg-1) /*промежуточные года*/ + endQ /*последний год*/ ; DisplayManager->showVolumeRow(vKHRList[num]->Executors.size()+1, allVolumes+2); int currVol = begQ; int currYear = kbeg; // заполнение названий столбцов for (int i=0; i < allVolumes; i++) { AnsiString data = IntToStr(currVol); switch(currVol) { case 1: data = "I кв. "; break; case 2: data = "II кв. ";break; case 3: data = "III кв. ";break; case 4: data = "IV кв. ";break; default: break; } // data+="."; data+=IntToStr(currYear); currVol++; if(currVol>4) { currVol=1; currYear++; } DisplayManager->showVolume(i+1, 0, data.c_str()); } // для всех исполнителей for(int i=0; i<vKHRList[num]->Executors.size(); i++) { int sumVolume=0; // суммарная трудоёмкость для исполнителя currVol = begQ; currYear = kbeg; int id = vKHRList[num]->Executors[i]->id; string name = Model->execByID(vKHRList[num], id); DisplayManager->showVolume(0, i+1, name.c_str()); for (int j=0; j < allVolumes; j++) { float vol = Model->getExecVolume(vKHRList[num], id, currYear, currVol); sumVolume+=vol; currVol++; if(currVol>4) { currVol=1; currYear++; } DisplayManager->showVolume(j+1, i+1, FloatToStr(vol)); } DisplayManager->showVolume(allVolumes+1, i+1, FloatToStr(sumVolume)); } } }
//--------------------------------------------------------------------------- static double str2dbl(AnsiString str) { double val=0.0; sscanf(str.c_str(),"%lf",&val); return val; }
//--------------------------------------------------------------------------- bool __fastcall TFile::WriteString(AnsiString string) { return WriteString(string.c_str()); }
void __fastcall TMainForm::ButtonLoadClick(TObject *Sender) { if (OraQueryAllJournal->RecordCount == 0 || OraQueryDocs->RecordCount == 0) { ShowMessage ("Не выбран файл для загрузки !"); return; } Screen->Cursor = crHourGlass; AnsiString temp_dir; TRegistry * reg = new TRegistry (KEY_READ); try { reg->RootKey = HKEY_LOCAL_MACHINE; reg->OpenKey ("\\SOFTWARE\\Gis center\\Journal", true); temp_dir = reg->ReadString ("TempDir"); } __finally { safe_delete (reg); // delete reg; } if (temp_dir.IsEmpty()) { ShowMessage ("Не задана временная директория для выгрузки файлов !"); Screen->Cursor = crDefault; return; } ProgressForm->Show(); AnsiString fn; TOraQuery * docQuery = new TOraQuery (this); try { docQuery->SQL->Text = "SELECT DOC_NAME, DOC_TEXT FROM " + m_shema + "." + m_blob_table + " WHERE " + m_blob_primary_key + " = " + OraQueryDocs->Fields->FieldByName(m_blob_primary_key)->AsString; docQuery->Open(); docQuery->First(); fn = docQuery->Fields->FieldByName ("DOC_NAME")->AsString; TBlobField * blob = (TBlobField*)(docQuery->Fields->FieldByName("DOC_TEXT")); blob->SaveToFile (temp_dir + "\\" + fn); docQuery->Close(); } __finally { safe_delete (docQuery); //delete docQuery; } m_loading_docs [OraQueryDocs->Fields->FieldByName(m_blob_primary_key)->AsInteger] = temp_dir + "\\" + fn; ButtonSaveDoc->Enabled = true; Files.insert(temp_dir + "\\" + fn); // Проверка ассоциации AnsiString path; reg = new TRegistry (KEY_READ); try { reg->RootKey = HKEY_LOCAL_MACHINE; reg->OpenKey ("\\SOFTWARE\\Gis center\\Journal\\Associations", true); path = reg->ReadString (ExtractFileExt (fn).Delete(1, 1)); reg->CloseKey(); } __finally { safe_delete (reg); //delete reg; } if (!path.IsEmpty()) { STARTUPINFO si = {sizeof (si)}; PROCESS_INFORMATION pi; AnsiString dir = GetCurrentDir(); SetCurrentDir (temp_dir); if (CreateProcess (NULL, ("\"" + path + "\" \"" +fn + "\"").c_str(), 0, 0, FALSE, 0,0,0, &si, &pi)) { CloseHandle (pi.hThread); CloseHandle (pi.hProcess); } SetCurrentDir (dir); } else { ShellExecute(0, "open", AnsiString (temp_dir + "\\" + fn).c_str(), NULL, NULL, SW_SHOWNORMAL); } ProgressForm->Close(); Screen->Cursor = crDefault; }