void __fastcall TForm1::TabControl1Change(TObject *Sender) { switch( TabControl1 -> TabIndex ) { case 0: { if( !FileExists( "MeanFile.txt" ) || !FileExists( "standardDeviation.txt" ) ) { char filename[ 150 ]; MacroBlock MeanBlock[ imageHeight / 16 ][ imageWidth / 16 ]; MacroBlock block[ imageHeight / 16 ][ imageWidth / 16 ]; for( int n = 0; n < FileListBox1 -> Items -> Count; n ++ ) { memset( block, 0, sizeof( block ) ); memset( MeanBlock, 0, sizeof( MeanBlock ) ); sprintf( filename, "%s%s", ExtractFilePath( FileListBox1 -> FileName ), FileListBox1 -> Items -> Strings[ n ].c_str() ); ReadBMPData( filename ); double LSum = 0; for( int i = 0; i < imageHeight / 16; i ++ ) for( int j = 0; j < imageWidth / 16; LSum = 0, j ++ ) { for( int k = i * 16; k <= ( i * 16 + 15 ); k ++ ) for( int m = j * 16 * 3; m <= ( j * 16 + 15 ) * 3; m += 3 ) { RGB2Lab( ImageDataBlock[ k ][ m + 0 ], ImageDataBlock[ k ][ m + 1 ], ImageDataBlock[ k ][ m + 2 ], &Lab_buf[ k ][ m + 0 ], &Lab_buf[ k ][ m + 1 ], &Lab_buf[ k ][ m + 2 ] ); LSum += Lab_buf[ k ][ m + 0 ]; } block[ i ][ j ].DCL = LSum / 256.0; MeanBlock[ i ][ j ].DCL += block[ i ][ j ].DCL; AllDCL[ n ][ i ][ j ] = block[ i ][ j ].DCL; } } for( int i = 0; i < imageHeight / 16; i ++ ) for( int j = 0; j < imageWidth / 16; j ++ ) MeanBlock[ i ][ j ].DCL /= FileListBox1 -> Items -> Count; FILE *MeanFile = fopen( "MeanFile.txt", "w" ); for( int i = 0; i < imageHeight / 16; i ++ ) { for( int j = 0; j < imageWidth / 16; j ++ ) fprintf( MeanFile, "%f ", MeanBlock[ i ][ j ].DCL ); fprintf( MeanFile, "\n" ); } fclose( MeanFile ); for( int i = 0; i < 100; i ++ ) for( int j = 0; j < imageHeight / 16; j ++ ) for( int k = 0; k < imageWidth / 16; k ++ ) stddev[ j ][ k ] += pow( AllDCL[ i ][ j ][ k ] - MeanBlock[ j ][ k ].DCL, 2 ); for( int i = 0; i < imageHeight / 16; i ++ ) for( int j = 0; j < imageWidth / 16; j ++ ) stddev[ i ][ j ] = pow( stddev[ i ][ j ] / ( FileListBox1 -> Items -> Count - 1 ), 0.5 ); FILE *StandardDeviation = fopen( "standardDeviation.txt", "w" ); for( int i = 0; i < imageHeight / 16; i ++ ) { for( int j = 0; j < imageWidth / 16; j ++ ) fprintf( StandardDeviation, "%f ", stddev[ i ][ j ] ); fprintf( StandardDeviation, "\n" ); } fclose( StandardDeviation ); } break; } } }
void __fastcall TfrmSearch::btnVBHelpClick(TObject *Sender) { ShellExecute(NULL,"open","hh.exe",(ExtractFilePath(Application->ExeName) + "Help\\VBScript语言参考.chm").c_str(),"",SW_NORMAL); }
//------------------------------------------------------------------------------ // Блок действий с файлом КХР //------------------------------------------------------------------------------ // добавление информации о КХР bool TController::addNewKHR() { // происходит проверка на заполненность полей if(Trim(formKHR->edtOrderNum->Text) == "" || Trim(formKHR->edtKHRNum->Text) == "" || Trim(formKHR->edtName->Text) == "" || Trim(formKHR->edtShort->Text) == "") { // какие-то данные не заполнены ShowMessage("Не все данные заполнены!"); return false; } TKHR *khr; string nfile; string pathName; // сохранение КХР formKHR->SaveDialog->InitialDir = ExtractFilePath(Application->ExeName); if (!formKHR->SaveDialog->Execute()) return false; else { nfile = STR(formKHR->SaveDialog->FileName); AnsiString temp; khr = new TKHR; // создание новой КХР temp = nfile.substr(nfile.size()-4, 4).string::c_str(); if(temp != ".xml") { formKHR->SaveDialog->FileName = formKHR->SaveDialog->FileName + ".xml"; } formKHR->SaveDialog->Options >> ofExtensionDifferent; pathName = STR(formKHR->SaveDialog->FileName); khr->path = pathName; } khr->szOrder = STR(formKHR->edtOrderNum->Text); khr->szNumber = STR(formKHR->edtKHRNum->Text); khr->szTitle = STR(formKHR->edtName->Text); khr->dtStartDate = formKHR->dtStartDate->Date; khr->szFileName = STR(formKHR->edtShort->Text); khr->selected = true; 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++; exec->szName = STR(formKHR->sgExecutors->Cells[0][i]); khr->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]); khr->Signatures.push_back(sig); } } addKHR(khr); DataManager->SaveData(khr, pathName); 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(); saveSettings(); showAll(); return true; }
void __fastcall TOptions::SaveClick(TObject *Sender) { Template->Lines->SaveToFile( ExtractFilePath(Application->ExeName) + "template.NEW"); }
//-------------------------------------------------------------------------- // 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; } }
int main (int argc, char **argv) { int i; double start, end; printf( "qrad.exe v 1.5 (%s)\n", __DATE__ ); printf ("----- Radiosity ----\n"); verbose = true; // Originally FALSE smoothing_threshold = cos(45.0*(Q_PI/180)); // Originally zero. for (i=1 ; i<argc ; i++) { if (!strcmp(argv[i],"-dump")) dumppatches = true; else if (!strcmp(argv[i],"-bounce")) { if ( ++i < argc ) { numbounce = atoi (argv[i]); if ( numbounce < 0 ) { fprintf(stderr, "Error: expected non-negative value after '-bounce'\n" ); return 1; } } else { fprintf( stderr, "Error: expected a value after '-bounce'\n" ); return 1; } } else if (!strcmp(argv[i],"-verbose")) { verbose = true; } else if (!strcmp(argv[i],"-terse")) { verbose = false; } else if (!strcmp(argv[i],"-threads")) { if ( ++i < argc ) { numthreads = atoi (argv[i]); if ( numthreads <= 0 ) { fprintf(stderr, "Error: expected positive value after '-threads'\n" ); return 1; } } else { fprintf( stderr, "Error: expected a value after '-threads'\n" ); return 1; } } else if (!strcmp(argv[i],"-maxchop")) { if ( ++i < argc ) { maxchop = (float)atof (argv[i]); if ( maxchop < 2 ) { fprintf(stderr, "Error: expected positive value after '-maxchop'\n" ); return 1; } } else { fprintf( stderr, "Error: expected a value after '-maxchop'\n" ); return 1; } } else if (!strcmp(argv[i],"-chop")) { if ( ++i < argc ) { minchop = (float)atof (argv[i]); if ( minchop < 1 ) { fprintf(stderr, "Error: expected positive value after '-chop'\n" ); return 1; } if ( minchop < 32 ) { fprintf(stderr, "WARNING: Chop values below 32 are not recommended. Use -extra instead.\n"); } } else { fprintf( stderr, "Error: expected a value after '-chop'\n" ); return 1; } } else if (!strcmp(argv[i],"-scale")) { if ( ++i < argc ) { lightscale = (float)atof (argv[i]); } else { fprintf( stderr, "Error: expected a value after '-scale'\n" ); return 1; } } else if (!strcmp(argv[i],"-ambient")) { if ( i+3 < argc ) { ambient[0] = (float)atof (argv[++i]) * 128; ambient[1] = (float)atof (argv[++i]) * 128; ambient[2] = (float)atof (argv[++i]) * 128; } else { fprintf( stderr, "Error: expected three color values after '-ambient'\n" ); return 1; } } else if( !strcmp(argv[i], "-proj") ) { if ( ++i < argc && *argv[i] ) strcpy( qproject, argv[i] ); else { fprintf(stderr, "Error: expected path name after '-proj'\n" ); return 1; } } else if ( !strcmp(argv[i], "-maxlight") ) { if ( ++i < argc && *argv[i] ) { maxlight = (float)atof (argv[i]) * 128; if ( maxlight <= 0 ) { fprintf(stderr, "Error: expected positive value after '-maxlight'\n" ); return 1; } } else { fprintf( stderr, "Error: expected a value after '-maxlight'\n" ); return 1; } } else if ( !strcmp(argv[i], "-lights" ) ) { if ( ++i < argc && *argv[i] ) { strcpy( designer_lights, argv[i] ); } else { fprintf( stderr, "Error: expected a filepath after '-lights'\n" ); return 1; } } else if ( !strcmp(argv[i], "-inc" ) ) { incremental = true; } else if (!strcmp(argv[i],"-gamma")) { if ( ++i < argc ) { gamma = (float)atof (argv[i]); } else { fprintf( stderr, "Error: expected a value after '-gamma'\n" ); return 1; } } else if (!strcmp(argv[i],"-dlight")) { if ( ++i < argc ) { dlight_threshold = (float)atof (argv[i]); } else { fprintf( stderr, "Error: expected a value after '-dlight'\n" ); return 1; } } else if (!strcmp(argv[i],"-extra")) { extra = true; } else if (!strcmp(argv[i],"-sky")) { if ( ++i < argc ) { indirect_sun = (float)atof (argv[i]); } else { fprintf( stderr, "Error: expected a value after '-gamma'\n" ); return 1; } } else if (!strcmp(argv[i],"-smooth")) { if ( ++i < argc ) { smoothing_threshold = (float)cos(atof(argv[i])*(Q_PI/180.0)); } else { fprintf( stderr, "Error: expected an angle after '-smooth'\n" ); return 1; } } else if (!strcmp(argv[i],"-coring")) { if ( ++i < argc ) { coring = (float)atof( argv[i] ); } else { fprintf( stderr, "Error: expected a light threshold after '-coring'\n" ); return 1; } } else if (!strcmp(argv[i],"-notexscale")) { texscale = false; } else { break; } } ThreadSetDefault (); if (maxlight > 255) maxlight = 255; if (i != argc - 1) Error ("usage: qrad [-dump] [-inc] [-bounce n] [-threads n] [-verbose] [-terse] [-chop n] [-maxchop n] [-scale n] [-ambient red green blue] [-proj file] [-maxlight n] [-threads n] [-lights file] [-gamma n] [-dlight n] [-extra] [-smooth n] [-coring n] [-notexscale] bspfile"); start = I_FloatTime (); strcpy (source, argv[i]); StripExtension (source); SetQdirFromPath (source); // Set the required global lights filename strcat( strcpy( global_lights, gamedir ), "lights.rad" ); if ( _access( global_lights, 0x04) == -1 ) { // try looking in qproject strcat( strcpy( global_lights, qproject ), "lights.rad" ); if ( _access( global_lights, 0x04) == -1 ) { // try looking in the directory we were run from GetModuleFileName( NULL, global_lights, sizeof( global_lights ) ); ExtractFilePath( global_lights, global_lights ); strcat( global_lights, "lights.rad" ); } } // Set the optional level specific lights filename DefaultExtension( strcpy( level_lights, source ), ".rad" ); if ( _access( level_lights, 0x04) == -1 ) *level_lights = 0; ReadLightFile(global_lights); // Required if ( *designer_lights ) ReadLightFile(designer_lights); // Command-line if ( *level_lights ) ReadLightFile(level_lights); // Optional & implied strcpy(incrementfile, source); DefaultExtension(incrementfile, ".r0"); DefaultExtension(source, ".bsp"); LoadBSPFile (source); ParseEntities (); if (!visdatasize) { printf ("No vis information, direct lighting only.\n"); numbounce = 0; ambient[0] = ambient[1] = ambient[2] = 0.1f; } RadWorld (); if (verbose) PrintBSPFileSizes (); WriteBSPFile (source); if ( incremental ) { if ( !IsIncremental(incrementfile) ) { SaveIncremental(incrementfile); } } else { unlink(incrementfile); } end = I_FloatTime (); printf ("%5.0f seconds elapsed\n", end-start); return 0; }
bool baseRunApp( const std::string &commandLine, const std::string ¶ms, const std::string &rundir, std::string &outfname, bool wait, bool minimise ) { STARTUPINFO StartInfo; StartInfo.hStdInput = 0; StartInfo.hStdOutput = 0; StartInfo.hStdError = 0; char appFName[ 255 ]; int nLen = 0; nLen = ::GetModuleFileName( HInstance, appFName, 255 ); appFName[ nLen ] = '\0'; String fname = ExtractFilePath( appFName ); fname += "TraceLog\\Runapp_"; String progname = ExtractFileName( commandLine.c_str() ); progname = progname.SubString( 1, progname.Pos( "." ) - 1 ); std::string outFileName = ( fname + progname + ".log" ).c_str() ; // use the system defined TEMP directory std::string inFileName = "%TEMP%\\NullInput.txt"; char cline[ 1024 ]; DWORD cnt = ExpandEnvironmentStrings( inFileName.c_str(), cline, 1023 ); if ( !cnt ) { logMessage( std::string( fname.c_str() ), std::string( "Error Expanding Environment Strings in " ) + inFileName + lastError() ); outfname = outFileName.c_str(); return false; } cline[ cnt ] = 0; inFileName = cline; PROCESS_INFORMATION ProcessInformation; memset( &StartInfo, 0, sizeof( STARTUPINFO ) ); StartInfo.cb = sizeof( STARTUPINFO ); StartInfo.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; StartInfo.wShowWindow = ( minimise ? SW_MINIMIZE : SW_NORMAL ); SECURITY_ATTRIBUTES outsa; outsa.nLength = sizeof( outsa ); outsa.lpSecurityDescriptor = 0; outsa.bInheritHandle = TRUE; StartInfo.hStdOutput = CreateFile( outFileName.c_str(), GENERIC_WRITE | GENERIC_READ, FILE_SHARE_WRITE | FILE_SHARE_READ, &outsa, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH, 0 ); if ( StartInfo.hStdOutput == INVALID_HANDLE_VALUE ) { logMessage( std::string( fname.c_str() ), std::string( "Error opening output file " ) + outFileName.c_str() + " : " + lastError() ); logMessage( std::string( fname.c_str() ), std::string( "Current directory is " ) + GetCurrentDir().c_str() ); outfname = outFileName.c_str(); return false; } logMessage( std::string( fname.c_str() ), std::string( "Output file is " ) + outFileName ); SECURITY_ATTRIBUTES insa; insa.nLength = sizeof( insa ); insa.lpSecurityDescriptor = 0; insa.bInheritHandle = TRUE; StartInfo.hStdInput = CreateFile( inFileName.c_str(), GENERIC_READ, FILE_SHARE_READ, &insa, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0 ); if ( StartInfo.hStdInput == INVALID_HANDLE_VALUE ) { logMessage( std::string( fname.c_str() ), std::string( "Error opening input file " ) + inFileName.c_str() + " : " + lastError() ); logMessage( std::string( fname.c_str() ), std::string( "Current directory is " ) + GetCurrentDir().c_str() ); outfname = outFileName.c_str(); return false; } // StdErr is a duplicate of StdOut BOOL cret = DuplicateHandle( GetCurrentProcess(), // handle to process with handle to duplicate StartInfo.hStdOutput, // handle to duplicate GetCurrentProcess(), // handle to process to duplicate to &StartInfo.hStdError, // pointer to duplicate handle 0, // access for duplicate handle TRUE, // handle inheritance flag DUPLICATE_SAME_ACCESS // optional actions ); if ( !cret ) { logMessage( std::string( fname.c_str() ), std::string( "Error duplicating handle for StdErr : " ) + lastError() ); outfname = outFileName.c_str(); return false; } std::string cmdl = commandLine; if ( params.size() ) { cmdl += " " + params; } cnt = ExpandEnvironmentStrings( cmdl.c_str(), cline, 1023 ); if ( !cnt ) { logMessage( std::string( fname.c_str() ), std::string( "Error Expanding Environment Strings in " ) + cmdl + lastError() ); outfname = outFileName.c_str(); return false; } cline[ cnt ] = 0; // All of our handles get passed on. cret = CreateProcess( 0, // pointer to name of executable module cline, // pointer to command line string - NOT CONST! 0, // pointer to process security attributes 0, // pointer to thread security attributes TRUE, // handle inheritance flag - must be true to assign even the standard handles CREATE_DEFAULT_ERROR_MODE, // creation flags 0, // pointer to new environment block ( rundir.size() ? rundir.c_str() : 0 ), // pointer to current directory name &StartInfo, // pointer to STARTUPINFO &ProcessInformation // pointer to PROCESS_INFORMATION ); // close all the handles - they are now given to the child process if ( StartInfo.hStdInput != INVALID_HANDLE_VALUE ) CloseHandle( StartInfo.hStdInput ); if ( StartInfo.hStdError != INVALID_HANDLE_VALUE ) CloseHandle( StartInfo.hStdError ); if ( StartInfo.hStdOutput != INVALID_HANDLE_VALUE ) CloseHandle( StartInfo.hStdOutput ); if ( !cret ) { logMessage( std::string( fname.c_str() ), std::string( "Error running <" ) + commandLine + "> : " + lastError() ); outfname = outFileName.c_str(); return false; } DWORD exitstat = 1; if ( wait ) { // we need to look at a closedown flag as well... WaitForSingleObject( ProcessInformation.hProcess, INFINITE ); if ( !GetExitCodeProcess( ProcessInformation.hProcess, &exitstat ) ) { logMessage( std::string( outfname ), std::string( "Unable to get process exit status" ) + lastError() ); } } CloseHandle( ProcessInformation.hThread ); CloseHandle( ProcessInformation.hProcess ); if ( wait ) { logMessage( std::string( fname.c_str() ), std::string( "Exit status was " ) + makeStr( exitstat ) ); } outfname = outFileName.c_str(); return true; }
/** This version of TxtToBmp uses txt2bmp utility located in /utility dir */ void TxtToBmp (TList *List, Graphics::TBitmap *Bitmap, TFont *Font, int left, int top) { AnsiString /** Define locations of some file needed for conversion */ workdir = ExtractFilePath(Application->ExeName)+"utility\\", utility = workdir + "txt2bmp.exe", /** utility itself, */ textfile = workdir + "__temp.txt", /** input file, */ picfile = workdir + "__temp.bmp", /** resulting file, */ conffile = workdir + "custom.cfg"; /** config to write font * * and indent settings. */ Log->Add("Converting parameters:"); /** Save text to temporary text file */ FILE *f = fopen(textfile.c_str(), "wt"); for(int i=0,j; i<List->Count; i++) { char str[10000]; strcpy(str, (const char *)List->Items[i]); if ((j=strcspn(str,"#"))<strlen(str)) str[j]=' '; fprintf(f, "%s\n", str); } fclose(f); /** * * * * * * * * * * * * * * * **** * * * * * * * * * * * * * * ** * * * Set custom config. File must have the following text format: * * * * - left\n, top\n : integer values, indents * * - fontface\n : string, name of the font to draw image with * * - fontsize\n : integer, size of the font * * - stylestring : string, determines font style. it must not * * contain any delimiters. * * For stylestring, if it contains 'b' character, font will * * be set to bold, 'i' and 'u' is for italic and underline rspct. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* FILE *fconfig = fopen(conffile.c_str(), "wt"); fprintf(fconfig, "%d\n%d\n%s\n%d\n%c%c%c", left, top, Font->Name.c_str(), Font->Size, Font->Style.Contains(fsBold)?'b':'x', Font->Style.Contains(fsItalic)?'i':'x', Font->Style.Contains(fsUnderline)?'u':'x' ); fclose(f); */ // Call the utility SHELLEXECUTEINFO sei; sei.cbSize = sizeof(sei); sei.fMask = SEE_MASK_NOCLOSEPROCESS; sei.lpVerb = NULL; sei.lpFile = utility.c_str(); Log->Add(strdup(("\""+textfile + "\" \"" + picfile+"\"").c_str())); sei.lpParameters = strdup(("\""+textfile + "\" \"" + picfile+"\"").c_str()); sei.lpDirectory = ("\""+workdir+"\"").c_str(); sei.nShow = SW_HIDE; ShellExecuteEx(&sei); /// ... wait while it works WaitForSingleObject(sei.hProcess, INFINITE); //spawnlp(P_WAIT,utility.c_str(),strdup(("\""+textfile + "\" \"" + picfile+"\"").c_str()),NULL); //Load the result*/ Bitmap->LoadFromFile(picfile); }
bool TmplGlob(T& out, const String& pattern, const bool emptyListBefore, const uint32 fileAttribs = FA_ALL, const uint32 required = 0, const bool relative = false) { if (emptyListBefore) out.clear(); String root = ExtractFilePath(pattern); String root_path = root; if (root.size() > 1 && (root.last() == '/' || root.last() == '\\')) root_path.removeLast(); else if (!root.empty()) root << Separator; # ifdef TA3D_PLATFORM_WINDOWS String strFilePath; // Filepath String strExtension; // Extension HANDLE hFile; // Handle to file WIN32_FIND_DATA FileInformation; // File information hFile = ::FindFirstFile(pattern.c_str(), &FileInformation); if (hFile != INVALID_HANDLE_VALUE) { do { if (FileInformation.cFileName[0] != '.') { String name = (const char*)FileInformation.cFileName; if((FileInformation.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && (fileAttribs & FA_DIREC) && !(required & FA_FILE)) { if (relative) out.push_back(name); else out.push_back(String(root) << name); } else if (!(required & FA_DIREC) && (fileAttribs & FA_FILE)) { if (relative) out.push_back(name); else out.push_back(String(root) << name); } } } while(::FindNextFile(hFile, &FileInformation) == TRUE); // Close handle ::FindClose(hFile); } # else /* ifdef WINDOWS */ (void)fileAttribs; String filename_pattern = ExtractFileName(pattern); filename_pattern.toUpper(); DIR *dp; struct dirent *dirp; if ((dp = opendir(root_path.c_str())) == NULL) { // Following line is commented out because it may be useful later, but for now it only floods the logs // LOG_ERROR( LOG_PREFIX_PATHS << "opening " << root << " failed: " << strerror( errno ) ); return true; } while ((dirp = readdir(dp)) != NULL) { String name = (char*)(dirp->d_name); if (dirp->d_type == 0) { DIR *dp2; if ((dp2 = opendir((String(root) << name).c_str()))) { closedir(dp2); dirp->d_type |= FA_DIREC; } else dirp->d_type |= FA_FILE; } if ((dirp->d_type & required) == required && name != "." && name != ".." && ToUpper(name).glob(filename_pattern)) { if (relative) out.push_back(name); else out.push_back(String(root) << name); } } closedir(dp); # endif return !out.empty(); }
void __fastcall TForm12::BitBtn2Click(TObject *Sender) { String ss="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+ExtractFilePath(Application->ExeName)+"库存导入.xls;Mode=Share Deny None;Extended Properties=\"Excel 8.0;IMEX=1;\";Persist Security Info=False" ; Form1->con1->Close(); Form1->con1->ConnectionString=ss; Form1->con1->Connected = true; Form1->qry1->Close(); Form1->qry1->SQL->Clear(); Form1->qry1->SQL->Add("select * from [Sheet1$]"); Form1->qry1->Open(); Form1->qry1->Active=true; int num0=0; int num1=0; int num2=0; int index=0; for(int i=0;;i++) { if(Form1->qry1->Fields->Fields[i]->FieldName.Trim()=="条码"){num0=i;index++;} else if(Form1->qry1->Fields->Fields[i]->FieldName.Trim()=="仓库"){num1=i;index++;} else if(Form1->qry1->Fields->Fields[i]->FieldName.Trim()=="库存"){num2=i;index++;} if(index==3)break; } String str=""; Double kc=0; String name=""; String CK=""; int indexshow=0; while(!Form1->qry1->Eof) //循环写入数据库 { if(Form1->qry1->Fields->Fields[num0]->AsString.Trim().Length()==0) { Form1->qry1->Next(); continue; } indexshow++; Form1->StatusBar1->Panels->Items[0]->Text="正在导入资料 条数: "+String(indexshow); if(Form1->qry1->Fields->Fields[num1]->AsString.Trim().Length()==0) CK="CK001"; else{ CK=Form1->qry1->Fields->Fields[num1]->AsString.Trim(); } if(Form1->qry1->Fields->Fields[num2]->AsString.Trim().Length()==0)kc=0; else { try { kc=Form1->qry1->Fields->Fields[num2]->AsString.Trim().ToDouble(); } catch(...) { kc=0; } } //查询库存是否存在 ,如果存在直接更新,如果不存在先搜索名称以后再添加进去 str=""; Form1->Search_ADOQuery->Close(); Form1->Search_ADOQuery->SQL->Clear(); str=String().sprintf("SELECT * FROM KC WHERE 条码 like \"%s\" AND 仓库 like \"%s\"",Form1->qry1->Fields->Fields[num0]->AsString.Trim(),Form1->qry1->Fields->Fields[num1]->AsString.Trim()); Form1->Search_ADOQuery->SQL->Add(str); Form1->Search_ADOQuery->Active= true; if(Form1->Search_ADOQuery->RecordCount==0) { Form1->KC_ADOTable->Insert(); Form1->KC_ADOTable->FieldByName("条码")->AsString = Form1->qry1->Fields->Fields[num0]->AsString.Trim(); /* if(Form1->qry1->Fields->Fields[num1]->AsString.Trim().Length()!=0)Form1->KC_ADOTable->FieldByName("仓库")->AsString = Form1->qry1->Fields->Fields[num1]->AsString.Trim(); else Form1->KC_ADOTable->FieldByName("仓库")->AsString = "CK001"; */ Form1->KC_ADOTable->FieldByName("仓库")->AsString=CK; Form1->KC_ADOTable->FieldByName("库存")->AsFloat = kc; Form1->KC_ADOTable->Post(); } else { str=""; str=String().sprintf("UPDATE KC SET 库存 =%f WHERE 条码 like \"%s\" AND 仓库 like \"%s\"" ,Form1->Search_ADOQuery->FieldByName("库存")->AsFloat+kc ,Form1->qry1->Fields->Fields[num0]->AsString.Trim() ,CK); Form1->ADOCommand1->CommandText = str; Form1->ADOCommand1->Execute(); } Application->ProcessMessages(); // Form1->qry1->Next(); } Form1->con1->Close(); Form1->qry1->Close(); Form1->qry1->SQL->Clear(); Form1->KC_ADOQuery->Close(); Form1->KC_ADOQuery->SQL->Clear(); Form1->KC_ADOQuery->SQL->Add("SELECT * FROM 库存"); Form1->KC_ADOQuery->Active= true; MessageDlg("导入完成",mtInformation,TMsgDlgButtons()<<mbOK,0); StatusBar1->Panels->Items[0]->Text="查询结果 条数: "+String(Form1->KC_ADOQuery->RecordCount); }
//--------------------------------------------------------------------------- void TMainForm::ListResults() { AnsiString FileName=ExtractFileName(FName),OutFile; FileName=FileName.SubString(1,FileName.Length()-4); AnsiString DirName=ExtractFilePath(FName)+FileName; CreateDir(DirName); SetCurrentDir(DirName); fstream file; int NMols,NFrames=0,i,j,n,x,y; float *MolIntegrInt,tmp; OutFile=DirName+"\\Kinetics.txt"; file.open(OutFile.c_str(),ios::out); for(n=0;n<Results.GetN() && !Results[n];n++){}; int StartFrame=n; if(Pars.UseExProfile) { //deleting the molecules outside Pars.Cutoff*ExFrame.GetMax() area; for(i=0;i<Results[n]->Count;i++) { x=Results[StartFrame]->Mol(i).x; y=Results[StartFrame]->Mol(i).y; if(ExFrame[y][x]<Pars.CutOff*ExFrame.GetMax()) for(j=0;j<Results.GetN();j++) if(Results[j]) Results[j]->Delete(i); } } NMols=Results[StartFrame]->Count; //the first processed frame gives the number of molecules file<<"Frame\t"; for(i=0;i<NMols;i++) file<<"Mol"<<i+1<<"\t";//kinetics file header file<<endl; MolIntegrInt=new float[NMols]; setmem(MolIntegrInt,NMols*sizeof(float),0);//starting integral values are zeros for(;n<Results.GetN() && Results[n];n++)//printing kinetics file and counting aver.int. { NFrames++; //counting actual number of frames file<<n+1<<"\t"; for(i=0;i<NMols;i++) { x=Results[StartFrame]->Mol(i).x; y=Results[StartFrame]->Mol(i).y; tmp=Results[n]->Mol(i).I; if(Pars.Normalize) tmp*=(float)ExFrame.GetMax()/ExFrame[y][x]; MolIntegrInt[i]+=tmp; //integral intensity of each molecule file<<floor(tmp)<<"\t"; } file<<endl; } file.close(); OutFile=DirName+"\\"+FileName+"_coor.txt"; file.open(OutFile.c_str(),ios::out); file<<"MolNum\tX\tY\tIaver"; if(Pars.UseExProfile) file<<"\tIex"; file<<endl; //coordinate file header for(i=0;i<NMols;i++) { x=Results[StartFrame]->Mol(i).x; y=Results[StartFrame]->Mol(i).y; file<<i+1<<"\t"<<x+1<<"\t"<<y+1<<"\t"<<floor(MolIntegrInt[i]/NFrames); //aver. int. if(Pars.UseExProfile) file<<"\t"<<(float)ExFrame[y][x]/ExFrame.GetMax(); file<<endl; } file.close(); //ImproveSignals(ExSignals,NFrames); //ImproveSignals(EmSignals,NFrames); OutFile=DirName+"\\"+"SignalsEx.txt"; file.open(OutFile.c_str(),ios::out); for(i=0;i<NFrames;i++) file<<ExSignals[i]<<endl; file.close(); OutFile=DirName+"\\"+"SignalsEm.txt"; file.open(OutFile.c_str(),ios::out); for(i=0;i<NFrames;i++) file<<EmSignals[i]<<endl; file.close(); delete[] MolIntegrInt; }
void autowad_UpdateUsedWads() { // see which wadfiles are needed // code for this wad loop somewhat copied from below wadinfo_t thiswad; lumpinfo_t* thislump = NULL; wadpath_t* currentwad; char* pszWadFile; FILE* texfile; const char* pszWadroot = getenv("WADROOT"); int i, j; int nTexLumps = 0; #ifdef _DEBUG Log("[dbg] Starting wad dependency check\n"); #endif // open each wadpath and sort though its contents for (i = 0; i < g_iNumWadPaths; i++) { currentwad = g_pWadPaths[i]; pszWadFile = currentwad->path; currentwad->usedbymap = false; // guilty until proven innocent #ifdef _DEBUG Log(" Parsing wad: '%s'\n", pszWadFile); #endif texfile = fopen(pszWadFile, "rb"); #ifdef SYSTEM_WIN32 if (!texfile) { // cant find it, maybe this wad file has a hard code drive if (pszWadFile[1] == ':') { pszWadFile += 2; // skip past the drive texfile = fopen(pszWadFile, "rb"); } } #endif char szTmp[_MAX_PATH]; if (!texfile && pszWadroot) { char szFile[_MAX_PATH]; char szSubdir[_MAX_PATH]; ExtractFile(pszWadFile, szFile); ExtractFilePath(pszWadFile, szTmp); ExtractFile(szTmp, szSubdir); // szSubdir will have a trailing separator safe_snprintf(szTmp, _MAX_PATH, "%s" SYSTEM_SLASH_STR "%s%s", pszWadroot, szSubdir, szFile); texfile = fopen(szTmp, "rb"); #ifdef SYSTEM_POSIX if (!texfile) { // cant find it, Convert to lower case and try again strlwr(szTmp); texfile = fopen(szTmp, "rb"); } #endif } #ifdef HLCSG_SEARCHWADPATH_VL #ifdef SYSTEM_WIN32 if (!texfile && pszWadFile[0] == '\\') { char tmp[_MAX_PATH]; int l; for (l = 'C'; l <= 'Z'; ++l) { safe_snprintf (tmp, _MAX_PATH, "%c:%s", l, pszWadFile); texfile = fopen (tmp, "rb"); if (texfile) { break; } } } #endif #endif if (!texfile) // still cant find it, skip this one { #ifdef HLCSG_SEARCHWADPATH_VL pszWadFile = currentwad->path; // correct it back #endif if(pszWadroot) { Warning("Wad file '%s' not found, also tried '%s'",pszWadFile,szTmp); } else { Warning("Wad file '%s' not found",pszWadFile); } continue; } // look and see if we're supposed to include the textures from this WAD in the bsp. { WadInclude_i it; bool including = false; for (it = g_WadInclude.begin(); it != g_WadInclude.end(); it++) { if (stristr(pszWadFile, it->c_str())) { #ifdef _DEBUG Log(" - including wad\n"); #endif including = true; currentwad->usedbymap = true; break; } } if (including) { //fclose(texfile); //continue; } } // read in this wadfiles information SafeRead(texfile, &thiswad, sizeof(thiswad)); // make sure its a valid format if (strncmp(thiswad.identification, "WAD2", 4) && strncmp(thiswad.identification, "WAD3", 4)) { fclose(texfile); continue; } thiswad.numlumps = LittleLong(thiswad.numlumps); thiswad.infotableofs = LittleLong(thiswad.infotableofs); // read in lump if (fseek(texfile, thiswad.infotableofs, SEEK_SET)) { fclose(texfile); continue; // had trouble reading, skip this wad } // memalloc for this lump thislump = (lumpinfo_t*)realloc(thislump, (nTexLumps + thiswad.numlumps) * sizeof(lumpinfo_t)); // BUGBUG: is this destructed? // for each texlump for (j = 0; j < thiswad.numlumps; j++, nTexLumps++) { SafeRead(texfile, &thislump[nTexLumps], (sizeof(lumpinfo_t) - sizeof(int)) ); // iTexFile is NOT read from file CleanupName(thislump[nTexLumps].name, thislump[nTexLumps].name); if (autowad_IsUsedTexture(thislump[nTexLumps].name)) { currentwad->usedbymap = true; currentwad->usedtextures++; #ifdef _DEBUG Log(" - Used wadfile: [%s]\n", thislump[nTexLumps].name); #endif autowad_PurgeName(thislump[nTexLumps].name); } } fclose(texfile); } #ifdef _DEBUG Log("[dbg] End wad dependency check\n\n"); #endif return; }
String TFileList::GetFullPath(int index) { if(index>=Count)return NULL; String p=ExtractFilePath(Path); return p+Strings[index]; }
String GetInstallPath() { return ExtractFilePath(Application->ExeName); }
void WriteMiptex (void) { int i, success; byte *miptex_data; dmiptexlump_t *miptex_lumps; char *path, *currentpath; miptexfile_t *m; path = ValueForKey (&entities[0], "_wad"); if (!path || !path[0]) { path = ValueForKey (&entities[0], "wad"); if (!path || !path[0]) { printf ("WriteMiptex: no wads specified in \"wad\" key in worldspawn\n"); texdatasize = 0; return; } } nummiptexfiles = 0; currentpath = path; while (*currentpath) { getwadname(wadname, ¤tpath); if (wadname[0]) { success = false; // try prepending each -wadpath on the commandline to the wad name for (i = 1;i < myargc;i++) { if (!Q_strcasecmp("-wadpath", myargv[i])) { i++; if (i < myargc) { sprintf(wadfilename, "%s%s", myargv[i], wadname); if ((success = loadwad(wadfilename) >= 0)) break; } } } if (!success) { // if the map name has a path, we can try loading the wad from there ExtractFilePath(bspfilename, wadfilename); if (wadfilename[0]) { strcat(wadfilename, wadname); if (!(success = loadwad(wadfilename) >= 0)) { // try the parent directory ExtractFilePath(bspfilename, wadfilename); strcat(wadfilename, "../"); strcat(wadfilename, wadname); success = loadwad(wadfilename) >= 0; } } } if (!success) { // try the wadname itself success = loadwad(wadname) >= 0; } if (!success) printf("Could not find wad \"%s\" using -wadpath options or in the same directory as the map or it's parent directory, so there!\n", wadname); } } for (i = 0;i < nummiptex;i++) CleanupName(miptex[i], miptex[i]); AddAnimatingTextures(); miptex_lumps = (dmiptexlump_t *)dtexdata; miptex_data = (byte *)&miptex_lumps->dataofs[nummiptex]; miptex_lumps->nummiptex = nummiptex; for (i=0 ; i < nummiptex ; i++) { printf("miptex used: %s", miptex[i]); m = FindMipTexFile(miptex[i]); if (m) { if (miptex_data + m->size - dtexdata >= MAX_MAP_MIPTEX) { miptex_lumps->dataofs[i] = -1; printf(" (MAX_MAP_MIPTEX exceeded)\n"); } else if (ReadMipTexFile(m, miptex_data)) { miptex_lumps->dataofs[i] = -1; printf(" (READ ERROR)\n"); } else { miptex_lumps->dataofs[i] = miptex_data - (byte *)miptex_lumps; printf("\n"); miptex_data += m->size; } } else { miptex_lumps->dataofs[i] = -1; printf(" (NOT FOUND)\n"); } } texdatasize = miptex_data - dtexdata; }
//--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "Prefers.h" #include "SNotes.h" #include "inifiles.hpp" #include "registry.hpp" #include "stdio.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "RxCombos" #pragma resource "*.dfm" AnsiString PrefFileOpt = ExtractFilePath(Application->ExeName) + "Preferences.ini"; TPrefsForm* PrefsForm; AnsiString OSopt; int StyleIs = 0; int TransIs; bool WasTrayIcon; bool WasTrans; bool WasXPEffects; bool WasMultiLine; bool WasTop; bool NeedOnClose = true; struct L { char* HotExists; char* NoPrefsError; char* Error; char* WritePrefsError;
void __fastcall TForm9::Button2Click(TObject *Sender) { //================================================ if(Form38->TBdata=="5") { ShowMessage("正在同步移库数据"); return; } String ss="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+ExtractFilePath(Application->ExeName)+"移库导入.xls;Mode=Share Deny None;Extended Properties=\"Excel 8.0;IMEX=1;\";Persist Security Info=False" ; Form1->con1->Close(); Form1->con1->ConnectionString=ss; Form1->con1->Connected = true; Form1->qry1->Close(); Form1->qry1->SQL->Clear(); Form1->qry1->SQL->Add("select * from [Sheet1$]"); Form1->qry1->Open(); Form1->qry1->Active=true; //单号,仓库,条码,数量 int num0=0; int num1=0; int num2=0; int num3=0; int num4=0; int index=0; for(int i=0;;i++) { if(Form1->qry1->Fields->Fields[i]->FieldName.Trim()=="条码"){num0=i;index++;} else if(Form1->qry1->Fields->Fields[i]->FieldName.Trim()=="数量"){num1=i;index++;} else if(Form1->qry1->Fields->Fields[i]->FieldName.Trim()=="原仓库"){num2=i;index++;} else if(Form1->qry1->Fields->Fields[i]->FieldName.Trim()=="目的仓库"){num3=i;index++;} else if(Form1->qry1->Fields->Fields[i]->FieldName.Trim()=="移库单号"){num4=i;index++;} if(index==5)break; } String str=""; Double num=0; int indexshow=0; String DH=""; while(!Form1->qry1->Eof) //循环写入数据库 { if(Form1->qry1->Fields->Fields[num0]->AsString.Trim().Length()==0) { Form1->qry1->Next(); continue; } indexshow++; this->StatusBar1->Panels->Items[0]->Text="正在导入资料 条数: "+String(indexshow); if(Form1->qry1->Fields->Fields[num1]->AsString.Trim().Length()==0)num=1; else { try { num=Form1->qry1->Fields->Fields[num1]->AsString.Trim().ToDouble(); } catch(...) { num=1; } } if(Form1->qry1->Fields->Fields[num4]->AsString.Trim().Length()==0)DH="DH001"; else { DH= Form1->qry1->Fields->Fields[num4]->AsString.Trim(); } String str=""; /*Form1->Search_ADOQuery->Close(); Form1->Search_ADOQuery->SQL->Clear(); str=String().sprintf("SELECT * FROM 移库 WHERE 条码 like \"%s\" AND 原仓库 like \"%s\" AND 目的仓库 like \"%s\"",Form1->qry1->Fields->Fields[num0]->AsString.Trim(),Form1->qry1->Fields->Fields[num2]->AsString.Trim(),Form1->qry1->Fields->Fields[num3]->AsString.Trim()); Form1->Search_ADOQuery->SQL->Add(str); Form1->Search_ADOQuery->Active= true; if(Form1->Search_ADOQuery->RecordCount==0) {*/ Form1->YK_ADOTable->Insert(); Form1->YK_ADOTable->FieldByName("条码")->AsString = Form1->qry1->Fields->Fields[num0]->AsString.Trim(); Form1->YK_ADOTable->FieldByName("数量")->AsFloat = num; Form1->YK_ADOTable->FieldByName("移库时间")->AsString=Now().FormatString("yyyy-mm-dd"); Form1->YK_ADOTable->FieldByName("移库单号")->AsString = DH; Form1->YK_ADOTable->FieldByName("原仓库")->AsString = Form1->qry1->Fields->Fields[num2]->AsString.Trim(); Form1->YK_ADOTable->FieldByName("目的仓库")->AsString = Form1->qry1->Fields->Fields[num3]->AsString.Trim(); Form1->YK_ADOTable->FieldByName("员工编号")->AsString = Form1->LoginName.Trim(); Form1->YK_ADOTable->Post(); /*} else { str=""; str=String().sprintf("UPDATE YK SET 数量 = %f , 移库时间 = \"%s\" , 员工编号 = \"%s\" WHERE 条码 like \"%s\" AND 原仓库 like \"%s\" AND 目的仓库 like \"%s\"" ,num+Form1->Search_ADOQuery->FieldByName("数量")->AsFloat ,Now().FormatString("yyyy-mm-dd") ,Form1->LoginName.Trim() ,Form1->qry1->Fields->Fields[num0]->AsString.Trim() ,Form1->qry1->Fields->Fields[num2]->AsString.Trim() ,Form1->qry1->Fields->Fields[num3]->AsString.Trim()); Form1->ADOCommand1->CommandText = str; Form1->ADOCommand1->Execute(); } */ //修改库存表格 str=""; Form1->KC_ADOQuery->Close(); Form1->KC_ADOQuery->SQL->Clear(); str=String().sprintf("SELECT * FROM 库存 WHERE 条码 like \"%s\" AND 仓库 like \"%s\"",Form1->qry1->Fields->Fields[num0]->AsString.Trim(),Form1->qry1->Fields->Fields[num2]->AsString.Trim()); Form1->KC_ADOQuery->SQL->Add(str); Form1->KC_ADOQuery->Active= true; if(Form1->KC_ADOQuery->RecordCount==0) { //MessageDlg("11",mtInformation,TMsgDlgButtons()<<mbOK,0); Form1->KC_ADOTable->Insert(); Form1->KC_ADOTable->FieldByName("条码")->AsString = Form1->qry1->Fields->Fields[num0]->AsString.Trim(); Form1->KC_ADOTable->FieldByName("出库数量")->AsFloat = 0; Form1->KC_ADOTable->FieldByName("入库数量")->AsFloat = 0; Form1->KC_ADOTable->FieldByName("仓库")->AsString = Form1->qry1->Fields->Fields[num2]->AsString.Trim(); Form1->KC_ADOTable->FieldByName("库存")->AsFloat = 0 -num; Form1->KC_ADOTable->Post(); } else { str=""; str=String().sprintf("UPDATE KC SET 库存 =%f WHERE 条码 like \"%s\" AND 仓库 like \"%s\"" ,Form1->KC_ADOQuery->FieldByName("库存")->AsFloat-num ,Form1->qry1->Fields->Fields[num0]->AsString.Trim() ,Form1->qry1->Fields->Fields[num2]->AsString.Trim()); Form1->ADOCommand1->CommandText = str; Form1->ADOCommand1->Execute(); } str=""; Form1->KC_ADOQuery->Close(); Form1->KC_ADOQuery->SQL->Clear(); str=String().sprintf("SELECT * FROM 库存 WHERE 条码 like \"%s\" AND 仓库 like \"%s\"",Form1->qry1->Fields->Fields[num0]->AsString.Trim(),Form1->qry1->Fields->Fields[num3]->AsString.Trim()); Form1->KC_ADOQuery->SQL->Add(str); Form1->KC_ADOQuery->Active= true; if(Form1->KC_ADOQuery->RecordCount==0) { //MessageDlg("11",mtInformation,TMsgDlgButtons()<<mbOK,0); Form1->KC_ADOTable->Insert(); Form1->KC_ADOTable->FieldByName("条码")->AsString = Form1->qry1->Fields->Fields[num0]->AsString.Trim(); Form1->KC_ADOTable->FieldByName("出库数量")->AsFloat = 0; Form1->KC_ADOTable->FieldByName("入库数量")->AsFloat = 0; Form1->KC_ADOTable->FieldByName("仓库")->AsString = Form1->qry1->Fields->Fields[num3]->AsString.Trim(); Form1->KC_ADOTable->FieldByName("库存")->AsFloat = num; Form1->KC_ADOTable->Post(); } else { str=""; str=String().sprintf("UPDATE KC SET 库存 =%f WHERE 条码 like \"%s\" AND 仓库 like \"%s\"" ,Form1->KC_ADOQuery->FieldByName("库存")->AsFloat+num ,Form1->qry1->Fields->Fields[num0]->AsString.Trim() ,Form1->qry1->Fields->Fields[num3]->AsString.Trim()); Form1->ADOCommand1->CommandText = str; Form1->ADOCommand1->Execute(); } Application->ProcessMessages(); // Form1->qry1->Next(); } // ADOTable1->Close(); Form1->con1->Close(); Form1->qry1->Close(); Form1->qry1->SQL->Clear(); Form1->KC_ADOQuery->Close(); Form1->KC_ADOQuery->SQL->Clear(); Form1->KC_ADOQuery->SQL->Add("SELECT * FROM 库存"); Form1->KC_ADOQuery->Active= true; Form1->YK_ADOQuery->Close(); Form1->YK_ADOQuery->SQL->Clear(); Form1->YK_ADOQuery->SQL->Add("SELECT * FROM 移库"); Form1->YK_ADOQuery->Active= true; MessageDlg("导入完成",mtInformation,TMsgDlgButtons()<<mbOK,0); this->StatusBar1->Panels->Items[0]->Text=""; }
//--------------------------------------------------------------------------- void ApplyLangOpt() { TIniFile* LangIni; if (SNotesXMForm->RussianLangMenu->Checked) LangIni = new TIniFile (ExtractFilePath(Application->ExeName) + "Languages\\Russian.lng"); if (SNotesXMForm->EnglishLangMenu->Checked) LangIni = new TIniFile (ExtractFilePath(Application->ExeName) + "Languages\\English.lng"); PrefsForm->Caption = LangIni->ReadString("Language", "OPTIONS_WINDOW_TITLE", "Настройки"); PrefsForm->PagesTree->Items->operator [](0)->Text = LangIni->ReadString("Language", "OPTIONS_PAGE_GENERAL", "Общие"); PrefsForm->PagesTree->Items->operator [](1)->Text = LangIni->ReadString("Language", "OPTIONS_PAGE_VIEW", "Вид"); PrefsForm->PagesTree->Items->operator [](2)->Text = LangIni->ReadString("Language", "OPTIONS_PAGE_OPTIMIZATION", "Оптимизация"); PrefsForm->PagesTree->Items->operator [](3)->Text = LangIni->ReadString("Language", "OPTIONS_PAGE_HOTKEY", "Горячая клавиша"); PrefsForm->PagesTree->Items->operator [](4)->Text = LangIni->ReadString("Language", "OPTIONS_PAGE_DEFAULT", "По умолчанию"); PrefsForm->OKButton->Caption = LangIni->ReadString("Language", "OPTIONS_OK_BUTTON", "OK"); PrefsForm->CancelButton->Caption = LangIni->ReadString("Language", "OPTIONS_CANCEL_BUTTON", "О&тмена"); PrefsForm->ApplyButton->Caption = LangIni->ReadString("Language", "OPTIONS_APPLY_BUTTON", "П&рименить"); PrefsForm->GeneralGroupBox->Caption = LangIni->ReadString("Language", "OPTIONS_GENERAL_LABEL", "Общие настройки"); PrefsForm->MinOnClose->Caption = LangIni->ReadString("Language", "OPTIONS_CLOSE_AS_MIN_CHECKBOX", "ЗАКРЫТЬ работает как СВЕРНУТЬ"); PrefsForm->StartWithWindows->Caption = LangIni->ReadString("Language", "OPTIONS_AUTORUN_CHECKBOX", "Запускаться с Windows"); PrefsForm->StorePagesGroupBox->Caption = LangIni->ReadString("Language", "OPTIONS_STORE_PAGES_LABEL", "Располагать названия страниц"); PrefsForm->TopPages->Caption = LangIni->ReadString("Language", "OPTIONS_ON_TOP_RADIO", "Вверху"); PrefsForm->BottomPages->Caption = LangIni->ReadString("Language", "OPTIONS_BOTTOM_RADIO", "Внизу"); PrefsForm->SelectBackupFolderLabel->Caption = LangIni->ReadString("Language", "OPTIONS_BACKUP_FOLDER_LABEL", "Выберите папку для резервного копирования:"); PrefsForm->IconInTray->Caption = LangIni->ReadString("Language", "OPTIONS_TRAY_ICON_CHECKBOX", "Значок в системном трее"); PrefsForm->TaskbarCheck->Caption = LangIni->ReadString("Language", "OPTIONS_TASKBAR_ICON_CHECKBOX", "Значок в панели задач (перезапустите программу)"); PrefsForm->HideWind->Caption = LangIni->ReadString("Language", "OPTIONS_HIDE_WINDOW_CHECKBOX", "Скрывать окно, если оно неактивно"); PrefsForm->HideLabel->Caption = LangIni->ReadString("Language", "OPTIONS_SECONDS_LABEL", "сек."); PrefsForm->ViewGroupBox->Caption = LangIni->ReadString("Language", "OPTIONS_VIEW_LABEL", "Вид"); PrefsForm->Transparency->Caption = LangIni->ReadString("Language", "OPTIONS_TRANS_CHECKBOX", "Эффект полупрозрачности (WinXP/2K/2003)"); PrefsForm->MultiLines->Caption = LangIni->ReadString("Language", "OPTIONS_MULTILINE_CHECKBOX", "Многострочные закладки"); PrefsForm->URLDetect->Caption = LangIni->ReadString("Language", "OPTIONS_AUTO_URL_CHECKBOX", "Автоопределение ссылок (перезапустите программу)"); PrefsForm->FadeShow->Caption = LangIni->ReadString("Language", "OPTIONS_FADE_SHOW_CHECKBOX", "Плавное появление"); PrefsForm->SpeedLabel->Caption = LangIni->ReadString("Language", "OPTIONS_SPEED_LABEL", "Скорость"); PrefsForm->StyleLabel->Caption = LangIni->ReadString("Language", "OPTIONS_STYLE_LABEL", "Стиль:"); PrefsForm->StyleBox->Items->Strings[0] = LangIni->ReadString("Language", "OPTIONS_DEFAULT_STYLE", "Стандартный"); PrefsForm->XPEffects->Caption = LangIni->ReadString("Language", "OPTIONS_XP_EFECTS_CHECKBOX", "Включить оформление XP"); PrefsForm->ProgramModeGroupBox->Caption = LangIni->ReadString("Language", "OPTIONS_PROGRAM_MODE_LABEL", "Выберите режим работы программы"); PrefsForm->NormalMode->Caption = LangIni->ReadString("Language", "OPTIONS_NORMAL_RADIO", "Обычный"); PrefsForm->HighMode->Caption = LangIni->ReadString("Language", "OPTIONS_SECURITY_RADIO", "Надежный"); PrefsForm->NormalModeLabel->Caption = LangIni->ReadString("Language", "OPTIONS_NORMAL_MODE_LABEL", "Программа сохраняет текст при смене страниц, сворачивании и закрытии. Работает быстро даже на слабых машинах."); PrefsForm->SecurityModeLabel->Caption = LangIni->ReadString("Language", "OPTIONS_SECURITY_MODE_LABEL", "Программа сохраняет каждый введенный символ. Занимает меньше места в RAM на 0.5 Мб, но работает медленно при высокой загрузке процессора."); PrefsForm->HotkeyGroupBox->Caption = LangIni->ReadString("Language", "OPTIONS_SEY_HOTKEY_LABEL", "Установите горячую клавишу"); PrefsForm->HotkeyLabel->Caption = LangIni->ReadString("Language", "OPTIONS_HOTKEY_LABEL", "Горячая клавиша для свертывания/восстановления SimpleNotes"); PrefsForm->SetHotkeyButton->Caption = LangIni->ReadString("Language", "OPTIONS_SET_HOTKEY_BUTTON", "Задействовать!"); PrefsForm->FadeHide->Caption = LangIni->ReadString("Language", "OPTIONS_FADE_HIDE_CHECKBOX", "Плавное исчезновение при нажатии"); PrefsForm->DefaultGroupBox->Caption = LangIni->ReadString("Language", "OPTIONS_DEFAULT_LABEL", "Настройки по умолчанию"); PrefsForm->DefaultFontLabel->Caption = LangIni->ReadString("Language", "OPTIONS_DEFAULT_FONT_LABEL", "Шрифт по умолчанию:"); PrefsForm->DefaultPageColorLabel->Caption = LangIni->ReadString("Language", "OPTIONS_DEFAULT_COLOR_LABEL", "Цвет фона страницы по умолчанию:"); PrefsForm->DefaultFontSizeLabel->Caption = LangIni->ReadString("Language", "OPTIONS_DEFAULT_FONT_SIZE_LABEL", "Размер шрифта по умолчанию:"); PrefsForm->PageFormatLabel->Caption = LangIni->ReadString("Language", "OPTIONS_DEFAULT_FORMAT_LABEL", "Формат страницы при создании:"); PrefsForm->FormatPageBox->Items->Strings[0] = LangIni->ReadString("Language", "OPTIONS_DEFAULT_RTF_FORMAT", "rtf-формат"); PrefsForm->FormatPageBox->Items->Strings[1] = LangIni->ReadString("Language", "OPTIONS_DEFAULT_TXT_FORMAT", "txt-формат"); PrefsForm->AttentionLabel->Caption = LangIni->ReadString("Language", "OPTIONS_FORMAT_WARNING_LABEL", "Внимание!!! В txt-формате Вы НЕ сможете вставлять объекты и изображения, менять фоматирование отдельных частей текста, менять цвет текста и т.д."); PrefsForm->AskFormat->Caption = LangIni->ReadString("Language", "OPTIONS_CONFIRM_FORMAT_CHANGE_CHECKBOX", "Подтверждать смену формата страницы из rtf в txt"); LMessagesOpt.Error = new char [strlen((LangIni->ReadString("Language", "MAIN_MESSAGE_ERROR", "Ошибка")).c_str()) + 1]; LMessagesOpt.HotExists = new char [strlen((LangIni->ReadString("Language", "OPTIONS_MESSAGE_ERROR_HOTKEY_ALREADY_REGISTERED", "Эта клавиша уже зарегистрирована!")).c_str()) + 1]; LMessagesOpt.NoPrefsError = new char [strlen((LangIni->ReadString("Language", "MAIN_MESSAGE_ERROR_PREFERENCES_NOT_FOUND_1", "Файл с настройками") + " " + PrefFileOpt + "\n" + LangIni->ReadString("Language", "MAIN_MESSAGE_ERROR_PREFERENCES_NOT_FOUND_2", "не найден и не может быть создан. Проверьте Ваши права на запись.")).c_str()) + 1]; LMessagesOpt.WritePrefsError = new char [strlen((LangIni->ReadString("Language", "MAIN_MESSAGE_ERROR_WRITE_PREFERENCES_1", "Ошибка при записи в файл настроек") + " " + PrefFileOpt + "\n" + LangIni->ReadString("Language", "MAIN_MESSAGE_ERROR_WRITE_PREFERENCES_2", "Возможные причины: файл блокирован другим приложением и невозможно получить к нему доступ, файл или диск защищены (переполнены)") + "\n" + LangIni->ReadString("Language", "MAIN_MESSAGE_ERROR_WRITE_PREFERENCES_3", "от записи, другой пользователь производит запись в данный файл.")).c_str()) + 1]; LMessagesOpt.ReadPrefsError = new char [strlen((LangIni->ReadString("Language", "MAIN_MESSAGE_ERROR_READ_PREFERENCES_1", "Ошибка при чтении файла настроек") + " " + PrefFileOpt + "\n" + LangIni->ReadString("Language", "MAIN_MESSAGE_ERROR_READ_PREFERENCES_2", "Возможные причины: файл блокирован другим приложением и невозможно прочитать его. Найдите это приложение и отключите блокировку.") + "\n" + LangIni->ReadString("Language", "MAIN_MESSAGE_ERROR_READ_PREFERENCES_3", "Либо данные, записанные в этом файле, некорректны.")).c_str()) + 1]; LMessagesOpt.SelectFolder = new char [strlen((LangIni->ReadString("Language", "OPTIONS_SELECT_FOLDER_DIALOG_LABEL", "Выберите папку для резервного копирования:")).c_str()) + 1]; strcpy(LMessagesOpt.Error, (LangIni->ReadString("Language", "MAIN_MESSAGE_ERROR", "Ошибка")).c_str()); strcpy(LMessagesOpt.HotExists, (LangIni->ReadString("Language", "OPTIONS_MESSAGE_ERROR_HOTKEY_ALREADY_REGISTERED", "Эта клавиша уже зарегистрирована!")).c_str()); strcpy(LMessagesOpt.NoPrefsError, (LangIni->ReadString("Language", "MAIN_MESSAGE_ERROR_PREFERENCES_NOT_FOUND_1", "Файл с настройками") + " " + PrefFileOpt + "\n" + LangIni->ReadString("Language", "MAIN_MESSAGE_ERROR_PREFERENCES_NOT_FOUND_2", "не найден и не может быть создан. Проверьте Ваши права на запись.")).c_str()); strcpy(LMessagesOpt.WritePrefsError, (LangIni->ReadString("Language", "MAIN_MESSAGE_ERROR_WRITE_PREFERENCES_1", "Ошибка при записи в файл настроек") + " " + PrefFileOpt + "\n" + LangIni->ReadString("Language", "MAIN_MESSAGE_ERROR_WRITE_PREFERENCES_2", "Возможные причины: файл блокирован другим приложением и невозможно получить к нему доступ, файл или диск защищены (переполнены)") + "\n" + LangIni->ReadString("Language", "MAIN_MESSAGE_ERROR_WRITE_PREFERENCES_3", "от записи, другой пользователь производит запись в данный файл.")).c_str()); strcpy(LMessagesOpt.ReadPrefsError, (LangIni->ReadString("Language", "MAIN_MESSAGE_ERROR_READ_PREFERENCES_1", "Ошибка при чтении файла настроек") + " " + PrefFileOpt + "\n" + LangIni->ReadString("Language", "MAIN_MESSAGE_ERROR_READ_PREFERENCES_2", "Возможные причины: файл блокирован другим приложением и невозможно прочитать его. Найдите это приложение и отключите блокировку.") + "\n" + LangIni->ReadString("Language", "MAIN_MESSAGE_ERROR_READ_PREFERENCES_3", "Либо данные, записанные в этом файле, некорректны.")).c_str()); strcpy(LMessagesOpt.SelectFolder, (LangIni->ReadString("Language", "OPTIONS_SELECT_FOLDER_DIALOG_LABEL", "Выберите папку для резервного копирования:")).c_str()); delete LangIni; }
void __fastcall TMainForm::FormCreate(TObject *Sender) { if (!LoadSettings()) { ShowMessage ("Отсутсвует или не корректный файл настроек !"); Application->Terminate(); return; } LoadFromRegistry (); if (m_auto_login) { OraSession1->LoginPrompt = false; OraSession1->Username = m_user_name; OraSession1->Password = m_password; OraSession1->Server = m_server; } else { OraSession1->LoginPrompt = true; } OraSession1->Connect(); exec_date_col_index = -1; done_col_index = -1; DBGridJournalDBTableView1->ClearItems(); GridFields::iterator iter = m_fields_list.begin(); while (iter != m_fields_list.end()) { TcxGridDBColumn * col = DBGridJournalDBTableView1->CreateColumn(); //col->BestFitMaxWidth = 40; col->Caption = iter->second; col->DataBinding->FieldName = iter->first; if (m_use_terms) { if (col->DataBinding->FieldName.LowerCase() == m_date_execute.LowerCase()) exec_date_col_index = col->Index; if (col->DataBinding->FieldName.LowerCase() == m_done.LowerCase()) done_col_index = col->Index; } iter++; } UpdateAllJournalGrid(); InitViewList(); Application->HintPause = 0; Application->HintHidePause = 10000; m_hint = new THintWindow (ValueListEditorJParam); m_row = -1; m_col = -1; m_show_hint = false; OraQueryDocsInsert->TableName = m_shema + "." + m_blob_table; Caption = m_caption; Application->HelpFile = ExtractFilePath (Application->ExeName) + "..\\journal_admin.hlp"; // Localization LocalizeGrid(); DBGridJournalDBTableView1->ApplyBestFit(); // ApplyBestFit // dxComponentPrinter1Link1->Preview(true); // dxComponentPrinter1Link1->Print }
//--------------------------------------------------------------------------- void __fastcall TSourceCodeForm1::HelpContentsExecute(TObject *Sender) { Application->HelpFile = ExtractFilePath(Application->ExeName) + "TextEditor.hlp"; Application->HelpCommand(HELP_CONTENTS, 0); }
//--------------------------------------------------------------------------- void __fastcall TViewCardDemoDataDM::DataModuleCreate(TObject *Sender) { String APath = ExtractFilePath(Application->ExeName) + "..\\..\\Data\\"; tblPersons->LoadFromFile(APath + "Persons.xml"); tblCountries->LoadFromFile(APath + "Countries.xml"); }
//--------------------------------------------------------------------------- void __fastcall TForm1::FormCreate(TObject *Sender) { if(FileExists("History.ini")) { Info.LoadHist("History.ini"); Info.GoToBeg(); while(!Info.EndOfList()){ Ed_Addres->Items->Add(Info.Next()); } }else ShowMessage("No found History file!!!"); home = "www.scene.ru"; startp= "z"; ILineVis = "0"; ABarVis = "0"; TBarVis = "0"; FILE *configure; conf = ExtractFilePath(Application->ExeName) + "conf.ini"; // Extract path to .exe file, and summ config name to him configure = fopen(conf.c_str(),"r"); if ( configure != NULL ){ fscanf(configure,"%s\n",home); // Read home site addres fscanf(configure,"%s\n",startp); // Read start page addres fscanf(configure,"%s\n",ILineVis); // Read vis information line fscanf(configure,"%s\n",ABarVis); // Read vis addres bar fscanf(configure,"%s\n",TBarVis); // Read vis tool bar }else ShowMessage("No found configuration file!"); // Load start page if (startp != "z"){ Ed_Addres->Text = startp; Btn_Go->Click(); } // Visible or Invisible Panels and ToolBars on Form1 if(StrToInt(ILineVis) == 1){ StatusBar1->Visible = true; InfoLineVis->Checked = true; } else{ StatusBar1->Visible = false; InfoLineVis->Checked = false; } if(StrToInt(TBarVis) == 1){ ToolBar1->Visible = true; ToolBarVis->Checked = true; } else{ ToolBar1->Visible = false; ToolBarVis->Checked = false; } if(StrToInt(ABarVis) == 1){ Panel1->Visible = true; AddresBarVis->Checked = true; } else { Panel1->Visible = false; AddresBarVis->Checked = false; } }
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; } }
//--------------------------------------------------------------------------- bool __fastcall TThreadSubmitToDB::SubmitToSQLServer() { SECURITY_ATTRIBUTES se = {0}; se.nLength = sizeof(se); se.bInheritHandle = true; se.lpSecurityDescriptor = NULL; CreatePipe(&hReadPipe,&hWritePipe,&se,0); STARTUPINFO si = {0}; si.cb = sizeof(si); si.dwFlags = STARTF_USESHOWWINDOW|STARTF_USESTDHANDLES; si.wShowWindow = SW_HIDE; si.hStdOutput = hWritePipe; si.hStdError = hWritePipe; memset(&pi,sizeof(pi),0); //AnsiString Text; //bcp pubs..hdhd_test_bills1 in c:\convert.tmp -Usa -Pwbzx9801 -S133.57.9.21 -fc:\convert.fmt AnsiString Command = ToolPath + " " + DataBaseName + ".." + DestTableName + " in " + TempFileName + " -U" + DBUserName + " -P" + DBPassword + " -S" + DBServer + " -f" + ExtractFilePath(TempFileName) + DestTableName + ".fmt" + " -m" + MaxError; MessageTextList->Add("执行命令:" + ToolPath + " " + DataBaseName + ".." + DestTableName + " in " + TempFileName + " -U" + DBUserName + " -P******** -S" + DBServer + " -f" + ExtractFilePath(TempFileName) + DestTableName + ".fmt" + " -m" + MaxError); if(SlentMode) { printf("%s\n","执行命令:" + ToolPath + " " + DataBaseName + ".." + DestTableName + " in " + TempFileName + " -U" + DBUserName + " -P******** -S" + DBServer + " -f" + ExtractFilePath(TempFileName) + DestTableName + ".fmt" + " -m" + MaxError); } if(CreateProcess(NULL,Command.c_str(),&se,&se,true,NORMAL_PRIORITY_CLASS,NULL,WorkDir.c_str(),&si,&pi)) { bool bContinue = CloseHandle(hWritePipe); hWritePipe = NULL; char chBuffer[2049]; unsigned long Bytesread; AnsiString Text; int pos = 0; while(bContinue) { bContinue = ReadFile(hReadPipe,&chBuffer[0],2048,&Bytesread,NULL); try { chBuffer[Bytesread] = 0; if(strlen(&chBuffer[0]) > 0) { Text = chBuffer; } //MessageBox(0,Text.c_str(),"",MB_OK); if(Text != "") { //if(MessageTextList->Count > MaxMessageLine) // MessageTextList->Clear(); if(SlentMode) printf("%s\n",Text); MessageTextList->Add(Text); } pos = GetRowsForBCP(Text); if(pos > -1) { SendMessage(hWnd,MSG_SET_PROCESS_POS,pos,0); } if(Text.Pos("时钟时间") > 0) break; } catch(...) { } chBuffer[0] = 0; } WaitForSingleObject(pi.hProcess,INFINITE); CloseHandle(pi.hProcess); CloseHandle(pi.hThread); CloseHandle(hReadPipe); pi.hProcess = NULL; hReadPipe = NULL; if(UpperCase(MessageTextList->Text).Pos("ERROR") > 0) { ErrorMessage = "提交数据失败,请查看状态窗口中的出错信息."; return false; } else { SendMessage(hWnd,MSG_SET_PROCESS_POS,TotalRecordCount,0); int n; for(n = MessageTextList->Count - 1;n > -1;n--) { Text = MessageTextList->Strings[n]; pos = Text.Pos(BCP_KEY_WORD2); if(pos > 0) { pos = StrToIntEx(Text.SubString(pos + strlen(BCP_KEY_WORD2),Text.Length() - strlen(BCP_KEY_WORD2)).c_str()); if(TotalRecordCount - pos > StrToInt(MaxError)) { ErrorMessage = "提交的数据行数与转换的行数不一致,且差异超出了允许的错误范围(最多" + MaxError + ").转换的数据行数为:" + IntToStr(TotalRecordCount) + ",实际提交的行数为:" + IntToStr(pos) + "."; } break; } } if(n == -1) { ErrorMessage = "找不到BCP关键字,导入失败."; } //如果导入成功,则继续执行SQL语句 if(ErrorMessage == "" && SQLCommandList != NULL) { for(int n = 0;n < SQLCommandList->Count;n++) { try { if(SlentMode) { printf("正在执行语句:%s\n",SQLCommandList->Strings[n]); } MessageTextList->Add("正在执行语句:" + SQLCommandList->Strings[n]); ADOConnection->Execute(SQLCommandList->Strings[n]); } catch(...){} } } try { MessageTextList->Add("*********************************数据提交报告*********************************"); MessageTextList->Add("完成时间:" + FormatDateTime("yyyy-mm-dd hh:nn:ss",Now()) + "."); MessageTextList->Add("目标表:" + DestTableName); MessageTextList->Add("临时文件:" + TempFileName); MessageTextList->Add("共转换了" + IntToStr(TotalRecordCount) + "条记录,导入了" + IntToStr(pos) + "条记录."); } catch(...) { } return true; } } else { CloseHandle(hWritePipe); CloseHandle(hReadPipe); ErrorMessage = "创建BCP进程失败.请检查是否安装了SQLServer客户端软件和ibill.ini中[ExternalTools]的bcppath是否配置正确."; return false; } }
//-------------------------------------------------------------------------- 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; } }
//--------------------------------------------------------------------------- bool __fastcall TThreadSubmitToDB::SubmitToOracle() { SECURITY_ATTRIBUTES se = {0}; se.nLength = sizeof(se); se.bInheritHandle = true; se.lpSecurityDescriptor = NULL; CreatePipe(&hReadPipe,&hWritePipe,&se,0); STARTUPINFO si = {0}; si.cb = sizeof(si); si.dwFlags = STARTF_USESHOWWINDOW|STARTF_USESTDHANDLES; si.wShowWindow = SW_HIDE; si.hStdOutput = hWritePipe; si.hStdError = hWritePipe; memset(&pi,sizeof(pi),0); if(CreateProcess(NULL,(ToolPath + " " + DBUserName + "/" + DBPassword + "@" + DBServer + " control=\"" + TempFileName + "\" errors=" + MaxError).c_str(),&se,&se,true,NORMAL_PRIORITY_CLASS,NULL,WorkDir.c_str(),&si,&pi)) { bool bContinue = CloseHandle(hWritePipe); hWritePipe = NULL; char chBuffer[2049]; unsigned long Bytesread; AnsiString Text; int pos = 0; while(bContinue) { bContinue = ReadFile(hReadPipe,&chBuffer[0],2048,&Bytesread,NULL); try { chBuffer[Bytesread] = 0; if(strlen(&chBuffer[0]) > 0) { Text = chBuffer; } //Text = AnsiReplaceStr(AnsiReplaceStr(Text,"\r",""),"\n",""); if(Text != "") { if(MessageTextList->Count > MaxMessageLine) MessageTextList->Clear(); if(SlentMode) { printf("%s\n",Text); } MessageTextList->Add(Text); } pos = GetRowsForSQLLDR(Text); if(pos > -1) { SendMessage(hWnd,MSG_SET_PROCESS_POS,pos,0); } } catch(...) { } } WaitForSingleObject(pi.hProcess,INFINITE); CloseHandle(pi.hProcess); pi.hProcess = NULL; CloseHandle(pi.hThread); CloseHandle(hReadPipe); hReadPipe = NULL; if(MessageTextList->Text.Pos("SQL*Loader-") > 0) { ErrorMessage = "提交数据失败,请查看状态窗口中的出错信息."; return false; } else { int n; AnsiString str;// = "逻辑记录计数"; /*for(n = MessageTextList->Count - 1;n > -1;n--) { Text = MessageTextList->Strings[n]; pos = Text.Pos(str); if(pos > 0) { pos = StrToIntEx(Text.SubString(pos + str.Length(),Text.Length() - str.Length() + 1).c_str()); SendMessage(hWnd,MSG_SET_PROCESS_POS,pos,0); if(pos != TotalRecordCount) { ErrorMessage = "提交的数据行数与转换的行数不一致.转换的数据行数为:" + IntToStr(TotalRecordCount) + ",实际提交的行数为:" + IntToStr(pos) + "."; } break; } } if(n == -1) { ErrorMessage = "找不到SQLLDR关键字.导入失败."; }*/ //分析日志文件 TStringList * LogFile = new TStringList; LogFile->LoadFromFile(ExtractFilePath(Application->ExeName) + DestTableName + ".log"); //if(LogFile->Pos(" str = "成功"; for(n = LogFile->Count - 1;n > -1;n--) { Text = LogFile->Strings[n]; int pos1 = Text.Pos(str); if(pos1 > 0) { pos1 = StrToIntEx(Text.c_str());//Text.SubString(pos1 + str.Length(),Text.Length() - str.Length() + 1).c_str()); if(TotalRecordCount - pos1 > StrToInt(MaxError)) { ErrorMessage = "共有" + IntToStr(TotalRecordCount) + "行需要导入,但实际上只载入了" + IntToStr(pos1) + "行."; } break; } } if(n == -1) { ErrorMessage = "找不到SQLLDR关键字,无法分析日志."; } delete LogFile; //如果导入成功,则继续执行SQL语句 if(ErrorMessage == "" && SQLCommandList != NULL) { for(int n = 0;n < SQLCommandList->Count;n++) { try { if(SlentMode) { printf("正在执行语句:%s\n",SQLCommandList->Strings[n]); } MessageTextList->Add("正在执行语句:" + SQLCommandList->Strings[n]); ADOConnection->Execute(SQLCommandList->Strings[n]); } catch(...){} } } //MessageTextList->Clear(); try { for(int n = 0;n < 10;n++) { try { MessageTextList->LoadFromFile(ExtractFilePath(Application->ExeName) + DestTableName + ".log"); break; } catch(...) { } } MessageTextList->Insert(0,"*********************************数据提交报告*********************************"); MessageTextList->Insert(1,"完成时间:" + FormatDateTime("yyyy-mm-dd hh:nn:ss",Now()) + "."); MessageTextList->Insert(2,"目标表:" + DestTableName); MessageTextList->Insert(3,"临时文件:" + TempFileName); MessageTextList->Insert(4,"共转换了" + IntToStr(TotalRecordCount) + "条记录,导入了" + IntToStr(pos) + "条记录."); MessageTextList->Insert(5,"以下是Oracle 的 SQLLDR 生成的报告:"); } catch(...) { } return true; } } else { CloseHandle(hWritePipe); CloseHandle(hReadPipe); ErrorMessage = "创建SQLLDR进程失败.请检查是否安装了Oracle客户端软件和ibill.ini中[ExternalTools]的sqlldrpath是否配置正确."; return false; } }
void thOpenFile::ReadAndModifyFromBuff(char *pBuff, DWORD dwSize, const char* pszFileName) { char szErrorMsg[MAX_PATH]; char szNewFileName[MAX_PATH]; DWORD w; TIniFile *ini; TypePtr p(pBuff); if('WDBC' != TAG(*p.dw)) { _snprintf(szErrorMsg, 512, "[%s]Not Wow's dbc file!", pszFileName); ShowMessage(szErrorMsg); return; } p.dw++; DWORD dwRows, dwCols, dwRowLen, dwTextLen; dwRows = *p.dw++; dwCols = *p.dw++; dwRowLen = *p.dw++; dwTextLen = *p.dw++; FrmMain->sgEdit->RowCount = dwRows+1; FrmMain->sgEdit->ColCount = dwCols+1; for(int i=0; i<FrmMain->sgEdit->RowCount; i++){ FrmMain->sgEdit->Cells[0][i]=IntToStr(i); if(Terminated) return; } //设定列标题 AnsiString iniSetFile=ExtractFilePath(Application->ExeName)+"BcdEditer.ini"; AnsiString SectionName=ExtractFileName(FrmMain->CurrentOpenFile); ini = new TIniFile( iniSetFile ); for(int j=0; j<FrmMain->sgEdit->ColCount; j++){ FrmMain->sgEdit->Cells[j][0]= ini->ReadString(SectionName,"ColTitle"+IntToStr(j),IntToStr(j)); //sgEdit->Cells[j][0]=IntToStr(j); ColType[j]=ini->ReadInteger(SectionName,"ColType"+IntToStr(j),0); if(Terminated) return; } delete ini; //int *ColType = new int[dwCols]; DWORD dwTextStartPos = dwRows*dwRowLen+20; char* pTextPtr = pBuff + dwTextStartPos; char pszTemp[MAX_PATH]; float fTemp; long lTemp; DWORD i, j; BOOL* pbString = new BOOL[dwRows*dwCols]; float newTmp; //int ColType; ini = new TIniFile( iniSetFile ); for(i=0; i<dwRows; i++) { for(j=0; j<dwCols; j++) { //SleepEx(0,0); if(Terminated) return; lTemp = *p.l; newTmp = *p.f; memcpy(&fTemp, &newTmp, 4); if(j==0) //ID FrmMain->sgEdit->Cells[j+1][i+1]=IntToStr(lTemp); else{ //ColType= ini->ReadInteger(SectionName,"ColType"+IntToStr(j),0); switch (ColType[j+1]) { case 0: //整型 FrmMain->sgEdit->Cells[j+1][i+1]=IntToStr(lTemp); break; case 1: //浮点 FrmMain->sgEdit->Cells[j+1][i+1]=FloatToStr(fTemp); break; case 2: //文本 文本类型只能看,不能编辑 if(dwTextStartPos + lTemp < dwSize){ pTextPtr = pBuff + dwTextStartPos + lTemp; FrmMain->sgEdit->Cells[j+1][i+1]=pTextPtr; }else{ FrmMain->sgEdit->Cells[j+1][i+1]="该列不是文本"; } break; default: //整型 FrmMain->sgEdit->Cells[j+1][i+1]=IntToStr(lTemp); } } p.c += 4; } } delete [] pbString; //delete [] ColType; delete ini; }
//--------------------------------------------------------------------------- AnsiString LanguageFileName() { return ExtractFilePath(ParamStr(0)) + SettingView.m_Language + ".lng"; }
bool FPlayList::ChangeList (const char *path) { FString playlistdir; FString song; FILE *file; bool first; bool pls; int i; Songs.Clear(); Position = 0; if ( (file = fopen (path, "rb")) == NULL) { Printf ("Could not open " TEXTCOLOR_BOLD "%s" TEXTCOLOR_NORMAL ": %s\n", path, strerror(errno)); return false; } first = true; pls = false; playlistdir = ExtractFilePath(path); while ((song = NextLine(file)).IsNotEmpty()) { if (first) { first = false; // Check for ID tags. if (song.Compare("[playlist]") == 0) { pls = true; continue; } } // For a .PLS file, skip anything that doesn't start with File[0-9]+= if (pls) { if (strncmp(song, "File", 4) != 0) { continue; } for (i = 4; song[i] >= '0' && song[i] <= '9'; ++i) { } if (song[i] != '=') { continue; } song = song.Mid(i + 1); } // Check for relative paths. long slashpos = song.IndexOf('/'); if (slashpos == 0) { // First character is a slash, so it's absolute. } #ifdef _WIN32 else if (slashpos == 2 && song[1] == ':') { // Name is something like X:/, so it's absolute. } #endif else if (song.IndexOf("://") == slashpos - 1) { // Name is a URL, so it's absolute. } else { // Path is relative; append it to the playlist directory. song = playlistdir + song; } // Just to make sure if (song.IsNotEmpty()) { Songs.Push(song); } } fclose (file); return Songs.Size() != 0; }
void __fastcall TForm1::FormCreate(TObject *Sender) { OpenDialog1->InitialDir = ExtractFilePath(Application->ExeName); }