当前位置: 首页>>代码示例>>C++>>正文


C++ TStringList::Delete方法代码示例

本文整理汇总了C++中TStringList::Delete方法的典型用法代码示例。如果您正苦于以下问题:C++ TStringList::Delete方法的具体用法?C++ TStringList::Delete怎么用?C++ TStringList::Delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TStringList的用法示例。


在下文中一共展示了TStringList::Delete方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: TStringList

void __fastcall TForm1::FileOpen1Accept(TObject *Sender)
{
String a = FileOpen1->Dialog->FileName;
if (a!=""){
// Öffnen
if (ExtractFileExt(a).UpperCase()!=".AD")a=a.SubString(1,a.Length()-ExtractFileExt(a).Length())+".ad";
TStringList *Liste = new TStringList();
Liste->LoadFromFile(a);

Max = StrToInt(Liste->Strings[0]);
Edit1->Text=Liste->Strings[1];
ListBox1->Clear();
Liste->Delete(0);
Liste->Delete(0);
for (int i=0;i<Max;i++){
ListBox1->Items->Add(Liste->Strings[i*67]);

for (int b=0;b<66;b++){
Data[i][b] = StrToInt(Liste->Strings[i*67 + b + 1]);
}
}
ListBox1->ItemIndex=0;
Selected = ListBox1->ItemIndex;
Load_Dat(Selected);
}
}
开发者ID:tilluhlig,项目名称:LED-Cube-Simulator,代码行数:26,代码来源:Unit1.cpp

示例2: RemoveFromList

void Defines::RemoveFromList(String keyList, String data)
{
        TStringList *s = GetList(keyList);
        if (s==0)
                return;
        int i=s->IndexOf(data);
        if (i>=0)
                s->Delete(i);
        SetList(keyList,s);
        delete s;
}
开发者ID:SpaceWind,项目名称:elo2kbuilder,代码行数:11,代码来源:defines.cpp

示例3: RemoveBookmark

//---------------------------------------------------------------------------
void __fastcall TLocationProfilesDialog::RemoveBookmark(TObject * Sender)
{
  TBookmarkList * BookmarkList = GetBookmarkList(Sender);
  TTreeView * ProfilesView = GetProfilesView(Sender);
  TStringList * Folders = GetFolders(Sender);

  assert(ProfilesView->Selected);
  TTreeNode * Node = ProfilesView->Selected;
  if (Node->Data)
  {
    BookmarkList->Delete((TBookmark *)Node->Data);
    TTreeNode * ParentNode = Node->Parent;
    Node->Delete();
    if (ParentNode && !ParentNode->Count)
    {
      assert(Folders->IndexOfObject(ParentNode) >= 0);
      Folders->Delete(Folders->IndexOfObject(ParentNode));
      ParentNode->Delete();
    }
  }
  else
  {
    UnicodeString Message = MainInstructions(LoadStr(DELETE_BOOKMARK_FOLDER));
    if (MessageDialog(Message, qtConfirmation,
          qaYes | qaNo, HELP_LOCATION_PROFILE_DELETE) == qaYes)
    {
      assert(Node->Count);
      for (int i = 0; i < Node->Count; i++)
      {
        BookmarkList->Delete((TBookmark *)Node->Item[i]->Data);
      }
      assert(Folders->IndexOfObject(Node) >= 0);
      Folders->Delete(Folders->IndexOfObject(Node));
      Node->Delete();
    }
  }
  UpdateControls();
}
开发者ID:elazzi,项目名称:winscp,代码行数:39,代码来源:LocationProfiles.cpp

示例4: BookmarkMove

//---------------------------------------------------------------------------
void __fastcall TLocationProfilesDialog::BookmarkMove(TObject * Sender,
  TTreeNode * Source, TTreeNode * Dest)
{
  TBookmarkList * BookmarkList = GetBookmarkList(Sender);
  TTreeView * ProfilesView = GetProfilesView(Sender);
  TStringList * Folders = GetFolders(Sender);

  assert(Source && Source->Data);

  TBookmark * Bookmark = (TBookmark *)Source->Data;
  TTreeNode * PrevFolderNode = Source->Parent;

  if (!Dest || !Dest->Data)
  {
    Bookmark->Node = Dest ? Dest->Text : UnicodeString();
    BookmarkList->MoveTo(BookmarkList->Bookmarks[BookmarkList->Count - 1],
      Bookmark, false);
    ProfilesView->Selected->MoveTo(Dest, naAddChild);
  }
  else
  {
    TBookmark * DestBookmark = (TBookmark *)Dest->Data;

    Bookmark->Node = DestBookmark->Node;
    BookmarkList->MoveTo(DestBookmark, Bookmark,
      Source->AbsoluteIndex > Dest->AbsoluteIndex);
    if (Source->AbsoluteIndex > Dest->AbsoluteIndex)
    {
      Source->MoveTo(Dest, naInsert);
    }
    else if (Dest->getNextSibling() != NULL)
    {
      Source->MoveTo(Dest->getNextSibling(), naInsert);
    }
    else
    {
      Source->MoveTo(Dest, naAdd);
    }
  }

  if (PrevFolderNode && !PrevFolderNode->Count)
  {
    assert(Folders->IndexOfObject(PrevFolderNode) >= 0);
    Folders->Delete(Folders->IndexOfObject(PrevFolderNode));
    PrevFolderNode->Delete();
  }

  Source->MakeVisible();
  UpdateControls();
}
开发者ID:elazzi,项目名称:winscp,代码行数:51,代码来源:LocationProfiles.cpp

