/*--------------------------------------------------------------------------*/ void SwitchConsole(void) { char *ConsoleName = getScilexConsoleName(); switch (GetConsoleState()) { /* La fenetre etait cachée , on la restaure */ case 0: { ShowScilex(); } break; /* La fenetre etait apparente , on la cache */ case 1: { HideScilex(); } break; } if (ConsoleName) { SetConsoleTitle(ConsoleName); FREE(ConsoleName); ConsoleName = NULL; } }
types::Function::ReturnValue sci_consolebox(types::typed_list &in, int _iRetCount, types::typed_list &out) { if (in.size() < 0 || in.size() > 1) { Scierror(77, _("%s: Wrong number of input argument(s): %d or %d expected.\n"), "consolebox", 0, 1); return types::Function::Error; } if (getScilabMode() != SCILAB_STD) { sciprint(_("Only on Windows Mode, not in Console Mode.\n")); out.push_back(new types::String(L"off")); return types::Function::OK; } //request mode if (in.size() == 0) { if (GetConsoleState()) { out.push_back(new types::String(L"on")); } else { out.push_back(new types::String(L"off")); } return types::Function::OK; } types::InternalType* pIT1 = in[0]; if (pIT1->isString() == false) { Scierror(999, _("%s: Wrong type for input argument #%d: String expected.\n"), "consolebox", 1); return types::Function::Error; } types::String* pS1 = pIT1->getAs<types::String>(); if (pS1->isScalar() == false) { Scierror(999, _("%s: Wrong size for input argument #%d: string expected.\n"), "consolebox", 1); return types::Function::Error; } std::wstring wcsAction(pS1->get(0)); if (wcsAction == L"on") { SetConsoleState(1); ShowScilex(); } else if (wcsAction == L"off") { SetConsoleState(0); HideScilex(); } else if (wcsAction == L"toggle") { SwitchConsole(); } else { Scierror(999, ("%s: Wrong input argument: '%s', '%s' or '%s' expected.\n"), "consolebox", "on", "off", "toggle"); return types::Function::Error; } if (GetConsoleState()) { out.push_back(new types::String(L"on")); } else { out.push_back(new types::String(L"off")); } return types::Function::OK; }
/*--------------------------------------------------------------------------*/ int sci_consolebox(char *fname,unsigned long l) { static int l1,n1,m1; char *Output=NULL; Rhs=Max(Rhs,0); CheckRhs(0,1); CheckLhs(0,1); Output=(char*)MALLOC(4*sizeof(char)); if (Rhs==0) { if (getScilabMode() == SCILAB_STD) { if (GetConsoleState()) strcpy(Output,"on"); else strcpy(Output,"off"); } else { sciprint(_("Only on Windows Mode, not in Console Mode.\n")); strcpy(Output,"off"); } } else if (GetType(1) == sci_strings) { char *param=NULL; GetRhsVar(1,STRING_DATATYPE,&m1,&n1,&l1); param=cstk(l1); if ( (strcmp(param,"off")==0) || (strcmp(param,"on")==0) || (strcmp(param,"toggle")==0) ) { if (getScilabMode() == SCILAB_STD) { if (strcmp(param,"on")==0) { SetConsoleState(1); ShowScilex(); strcpy(Output,"on"); } else if (strcmp(param,"off")==0) { SetConsoleState(0); HideScilex(); strcpy(Output,"off"); } else /* toggle */ { SwitchConsole(); if (GetConsoleState()) strcpy(Output,"on"); else strcpy(Output,"off"); } } else { sciprint(_("Only on Windows Mode, not in Console Mode.\n")); strcpy(Output,"off"); } } else { Scierror(999,("%s: Wrong input argument: '%s', '%s' or '%s' expected.\n"),fname,"on", "off", "toggle"); return 0; } } else { Scierror(999,("%s: Wrong input argument: '%s', '%s' or '%s' expected.\n"),fname,"on", "off", "toggle"); return 0; } n1=1; CreateVarFromPtr(Rhs+ 1,STRING_DATATYPE,(m1=(int)strlen(Output), &m1),&n1,&Output); if (Output) {FREE(Output);Output=NULL;} LhsVar(1) = Rhs+1; PutLhsVar(); return 0; }