本文整理汇总了C++中AnsiString::sprintf方法的典型用法代码示例。如果您正苦于以下问题:C++ AnsiString::sprintf方法的具体用法?C++ AnsiString::sprintf怎么用?C++ AnsiString::sprintf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnsiString
的用法示例。
在下文中一共展示了AnsiString::sprintf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateBins
//---------------------------------------------------------------------------
void TForm2D::DataPrepare()
{
m_setval = 0;
m_val_n = 0;
AnsiString as;
//range of grid values must be slightly wider...
Chart1->LeftAxis->Maximum = m_fnc_max;
Chart1->LeftAxis->Minimum = m_fnc_min;
Chart1->Title->Text->Clear();
Chart1->Title->Text->Add(m_chart_title_text);
Chart1->LeftAxis->Title->Caption = m_y_axis_title;
Chart1->BottomAxis->Title->Caption = m_x_axis_title;
for(int i = 0; i < m_count_of_function_points; i++)
{
if (m_horizontal_axis_grid_mode < 2) //0,1 modes
as.sprintf(m_horizontal_axis_values_format.c_str(), m_horizontal_axis_grid_values[i]);
else //mode 2
as.sprintf(m_horizontal_axis_values_format.c_str(), mp_modified_function[i+m_count_of_function_points]);
Series1->Add(mp_original_function[i], as, clAqua);
Series2->Add(mp_modified_function[i], as, clRed);
}
if (2==m_horizontal_axis_grid_mode)
UpdateBins();
}
示例2: BtnLoadClick
//---------------------------------------------------------------------------
void __fastcall TPntDialog::BtnLoadClick(TObject *Sender)
{
AnsiString s;
FILE *fp;
char buff[256],name[256];
double pos[3];
int i=0;
if (!OpenDialog->Execute()) return;
if (!(fp=fopen(OpenDialog->FileName.c_str(),"r"))) return;
while (fgets(buff,sizeof(buff),fp)&&i<PntList->RowCount) {
if (buff[0]=='#') continue;
if (sscanf(buff,"%lf %lf %lf %s",pos,pos+1,pos+2,name)<4) continue;
PntList->Cells[0][i]=s.sprintf("%.9f",pos[0]);
PntList->Cells[1][i]=s.sprintf("%.9f",pos[1]);
PntList->Cells[2][i]=s.sprintf("%.4f",pos[2]);
PntList->Cells[3][i++]=name;
}
for (;i<PntList->RowCount;i++) {
PntList->Cells[0][i]="";
PntList->Cells[1][i]="";
PntList->Cells[2][i]="";
PntList->Cells[3][i]="";
}
fclose(fp);
}
示例3: GetExtErrOpt
//---------------------------------------------------------------------------
void __fastcall TExtOptDialog::GetExtErrOpt(void)
{
TEdit *editc[][6]= {
{CodeErr00,CodeErr01,CodeErr02,CodeErr03,CodeErr04,CodeErr05},
{CodeErr10,CodeErr11,CodeErr12,CodeErr13,CodeErr14,CodeErr15},
{CodeErr20,CodeErr21,CodeErr22,CodeErr23,CodeErr24,CodeErr25}
};
TEdit *editp[][6]= {
{PhaseErr00,PhaseErr01,PhaseErr02,PhaseErr03,PhaseErr04,PhaseErr05},
{PhaseErr10,PhaseErr11,PhaseErr12,PhaseErr13,PhaseErr14,PhaseErr15},
{PhaseErr20,PhaseErr21,PhaseErr22,PhaseErr23,PhaseErr24,PhaseErr25}
};
AnsiString s;
ExtEna0->Checked=OptDialog->ExtErr.ena[0];
ExtEna1->Checked=OptDialog->ExtErr.ena[1];
ExtEna2->Checked=OptDialog->ExtErr.ena[2];
ExtEna3->Checked=OptDialog->ExtErr.ena[3];
for (int i=0; i<3; i++) for (int j=0; j<6; j++) {
editc[i][j]->Text=s.sprintf("%.3f",OptDialog->ExtErr.cerr[i][j]);
editp[i][j]->Text=s.sprintf("%.3f",OptDialog->ExtErr.perr[i][j]);
}
GpsGloB0->Text=s.sprintf("%.3f",OptDialog->ExtErr.gpsglob[0]);
GpsGloB1->Text=s.sprintf("%.3f",OptDialog->ExtErr.gpsglob[1]);
GloICB0->Text=s.sprintf("%.3f",OptDialog->ExtErr.gloicb[0]);
GloICB1->Text=s.sprintf("%.3f",OptDialog->ExtErr.gloicb[1]);
}
示例4: SearchFile
//---------------------------------------------------------------------------
bool __fastcall CIniFile::SearchFile(AnsiString strBarCode,AnsiString &strFileName)
{
WIN32_FIND_DATA FindFileData;
AnsiString strName;
char *pFileName;
TIniFile *pIniFile;
bool bResult=false;
strName.sprintf("%s*.ini",IniFile_Dir);
HANDLE hFile=FindFirstFile(strName.c_str(),&FindFileData);
if(hFile!=INVALID_HANDLE_VALUE)
{
while(FindNextFile(hFile,&FindFileData)!=0)
{
pFileName=FindFileData.cFileName;
strName.sprintf("%s%s",IniFile_Dir,pFileName);
pIniFile = new TIniFile(strName);
AnsiString strCode=pIniFile->ReadString(Product_Section,"BarCode","0000");
delete pIniFile;
if(strCode==strBarCode)
{
strFileName=strName;
bResult=true;
break;
}
}
FindClose(hFile);
}
return bResult;
}
示例5: StoreHistory
//---------------------------------------------------------------------------
void __fastcall CIniFile::StoreHistory(int nYear,int nMonth,int nDate,AnsiString strMessage)
{
AnsiString strFileName;
TIniFile *pIniFile;
int nFileMonth,nIndex;
strFileName.sprintf("%s\\Message History\\%4d_%02d_%02d.ini",IniFile_Dir,nYear,nMonth,nDate);
pIniFile = new TIniFile(strFileName);
nFileMonth=pIniFile->ReadInteger("Control","Month",1);
nIndex=pIniFile->ReadInteger("Control","Index",1);
if(nFileMonth!=nMonth)
{
nIndex=1;
pIniFile->WriteInteger("Control","Month",nMonth);
}
AnsiString strID;
strID.sprintf("No%08d",nIndex);
pIniFile->WriteString("History",strID,strMessage);
nIndex++;
strID.sprintf("No%08d",nIndex);
pIniFile->WriteString("History",strID,"//-------------以下做作廢--------------------//");
pIniFile->WriteInteger("Control","Index",nIndex);
delete pIniFile;
}
示例6: UpdateObsType
// update observation type pull-down menu --------------------------------------
void __fastcall TPlot::UpdateObsType(void)
{
AnsiString s;
char *codes[MAXCODE+1],freqs[]="125678";
int i,j,n=0,cmask[MAXCODE+1]={0},fmask[6]={0};
trace(3,"UpdateObsType\n");
for (i=0;i<Obs.n;i++) for (j=0;j<NFREQ+NEXOBS;j++) {
cmask[Obs.data[i].code[j]]=1;
}
for (i=1;i<=MAXCODE;i++) {
if (!cmask[i]) continue;
codes[n++]=code2obs(i,&j);
fmask[j-1]=1;
}
ObsType ->Items->Clear();
ObsType2->Items->Clear();
ObsType ->Items->Add("ALL");
for (i=0;i<6;i++) {
if (!fmask[i]) continue;
ObsType ->Items->Add(s.sprintf("L%c",freqs[i]));
ObsType2->Items->Add(s.sprintf("L%c",freqs[i]));
}
for (i=0;i<n;i++) {
ObsType ->Items->Add(s.sprintf("L%s",codes[i]));
ObsType2->Items->Add(s.sprintf("L%s",codes[i]));
}
ObsType ->ItemIndex=0;
ObsType2->ItemIndex=0;
}
示例7: UpdateField
//---------------------------------------------------------------------------
void __fastcall TSkyImgDialog::UpdateField(void)
{
AnsiString s;
Caption=Plot->SkyImageFile;
SkySize1->Text=s.sprintf("%d",Plot->SkySize[0]);
SkySize2->Text=s.sprintf("%d",Plot->SkySize[1]);
SkyCent1->Text=s.sprintf("%.2f",Plot->SkyCent[0]);
SkyCent2->Text=s.sprintf("%.2f",Plot->SkyCent[1]);
SkyScale->Text=s.sprintf("%.2f",Plot->SkyScale);
SkyFov1 ->Text=s.sprintf("%.2f",Plot->SkyFov[0]);
SkyFov2 ->Text=s.sprintf("%.2f",Plot->SkyFov[1]);
SkyFov3 ->Text=s.sprintf("%.2f",Plot->SkyFov[2]);
SkyDest1->Text=s.sprintf("%.1f",Plot->SkyDest[1]);
SkyDest2->Text=s.sprintf("%.1f",Plot->SkyDest[2]);
SkyDest3->Text=s.sprintf("%.1f",Plot->SkyDest[3]);
SkyDest4->Text=s.sprintf("%.1f",Plot->SkyDest[4]);
SkyDest5->Text=s.sprintf("%.1f",Plot->SkyDest[5]);
SkyDest6->Text=s.sprintf("%.1f",Plot->SkyDest[6]);
SkyDest7->Text=s.sprintf("%.1f",Plot->SkyDest[7]);
SkyDest8->Text=s.sprintf("%.1f",Plot->SkyDest[8]);
SkyDest9->Text=s.sprintf("%.1f",Plot->SkyDest[9]);
SkyElMask->Checked=Plot->SkyElMask;
SkyDestCorr->Checked=Plot->SkyDestCorr;
SkyRes->ItemIndex=Plot->SkyRes;
SkyFlip->Checked=Plot->SkyFlip;
}
示例8: FormShow
//---------------------------------------------------------------------------
void __fastcall TPntDialog::FormShow(TObject *Sender)
{
TGridRect r={0};
AnsiString s;
double pos[3];
int width[]={90,90,80,90};
FontScale=Screen->PixelsPerInch;
for (int i=0;i<4;i++) {
PntList->ColWidths[i]=width[i]*FontScale/96;
}
PntList->DefaultRowHeight=17*FontScale/96;
for (int i=0;i<PntList->RowCount;i++) {
if (i<Plot->NWayPnt) {
ecef2pos(Plot->PntPos[i],pos);
PntList->Cells[0][i]=s.sprintf("%.9f",pos[0]*R2D);
PntList->Cells[1][i]=s.sprintf("%.9f",pos[1]*R2D);
PntList->Cells[2][i]=s.sprintf("%.4f",pos[2]);
PntList->Cells[3][i]=Plot->PntName[i];
}
else {
for (int j=0;j<PntList->ColCount;j++) PntList->Cells[j][i]="";
}
}
r.Top=r.Bottom=PntList->RowCount;
PntList->Selection=r;
}
示例9: GenerateObjectName
void CFolderHelper::GenerateObjectName(TElTree* tv, TElTreeItem* node, AnsiString& name,AnsiString pref, bool num_first)
{
int cnt = 0;
if (num_first) name.sprintf("%s_%02d",pref,cnt++); else name = pref;
while (FindItemInFolder(TYPE_OBJECT,tv,node,name))
name.sprintf("%s_%02d",pref,cnt++);
}
示例10:
void SPBItem::GetInfo (AnsiString& txt, float& p, float& m)
{
if (info.size())txt.sprintf("%s (%s)",text.c_str(),info.c_str());
else txt.sprintf("%s",text.c_str());
p = progress;
m = max;
}
示例11: Connect
// connect to external sources ----------------------------------------------
void __fastcall TPlot::Connect(void)
{
AnsiString s;
char *cmd,*path,buff[MAXSTRPATH],*name[2]={"",""},*p;
int i,mode=STR_MODE_R;
trace(3,"Connect\n");
if (ConnectState) return;
for (i=0;i<2;i++) {
if (RtStream[i]==STR_NONE ) continue;
else if (RtStream[i]==STR_SERIAL ) path=StrPaths[i][0].c_str();
else if (RtStream[i]==STR_FILE ) path=StrPaths[i][2].c_str();
else if (RtStream[i]<=STR_NTRIPCLI) path=StrPaths[i][1].c_str();
else continue;
if (RtStream[i]==STR_FILE||!SolData[i].cyclic||SolData[i].nmax!=RtBuffSize+1) {
Clear();
initsolbuf(SolData+i,1,RtBuffSize+1);
}
if (RtStream[i]==STR_SERIAL) mode|=STR_MODE_W;
strcpy(buff,path);
if ((p=strstr(buff,"::"))) *p='\0';
if ((p=strstr(buff,"/:"))) *p='\0';
if ((p=strstr(buff,"@"))) name[i]=p+1; else name[i]=buff;
if (!stropen(Stream+i,RtStream[i],mode,path)) {
ShowMsg(s.sprintf("connect error: %s",name));
ShowLegend(NULL);
trace(1,"stream open error: ch=%d type=%d path=%s\n",i+1,RtStream[i],path);
continue;
}
strsettimeout(Stream+i,RtTimeOutTime,RtReConnTime);
if (StrCmdEna[i][0]) {
cmd=StrCmds[i][0].c_str();
strwrite(Stream+i,(unsigned char *)cmd,strlen(cmd));
}
ConnectState=1;
}
if (!ConnectState) return;
if (Title!="") Caption=Title;
else Caption=s.sprintf("CONNECT %s %s",name[0],name[1]);
BtnConnect->Down=true;
BtnSol1 ->Down=*name[0];
BtnSol2 ->Down=*name[1];
BtnSol12 ->Down=false;
BtnShowTrack->Down=true;
BtnFixHoriz->Down=true;
UpdateEnable();
UpdateTime();
UpdatePlot();
}
示例12: ReadObsRnx
// read observation data rinex ----------------------------------------------
int __fastcall TPlot::ReadObsRnx(TStrings *files, obs_t *obs, nav_t *nav,
sta_t *sta)
{
AnsiString s;
gtime_t ts,te;
double tint;
int i;
char obsfile[1024],navfile[1024],*p,*opt=RnxOpts.c_str();
trace(3,"ReadObsRnx\n");
TimeSpan(&ts,&te,&tint);
for (i=0;i<files->Count;i++) {
strcpy(obsfile,U2A(files->Strings[i]).c_str());
ShowMsg(s.sprintf("reading obs data... %s",obsfile));
Application->ProcessMessages();
if (readrnxt(obsfile,1,ts,te,tint,opt,obs,nav,sta)<0) {
ShowMsg("error: insufficient memory");
return -1;
}
}
ShowMsg("reading nav data...");
Application->ProcessMessages();
for (i=0;i<files->Count;i++) {
strcpy(navfile,U2A(files->Strings[i]).c_str());
if (!(p=strrchr(navfile,'.'))) continue;
if (!strcmp(p,".obs")||!strcmp(p,".OBS")) {
strcpy(p,".nav" ); readrnxt(navfile,1,ts,te,tint,opt,NULL,nav,NULL);
strcpy(p,".gnav"); readrnxt(navfile,1,ts,te,tint,opt,NULL,nav,NULL);
strcpy(p,".hnav"); readrnxt(navfile,1,ts,te,tint,opt,NULL,nav,NULL);
strcpy(p,".qnav"); readrnxt(navfile,1,ts,te,tint,opt,NULL,nav,NULL);
strcpy(p,".lnav"); readrnxt(navfile,1,ts,te,tint,opt,NULL,nav,NULL);
}
else if (!strcmp(p+3,"o" )||!strcmp(p+3,"d" )||
!strcmp(p+3,"O" )||!strcmp(p+3,"D" )) {
strcpy(p+3,"N"); readrnxt(navfile,1,ts,te,tint,opt,NULL,nav,NULL);
strcpy(p+3,"G"); readrnxt(navfile,1,ts,te,tint,opt,NULL,nav,NULL);
strcpy(p+3,"H"); readrnxt(navfile,1,ts,te,tint,opt,NULL,nav,NULL);
strcpy(p+3,"Q"); readrnxt(navfile,1,ts,te,tint,opt,NULL,nav,NULL);
strcpy(p+3,"L"); readrnxt(navfile,1,ts,te,tint,opt,NULL,nav,NULL);
strcpy(p+3,"P"); readrnxt(navfile,1,ts,te,tint,opt,NULL,nav,NULL);
}
}
if (obs->n<=0) {
ShowMsg(s.sprintf("no observation data: %s...",files->Strings[0].c_str()));
freenav(nav,0xFF);
return 0;
}
uniqnav(nav);
return sortobs(obs);
}
示例13: FormShow
//---------------------------------------------------------------------------
void __fastcall TConvOptDialog::FormShow(TObject *Sender)
{
AnsiString s;
RnxVer->ItemIndex=MainWindow->RnxVer;
RnxFile->Checked=MainWindow->RnxFile;
RnxCode->Text=MainWindow->RnxCode;
RunBy->Text=MainWindow->RunBy;
Marker->Text=MainWindow->Marker;
MarkerNo->Text=MainWindow->MarkerNo;
MarkerType->Text=MainWindow->MarkerType;
Name0->Text=MainWindow->Name[0];
Name1->Text=MainWindow->Name[1];
Rec0->Text=MainWindow->Rec[0];
Rec1->Text=MainWindow->Rec[1];
Rec2->Text=MainWindow->Rec[2];
Ant0->Text=MainWindow->Ant[0];
Ant1->Text=MainWindow->Ant[1];
Ant2->Text=MainWindow->Ant[2];
AppPos0->Text=s.sprintf("%.4f",MainWindow->AppPos[0]);
AppPos1->Text=s.sprintf("%.4f",MainWindow->AppPos[1]);
AppPos2->Text=s.sprintf("%.4f",MainWindow->AppPos[2]);
AntDel0->Text=s.sprintf("%.4f",MainWindow->AntDel[0]);
AntDel1->Text=s.sprintf("%.4f",MainWindow->AntDel[1]);
AntDel2->Text=s.sprintf("%.4f",MainWindow->AntDel[2]);
Comment0->Text=MainWindow->Comment[0];
Comment1->Text=MainWindow->Comment[1];
RcvOption->Text=MainWindow->RcvOption;
for (int i=0;i<6;i++) CodeMask[i]=MainWindow->CodeMask[i];
AutoPos->Checked=MainWindow->AutoPos;
ScanObs->Checked=MainWindow->ScanObs;
OutIono->Checked=MainWindow->OutIono;
OutTime->Checked=MainWindow->OutTime;
OutLeaps->Checked=MainWindow->OutLeaps;
Nav1->Checked=MainWindow->NavSys&SYS_GPS;
Nav2->Checked=MainWindow->NavSys&SYS_GLO;
Nav3->Checked=MainWindow->NavSys&SYS_GAL;
Nav4->Checked=MainWindow->NavSys&SYS_QZS;
Nav5->Checked=MainWindow->NavSys&SYS_SBS;
Nav6->Checked=MainWindow->NavSys&SYS_CMP;
Obs1->Checked=MainWindow->ObsType&OBSTYPE_PR;
Obs2->Checked=MainWindow->ObsType&OBSTYPE_CP;
Obs3->Checked=MainWindow->ObsType&OBSTYPE_DOP;
Obs4->Checked=MainWindow->ObsType&OBSTYPE_SNR;
Freq1->Checked=MainWindow->FreqType&FREQTYPE_L1;
Freq2->Checked=MainWindow->FreqType&FREQTYPE_L2;
Freq3->Checked=MainWindow->FreqType&FREQTYPE_L5;
Freq4->Checked=MainWindow->FreqType&FREQTYPE_L6;
Freq5->Checked=MainWindow->FreqType&FREQTYPE_L7;
Freq6->Checked=MainWindow->FreqType&FREQTYPE_L8;
ExSats->Text=MainWindow->ExSats;
TraceLevel->ItemIndex=MainWindow->TraceLevel;
UpdateEnable();
}
示例14: StoreHistoryNew
//---------------------------------------------------------------------------
void __fastcall CIniFile::StoreHistoryNew()
{
AnsiString strFileName;
TIniFile *pIniFile;
int nFileMonth,nIndex;
time_t timer;
struct tm *tblock;
int nSize=m_vecMsg.size();
if(nSize==0) return;
AnsiString strMsg;
strMsg.sprintf("訊息共有 %d 筆\n每筆花費時間約 10 ms\n是否要儲存訊息??",nSize);
if(Application->MessageBoxA(strMsg.c_str(),"Confirm",MB_ICONQUESTION|MB_OKCANCEL)!=IDOK) return;
/* gets time of day */
timer = time(NULL);
/* converts date/time to a structure */
tblock = localtime(&timer);
int nMonth=tblock->tm_mon;
int nDate=tblock->tm_mday;
strFileName.sprintf("%s\\Message History\\%d.ini",IniFile_Dir,nDate);
pIniFile = new TIniFile(strFileName);
nFileMonth=pIniFile->ReadInteger("Control","Month",1);
nIndex=pIniFile->ReadInteger("Control","Index",1);
if(nFileMonth!=nMonth)
{
DeleteFile(strFileName);
nIndex=1;
pIniFile->WriteInteger("Control","Month",nMonth);
}
AnsiString strID;
for(int nSz=0;nSz<nSize;nSz++)
{
strID.sprintf("No%08d",nIndex);
pIniFile->WriteString("History",strID,m_vecMsg[nSz]);
nIndex++;
}
m_vecMsg.clear();
strID.sprintf("No%08d",nIndex);
pIniFile->WriteString("History",strID,"//-------------以下做作廢--------------------//");
pIniFile->WriteInteger("Control","Index",nIndex);
delete pIniFile;
}
示例15: FloatTimeToStrTime
AnsiString FloatTimeToStrTime(float v, bool _h, bool _m, bool _s, bool _ms)
{
AnsiString buf = "";
int h = 0, m = 0, s = 0, ms;
AnsiString t;
if (_h) { h = iFloor(v / 3600); t.sprintf("%02d", h); buf += t; }
if (_m) { m = iFloor((v - h * 3600) / 60); t.sprintf("%02d", m); buf += buf.IsEmpty() ? t : ":" + t; }
if (_s) { s = iFloor(v - h * 3600 - m * 60); t.sprintf("%02d", s); buf += buf.IsEmpty() ? t : ":" + t; }
if (_ms) { ms = iFloor((v - h * 3600 - m * 60 - s)*1000.f); t.sprintf("%03d", ms); buf += buf.IsEmpty() ? t : "." + t; }
return buf;
}