diff --git a/src/sbbs3/ctrl/MainFormUnit.cpp b/src/sbbs3/ctrl/MainFormUnit.cpp index b0ea615ab8c9cf8b6f70d6fbb12a62b7b2988d11..fa9cee74bb2ccd6adffc4918048f31c3aff965b2 100644 --- a/src/sbbs3/ctrl/MainFormUnit.cpp +++ b/src/sbbs3/ctrl/MainFormUnit.cpp @@ -4014,3 +4014,45 @@ void __fastcall TMainForm::FidonetPollMenuItemClick(TObject *Sender) //--------------------------------------------------------------------------- +void __fastcall TMainForm::FileMenuRunJSMenuItemClick(TObject *Sender) +{ + TOpenDialog* dlg=new TOpenDialog((TComponent*)Sender); + + dlg->Options << ofNoChangeDir; + dlg->Filter = "JavaScript files (*.js)|*.js"; + dlg->InitialDir=cfg.exec_dir; + if(dlg->Execute()==true) { + char cmdline[MAX_PATH+1]; + SAFEPRINTF2(cmdline,"%sjsexec.exe -p %s" + ,MainForm->cfg.exec_dir + ,dlg->FileName.c_str() + ); + STARTUPINFO startup_info={0}; + PROCESS_INFORMATION process_info; + startup_info.cb=sizeof(startup_info); + startup_info.lpTitle = cmdline; + if(!CreateProcess( + NULL, // pointer to name of executable module + cmdline, // pointer to command line string + NULL, // process security attributes + NULL, // thread security attributes + FALSE, // handle inheritance flag + 0, // creation flags + NULL, // pointer to new environment block + cfg.ctrl_dir, // pointer to current directory name + &startup_info, // pointer to STARTUPINFO + &process_info // pointer to PROCESS_INFORMATION + )) + Application->MessageBox(AnsiString("ERROR " + IntToStr(GetLastError()) + + " executing " + cmdline).c_str() + ,"ERROR" + ,MB_OK|MB_ICONEXCLAMATION); + // Resource leak if you don't close these: + CloseHandle(process_info.hThread); + CloseHandle(process_info.hProcess); + } + delete dlg; + +} +//--------------------------------------------------------------------------- + diff --git a/src/sbbs3/ctrl/MainFormUnit.dfm b/src/sbbs3/ctrl/MainFormUnit.dfm index 238f6b9b2358de2382ffa9ffad81cce6cdaf0cab..dbd8354edaea2a9a4b3a2e6504f9bf319551f2eb 100644 --- a/src/sbbs3/ctrl/MainFormUnit.dfm +++ b/src/sbbs3/ctrl/MainFormUnit.dfm @@ -13637,8 +13637,8 @@ object MainForm: TMainForm OnClick = RunJSClick end object FileMenuRunJSMenuItem: TMenuItem - Caption = 'Other JavaScript Module' - Visible = False + Caption = 'Other JavaScript Module...' + OnClick = FileMenuRunJSMenuItemClick end end object FileEditMenuItem: TMenuItem diff --git a/src/sbbs3/ctrl/MainFormUnit.h b/src/sbbs3/ctrl/MainFormUnit.h index 4a5ce69ecb5fdebab825c4a41d48ad267e9b5f47..fa689d751b062f9c83bc70de16738a428a9cd894 100644 --- a/src/sbbs3/ctrl/MainFormUnit.h +++ b/src/sbbs3/ctrl/MainFormUnit.h @@ -450,6 +450,7 @@ __published: // IDE-managed Components void __fastcall RefreshLogClick(TObject *Sender); void __fastcall FidonetConfigureMenuItemClick(TObject *Sender); void __fastcall FidonetPollMenuItemClick(TObject *Sender); + void __fastcall FileMenuRunJSMenuItemClick(TObject *Sender); private: // User declarations public: // User declarations __fastcall TMainForm(TComponent* Owner);