#include <WScom.h>
#include <WSCfunctionList.h>
#include <WSCbase.h>
#include <WSCvlabel.h>

//----------------------------------------------------------
//Function for the event procedure
//----------------------------------------------------------

//표시라벨의 외부 접근선언
extern WSCvlabel* newvlab_001;
WSCvariant value1;
void opbtnep(WSCbase* object){
  //do something...
  WSCvariant val2 = newvlab_001->getProperty(WSNlabelString);
  long op = (long)newvlab_001->getUserData("op-input");
  if (op == 1){
    value1 = (double)((double)value1 + (double)val2);
  }else
  if (op == 2){
    value1 = (double)((double)value1 - (double)val2);
  }else
  if (op == 3){
    value1 = (double)((double)value1 * (double)val2);
  }else
  if (op == 4){
    value1 = (double)((double)value1 / (double)val2);
  }else{
    value1 = val2;
  }
  //연산자 단추의 WSNlabelString 속성에서 문자열을 꺼낸다.
  WSCvariant val = object->getProperty(WSNlabelString);
  if (!strcmp(val,"+")){
    newvlab_001->setUserData("op-input",(void*)1);
  }else
  if (!strcmp(val,"-")){
    newvlab_001->setUserData("op-input",(void*)2);
  }else
  if (!strcmp(val,"*")){
    newvlab_001->setUserData("op-input",(void*)3);
  }else
  if (!strcmp(val,"/")){
    newvlab_001->setUserData("op-input",(void*)4);
  }else{
    newvlab_001->setUserData("op-input",(void*)0);
  }
  char buffer[128];
  sprintf(buffer,"%g",(double)value1);
  if (strlen(buffer)>12){
    buffer[13] = 0;
  }
  newvlab_001->setProperty(WSNlabelString,buffer);
  newvlab_001->setUserData("num-input",(void*)0);
  newvlab_001->setUserData("dot-input",(void*)0);

}
static WSCfunctionRegister  op("opbtnep",(void*)opbtnep);
