Exemplo n.º 1
0
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;
    }
  }
}
Exemplo n.º 2
0
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;
}
Exemplo n.º 3
0
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;
}
Exemplo n.º 4
0
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;
}
Exemplo n.º 5
0
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;
}
Exemplo n.º 6
0
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;
}
Exemplo n.º 7
0
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;
}
Exemplo n.º 8
0
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;
}
Exemplo n.º 9
0
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;
}