2015-03-09 5 views
-2

Я довольно новичок в создании скриптов через окна. Возможно, мне даже нужно что-то другое, кроме скрипта. Я сделал некоторые подобные вещи в linux, используя sed с файлом csv, но я хочу создать файл сценария .bat (или что-то подобное), который будет использоваться в файле заголовка c и удалить все завершающие пробелы..bat скрипт для удаления конечных пробелов

редактировать Причина: (Мой Svn репо не позволяет завершающим пробела и при работе с C++ UI Form добавляет комментарии с завершающими пробелами каждый раз, когда я добавить новый объект, как кнопка, например)

редактировать: это происходит после того, как эти комментарии, показанные ниже

 "// 
     // outputStringsTab 
     // " 

пример Snippit:

#pragma region Windows Form Designer generated code 
     /// <summary> 
     /// Required method for Designer support - do not modify 
     /// the contents of this method with the code editor. 
     /// </summary> 
     void InitializeComponent(void) 
     { 
     this->tabCollection = (gcnew System::Windows::Forms::TabControl()); 
     this->outputStringsTab = (gcnew System::Windows::Forms::TabPage()); 
     this->justificationComboBox = (gcnew System::Windows::Forms::ComboBox()); 
     this->stringSizeDropBox = (gcnew System::Windows::Forms::ComboBox()); 
     this->stringFontLabel = (gcnew System::Windows::Forms::Label()); 
     this->label7 = (gcnew System::Windows::Forms::Label()); 
     this->stringSizeLabel = (gcnew System::Windows::Forms::Label()); 
     this->stringBackgroundLabel = (gcnew System::Windows::Forms::Label()); 
     this->fontCheckListBox = (gcnew System::Windows::Forms::CheckedListBox()); 
     this->greenRadio = (gcnew System::Windows::Forms::RadioButton()); 
     this->blueRadio = (gcnew System::Windows::Forms::RadioButton()); 
     this->whiteRadio = (gcnew System::Windows::Forms::RadioButton()); 
     this->blackRadio = (gcnew System::Windows::Forms::RadioButton()); 
     this->label4 = (gcnew System::Windows::Forms::Label()); 
     this->label3 = (gcnew System::Windows::Forms::Label()); 
     this->label2 = (gcnew System::Windows::Forms::Label()); 
     this->label1 = (gcnew System::Windows::Forms::Label()); 
     this->shapePage = (gcnew System::Windows::Forms::TabPage()); 
     this->circleAngleGroupBox = (gcnew System::Windows::Forms::GroupBox()); 
     this->circleAngleLabel = (gcnew System::Windows::Forms::Label()); 
     this->circleAngleStartTextBox = (gcnew System::Windows::Forms::TextBox()); 
     this->circleAngleEndTextBox = (gcnew System::Windows::Forms::TextBox()); 
     this->circleAngleButton = (gcnew System::Windows::Forms::Button()); 
     this->startAngleLabel = (gcnew System::Windows::Forms::Label()); 
     this->degreesLabel2 = (gcnew System::Windows::Forms::Label()); 
     this->endAngleLabel = (gcnew System::Windows::Forms::Label()); 
     this->degreesLabel1 = (gcnew System::Windows::Forms::Label()); 
     this->lineSuppresionGroupBox = (gcnew System::Windows::Forms::GroupBox()); 
     this->squareLineLabel = (gcnew System::Windows::Forms::Label()); 
     this->noneSuppressRadio = (gcnew System::Windows::Forms::RadioButton()); 
     this->topSuppressRadio = (gcnew System::Windows::Forms::RadioButton()); 
     this->bottomSuppressRadio = (gcnew System::Windows::Forms::RadioButton()); 
     this->leftSuppressRadio = (gcnew System::Windows::Forms::RadioButton()); 
     this->rightSuppressRadio = (gcnew System::Windows::Forms::RadioButton()); 
     this->sizeGroupBox = (gcnew System::Windows::Forms::GroupBox()); 
     this->circleRadioButton = (gcnew System::Windows::Forms::RadioButton()); 
     this->shapesHeightWidthLabel = (gcnew System::Windows::Forms::Label()); 
     this->squareRadioButton = (gcnew System::Windows::Forms::RadioButton()); 
     this->heightTextBox = (gcnew System::Windows::Forms::TextBox()); 
     this->heightLabel = (gcnew System::Windows::Forms::Label()); 
     this->sizeSendButton = (gcnew System::Windows::Forms::Button()); 
     this->widthLabel = (gcnew System::Windows::Forms::Label()); 
     this->widthTextBox = (gcnew System::Windows::Forms::TextBox()); 
     this->gaugeTabPage = (gcnew System::Windows::Forms::TabPage()); 
     this->gaugeValueGroupBox = (gcnew System::Windows::Forms::GroupBox()); 
     this->barValueRadioButton = (gcnew System::Windows::Forms::RadioButton()); 
     this->label5 = (gcnew System::Windows::Forms::Label()); 
     this->meterValueRadioButton = (gcnew System::Windows::Forms::RadioButton()); 
     this->label6 = (gcnew System::Windows::Forms::Label()); 
     this->arcValueRadioButton = (gcnew System::Windows::Forms::RadioButton()); 
     this->gaugeValueTrackBar = (gcnew System::Windows::Forms::TrackBar()); 
     this->trackBarLabel = (gcnew System::Windows::Forms::Label()); 
     this->tabCollection->SuspendLayout(); 
     this->outputStringsTab->SuspendLayout(); 
     this->shapePage->SuspendLayout(); 
     this->circleAngleGroupBox->SuspendLayout(); 
     this->lineSuppresionGroupBox->SuspendLayout(); 
     this->sizeGroupBox->SuspendLayout(); 
     this->gaugeTabPage->SuspendLayout(); 
     this->gaugeValueGroupBox->SuspendLayout(); 
     (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->gaugeValueTrackBar))->BeginInit(); 
     this->SuspendLayout(); 
     // 
     // tabCollection 
     // 
     this->tabCollection->Controls->Add(this->outputStringsTab); 
     this->tabCollection->Controls->Add(this->shapePage); 
     this->tabCollection->Controls->Add(this->gaugeTabPage); 
     this->tabCollection->Location = System::Drawing::Point(12, 12); 
     this->tabCollection->Name = L"tabCollection"; 
     this->tabCollection->SelectedIndex = 0; 
     this->tabCollection->Size = System::Drawing::Size(827, 396); 
     this->tabCollection->TabIndex = 0; 
     // 
     // outputStringsTab 
     // 
     this->outputStringsTab->BackColor = System::Drawing::Color::White; 
     this->outputStringsTab->Controls->Add(this->justificationComboBox); 
     this->outputStringsTab->Controls->Add(this->stringSizeDropBox); 
     this->outputStringsTab->Controls->Add(this->stringFontLabel); 
     this->outputStringsTab->Controls->Add(this->label7); 
     this->outputStringsTab->Controls->Add(this->stringSizeLabel); 
     this->outputStringsTab->Controls->Add(this->stringBackgroundLabel); 
     this->outputStringsTab->Controls->Add(this->fontCheckListBox); 
     this->outputStringsTab->Controls->Add(this->greenRadio); 
     this->outputStringsTab->Controls->Add(this->blueRadio); 
     this->outputStringsTab->Controls->Add(this->whiteRadio); 
     this->outputStringsTab->Controls->Add(this->blackRadio); 
     this->outputStringsTab->Controls->Add(this->label4); 
     this->outputStringsTab->Controls->Add(this->label3); 
     this->outputStringsTab->Controls->Add(this->label2); 
     this->outputStringsTab->Controls->Add(this->label1); 
     this->outputStringsTab->Location = System::Drawing::Point(4, 22); 
     this->outputStringsTab->Name = L"outputStringsTab"; 
     this->outputStringsTab->Padding = System::Windows::Forms::Padding(3); 
     this->outputStringsTab->Size = System::Drawing::Size(819, 370); 
     this->outputStringsTab->TabIndex = 0; 
     this->outputStringsTab->Text = L"Output Strings"; 
     // 
     // justificationComboBox 
     // 
     this->justificationComboBox->FormattingEnabled = true; 
     this->justificationComboBox->Items->AddRange(gcnew cli::array<System::Object^>(3) { L"Left", L"Middle", L"Right" }); 