示例5: LoadHexToRAM

bool __fastcall TMainForm::LoadHexToRAM(String fName, bool bLow)
{
  // Load all the text lines from the .hex file into a String List for easy
  // manipulation

  TStringList *sList = new TStringList;

  if (fName.Pos("VendAX")) {
    GetVendAX(sList);
  } else {
    TFileStream *srcStream = new TFileStream(fName,fmOpenRead | fmShareDenyWrite);
    if (srcStream == NULL) return false;
    sList->LoadFromStream(srcStream);
    delete srcStream;
  }


  String tmp;
  int v;

  // Delete non-data records
  for (int i=sList->Count - 1; i>=0; i--) {
    if (sList->Strings[i].Length()) {
      tmp = sList->Strings[i].SubString(8,2);   // Get the Record Type into v
      v = 0;  HexToBin(tmp.c_str(),(char *)&v,1); v *= 2;
      if (v) sList->Delete(i);                  // Data records are type == 0
    }
  }

  // Re-construct the strings to only contain the offset followed by the data
  for (int i=0; i<sList->Count; i++) {
    // Remove comments
    v = sList->Strings[i].Pos("//");
    if (v) sList->Strings[i].SetLength(v-1);

    // Build string that just contains the offset followed by the data bytes
    if (sList->Strings[i].Length()) {
      // Get the offset
      String sOffset = sList->Strings[i].SubString(4,4);

      // Get the string of data chars
      tmp = sList->Strings[i].SubString(2,2);
      v = 0;  HexToBin(tmp.c_str(),(char *)&v,1); v *= 2;
      String s = sList->Strings[i].SubString(10,v);

      // Replace the string in the list
      sList->Strings[i] = sOffset + s;
    }

  }

  if (bLow) ResetFX2(1);      // Stop the processor

  FX2Device->ControlEndPt->ReqCode = bLow ? 0xA0 : 0xA3;
  FX2Device->ControlEndPt->Index = 0;
  FX2Device->ControlEndPt->Value = 0;

  // Go through the list, loading data into RAM
  String DataString = "";
  WORD nxtoffset = 0;
  LONG xferLen = 0;

  WORD offset;
  int RamSize = 0x2000;  // 8KB

  UCHAR buf[MAX_CTLXFER_SIZE];

  char  c;
  PCHAR pc;

  for (int i=0; i<sList->Count; i++) {
    // Get the offset
    tmp = sList->Strings[i].SubString(1,4);
    HexToBin(tmp.c_str(),(char *)&offset,2);
    pc = (char *) &offset; c = pc[0]; pc[0]=pc[1]; pc[1]=c;  // Swap the bytes

    int sLen = sList->Strings[i].Length();

    // Handle a line that straddles the 8KB boundary
    int bytes = (sLen - 4)/2;
    LONG lastAddr = offset + bytes;

    // This case is the last segment to be sent to low memory
    if (bLow && (offset < RamSize) && (lastAddr > RamSize))
      bytes = RamSize - offset;

    // In this case, we found the first segment to be sent to the high memory
    if (!bLow && (offset < RamSize) && (lastAddr > RamSize)) {
      bytes = lastAddr - RamSize;
      String s = "xxxx"+sList->Strings[i].SubString(sLen - (bytes*2)+1,bytes*2);
      sList->Strings[i] = s;
      offset = RamSize;
    }

    if ((bLow &&  (offset < RamSize)) || // Below 8KB - internal RAM
       (!bLow && (offset >= RamSize)) ) {

      xferLen += bytes;

      if ((offset == nxtoffset) && (xferLen < MAX_CTLXFER_SIZE)) {
//.........这里部分代码省略.........
开发者ID:MarkN0,项目名称:HEXITEC-GSE,代码行数:101,代码来源:MainF.cpp

示例6: BeginJob

//执行任务
bool __fastcall BeginJob(
    int JobMode,              //工作模式.1:本地文件模式;2:FTP文件模式
    AnsiString ListFileName,  //列表文件名
    AnsiString BillName,      //话单类型名称
    AnsiString DBName,        //数据库连接名
    AnsiString TableName,     //表名
    AnsiString LogFileName,   //日志文件名
    AnsiString TempPath,      //临时目录
    bool TransFieldValue,     //是否对字段值进行翻译
    int  MaxError,            //导入时允许的最大错误数
    bool VerifyFile,          //是否对文件进行格式检查
    AnsiString FTPServer,     //已配置好的FTP服务器名称,FTP文件模式
    AnsiString DirList,       //取文件的目录列表
    int FTPRetryCount         //列FTP文件时允许的最大重试次数
    )
{
  SaveLog(("开始运行任务."\
          "\n话单类型:" + BillName +
          "\n数据库连接:" + DBName +
          "\n导入到表:" + TableName +
          "\n日志文件:" + LogFileName +
          "\n导入数据库允许的最大错误数:" + IntToStr(MaxError) + "\n"
          "\n临时文件放置在:" + TempPath + "驱动器\n"
          ).c_str());
  if(JobMode == 1)
  {
    SaveLog(("话单文件列表是" + ListFileName + ".\n").c_str());
  }
  else if(JobMode == 2)
  {
    SaveLog(("搜索目录列表是" + DirList + "\n" +
      "FTP服务器:" + FTPServer).c_str());
  }  
  bool Result = false;
  frmMain     = NULL;
  TStringList * FileList = NULL;
  TIdFTP      * IdFTP    = NULL;
  try
  {
    frmMain = new TfrmMain(Application);
    if(TempPath != "")
    {
      if(!DirectoryExists(TempPath) && !CreateDir(TempPath))
        SaveLog(("指定的临时文件夹无效,已改为使用默认的临时文件夹:" + frmMain->TempDirectory + "\n").c_str());
      else
      {
        if(TempPath.SubString(TempPath.Length(),1) != "\\")
          TempPath = TempPath + "\\";
        frmMain->TempDirectory = TempPath;
      }
    }
    if(!frmMain->DBConfig->IsDBNameExists(DBName))
      throw new Exception("在配置文件中找不到" + DBName + "的配置信息");
    frmExportToDB = new TfrmExportToDB(NULL);
    frmExportToDB->txtDBServer->Text = frmMain->DBConfig->GetDBAttributeValue(DBName,"Server");
    if(frmExportToDB->txtDBServer->Text == "")
      throw new Exception("没有为" + DBName + "配置服务器地址");
    frmExportToDB->cbxDBType->ItemIndex =
      frmExportToDB->cbxDBType->Items->IndexOf(
        frmMain->DBConfig->GetDBAttributeValue(DBName,"DBType"));
    if(frmExportToDB->cbxDBType->ItemIndex < 0)
    {
      throw new Exception("为" + DBName + "配置的数据库类型不正确");
    }
    FileList = new TStringList;
    if(JobMode == 1)
    {
      FileList->LoadFromFile(ListFileName);
      for(int n = FileList->Count - 1;n > -1;n--)
      {
        if(FileList->Strings[n] == "")
          FileList->Delete(n);
      }
    }
    else  //FTP模式
    {
      if(!frmMain->FTPConfig->IsFTPNameExists(FTPServer))
      {
        throw new Exception("在FTP配置文件中找不到指定的FTP服务器");
      }
      IdFTP = new TIdFTP(NULL);
      IdFTP->Host = frmMain->FTPConfig->GetFTPAttributeValue(FTPServer,"Server");
      try
      {
        IdFTP->Port = StrToInt(frmMain->FTPConfig->GetFTPAttributeValue(FTPServer,"Port"));
      }
      catch(...)
      {
        IdFTP->Port = 21;
      }
      IdFTP->Username = frmMain->FTPConfig->GetFTPAttributeValue(FTPServer,"UserName");
      IdFTP->Password = frmMain->FTPConfig->GetFTPAttributeValue(FTPServer,"Password",true);
      IdFTP->Passive  = frmMain->FTPConfig->GetFTPAttributeValue(FTPServer,"Mode").UpperCase() == "PASV";
      AnsiString FTPString  = "ftp://" +
        frmMain->FTPConfig->EncryFTPString(IdFTP->Username) + ":" +
        frmMain->FTPConfig->EncryFTPString(IdFTP->Password) + "@" + IdFTP->Host + ":" + IntToStr(IdFTP->Port);
      AnsiString PasvString;
      if(IdFTP->Passive)
        PasvString = "|PASV|";
//.........这里部分代码省略.........
开发者ID:josecohenca,项目名称:xmlconvertsql,代码行数:101,代码来源:ibill.cpp


注:本文中的TStringList::Delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。