int main () { stackADT operandStack; string line; char ch; printf("RPN kalkulator -- symulacja (napisz H aby otrzymać pomoc)\n"); operandStack=NewStack(); while (TRUE) { printf("> "); line=GetLine(); ch=toupper(line[0]); switch (ch) { case 'Q': exit(0); case 'H': HelpCommand(); break; case 'C': ClearStack(operandStack); break; case 'D': DisplayStack(operandStack); break; default: if (isdigit(ch)) Push(operandStack, StringToReal(line)); else ApplyOperator(ch, operandStack); break; } } }
void wxLuaConsole::OnMenu(wxCommandEvent& event) { switch (event.GetId()) { case wxID_NEW : { m_textCtrl->Clear(); break; } case wxID_SAVEAS : { wxString filename = wxFileSelector(wxT("Select file to save output to"), m_saveFilename.GetPath(), m_saveFilename.GetFullName(), wxT("txt"), wxT("Text files (*.txt)|*.txt|All files (*.*)|*.*"), wxFD_SAVE|wxFD_OVERWRITE_PROMPT, this); if (!filename.IsEmpty()) { m_saveFilename = wxFileName(filename); m_textCtrl->SaveFile(filename); } break; } case wxID_COPY : { long from = 0, to = 0; m_textCtrl->GetSelection(&from, &to); m_textCtrl->SetSelection(-1, -1); m_textCtrl->Copy(); m_textCtrl->SetSelection(from, to); break; } case ID_WXLUACONSOLE_SCROLLBACK_LINES : { long lines = wxGetNumberFromUser(wxT("Set the number of printed lines to remember, 0 to 10000.\nSet to 0 for infinite history."), wxT("Lines : "), wxT("Set Number of Scrollback Lines"), m_max_lines, 0, 10000, this); if (lines >= 0) SetMaxLines(lines); break; } case ID_WXLUACONSOLE_BACKTRACE : { if (m_luaState.IsOk()) { DisplayStack(m_luaState); //wxLuaStackDialog dlg(m_wxlState, this); //dlg.ShowModal(); } break; } default : break; } }