... и т.д.

+0

Почему это проблема C или C++? Я предлагаю удалить теги C и C++, так как вы говорите о пакетном файле, используя язык сценариев MSDOS. –

+0

My Svn repo не позволяет заканчивать пробелы, а при работе с формой C++ UI он добавляет комментарии с завершающим пробелом каждый раз, когда я добавляю новый объект, например, например, с помощью кнопки – user3542604

+0

. Если бы это было о C или C++, вы бы представить нам программу C или C++, которая обрезает конечное пробел. –

ответ

0

Пакетные скрипты Windows не предоставляют полный язык программирования Turing и в основном используются именно для того, что подразумевается в названии - объединение нескольких команд (которые вы в противном случае выполняли бы из командной строки). Современная Windows предлагает большое количество расширений в пакетных файлах MS-DOS, но она по-прежнему не является подходящим инструментом для выполнения ваших запросов.

В настоящее время Windows включает PowerShell в качестве альтернативы базовому процессору командной строки и пакетным файлам; вам может быть лучше использовать это, но goven, что вы, по-видимому, работаете с C и C++, будет достаточно простым, чтобы написать свою собственную утилиту на языках, которые вы уже знакомы, возможно?

0

TrimSpace

filter ts {l|r|lr|lc count} 

Планки начальные и конечные пробелы в строке.

