Skip to content
Snippets Groups Projects
Commit 90a00f8b authored by rswindell's avatar rswindell
Browse files

Enable the File->Run->Other JavaScript Module menu item.

Allows sysop to select the .js file from the exec directory, but does not yet
allow them to specify/add any command-line options.
parent aa0303c0
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
//---------------------------------------------------------------------------
......@@ -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
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment