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; } } }
double GetMouseY() { if (TcpClient == NULL) Error("Graphics not initialized"); string resp = TcpClient->ExchangeMsg("GETMOUSEY"); double val; try { val = StringToReal(resp); } catch (ErrorException e) { Error("GetMouseY: " + resp); } return val; }
double GetYResolution() { if (TcpClient == NULL) Error("Graphics not initialized"); string resp = TcpClient->ExchangeMsg("GETYRESOLUTION"); double val; try { val = StringToReal(resp); } catch (ErrorException e) { Error("GetYResolution: " + resp); } return val; }
double GetFontHeight() { if (TcpClient == NULL) Error("Graphics not initialized"); string resp = TcpClient->ExchangeMsg("GETFONTHEIGHT"); double val; try { val = StringToReal(resp); } catch (ErrorException e) { Error("GetCurrentX: " + resp); } return val; }
int GetStyle() { if (TcpClient == NULL) Error("Graphics not initialized"); string resp = TcpClient->ExchangeMsg("GETSTYLE"); double val; try { val = StringToReal(resp); } catch (ErrorException e) { Error("GetCurrentX: " + resp); } return val; }
double GetWindowWidth() { if (TcpClient == NULL) Error("Graphics not initialized"); string resp = TcpClient->ExchangeMsg("GETWINDOWWIDTH"); double val; try { val = StringToReal(resp); } catch (ErrorException e) { Error("GetWindowWidth: " + resp); } return val; }
double GetFullScreenHeight() { if (TcpClient == NULL) Error("Sorry, in this version you need to run InitGraphics BEFORE GetFullScreenWidth/Height"); string resp = TcpClient->ExchangeMsg("GETFULLSCREENHEIGHT"); double val; try { val = StringToReal(resp); } catch (ErrorException e) { Error("GetFullScreenHeight: " + resp); } return val; }
double TextStringWidth(string text) { if (TcpClient == NULL) Error("Graphics not initialized"); stringstream cmd; cmd << "TEXTSTRINGWIDTH " << text; string resp = TcpClient->ExchangeMsg(cmd.str()); double val; try { val = StringToReal(resp); } catch (ErrorException e) { Error("TextStringWidth: " + resp); } return val; }
double GetPictureHeight(string name) { if (TcpClient == NULL) Error("Graphics not initialized"); stringstream cmd; cmd << "GETPICTUREHEIGHT " << name; string resp = TcpClient->ExchangeMsg(cmd.str()); double val; try { val = StringToReal(resp); } catch (ErrorException e) { Error("GetPictureHeight: " + resp); } return val; }