l - удаляет ведущие пространства.

r - удаляет конечные пробелы.

lr - удаляет ведущие и конечные пробелы.

lc - удаляет <count> ведущие пространства.

Пример

затруднительных win.ini, не то, что ему необходимо фиксации, и посылает его на экран

filter trimspace lc 5 <"%systemroot%\win.ini" 

VBS скрипт

Set Arg = WScript.Arguments 
set WshShell = createObject("Wscript.Shell") 
Set Inp = WScript.Stdin 
Set Outp = Wscript.Stdout 

If LCase(Arg(1)) = "l" then 
    Do Until Inp.AtEndOfStream 
     Line=Inp.readline 
     outp.writeline LTrim(Line) 
    Loop 
ElseIf LCase(Arg(1)) = "r" then 
    Do Until Inp.AtEndOfStream 
     Line=Inp.readline 
     outp.writeline RTrim(Line) 
    Loop 
ElseIf LCase(Arg(1)) = "lr" then 
    Do Until Inp.AtEndOfStream 
     Line=Inp.readline 
     outp.writeline Trim(Line) 
    Loop 
ElseIf LCase(Arg(1)) = "lc" then 
    Count = Cint(LCase(Arg(2))) 
    Do Until Inp.AtEndOfStream 
     Line=Inp.readline 
     If Left(Line,Count) = Space(Count) then 
      outp.writeline Mid(Line, Count +1) 
     Else 
      outp.writeline LTrim(Line) 
     End If 
    Loop 
End If 

использовать пакетный файл, чтобы начать его так:

cscript //nologo <pathtovbsscript\vbsscript.vbs> lc 5 <file.h 

Общее использование

Фильтр предназначен для использования в командной строке. Filter.vbs должен запускаться с помощью cscript.exe. Если вы просто наберете фильтр, он запустит пакетный файл, который сделает это автоматически.

filter subcommand [parameters] 

Фильтр считывает и записывает только стандартные и стандартные данные. Они доступны только в командной строке.

filter <inputfile >outputfile 
filter <inputfile | other_command 
other_command | filter >outputfile 
other_command | filter | other_command 
Смежные вопросы