//************************************/ //* Leitura do arquivo Kiss */ //* da MEF minimizada */ //************************************/ // Realiza a leitura do formato .kiss void readCodedKiss(FILE *input, FILE *output) { do { fgets(aux , MAX , input); if (aux[0] == '.') switch (aux[1]) { case 'i': Ninput = nextNumber(0,aux); break; case 'o': Noutput = nextNumber(0,aux); break; case 'p': Ntrans = nextNumber(0,aux); break; case 's': Nstate = nextNumber(0,aux); break; default: break; } } while (!(aux[0] == '.' && aux[1] == 'e')); fgets(aux , MAX , input); fprintf(output, "# Codificação\n"); do { strtok(aux, "\n"); if (strstr(aux, ".code") != NULL) { for (int j = 0; j + 6 <= strlen(aux); j++) aux[j] = aux[j + 6]; fprintf(output, "# States.%s\n", aux); encode(aux); } fgets(aux , MAX , input); } while (!(aux[0] == '.' && aux[1] == 'e')); }
void weightedinterpolation_read(t_weightedinterpolation *x, t_symbol *s) { FILE* fp; t_float number; int index = 0; int structindex = 0; fp = fopen(s->s_name, "r"); if(fp == NULL) { error("Impossible to open the file \"%s\"", s->s_name); x->loaded = 0; return; } if(x->loaded) free(x->presets); while(nextNumber(fp)!=-1) { if(structindex == 0) x->presets = (t_preset*) malloc(sizeof(t_preset)); else x->presets = (t_preset*) realloc(x->presets, (structindex+1)*sizeof(t_preset)); index = 0; while(nextNumber(fp)==1) { fscanf(fp, "%f", &number); switch(index) { case 0: //post("x = %f\n", number); (x->presets+structindex)->x = number; break; case 1: //post("y = %f\n", number); (x->presets+structindex)->y = number; break; case 2: //post("mass = %f\n", number); (x->presets+structindex)->mass = number; break; default: (x->presets+structindex)->parameters[index-3] = number; break; } index++; } structindex++; } x->presetsSize = structindex; fclose(fp); x->loaded = 1; post("file loaded: \"%s\"", s->s_name); post("Number of presets: %d", x->presetsSize); //displayparameters(x); }
void MINIGAME_pressRightNumber() /* Minigame padrão */ { int n, i, c = randomNumber(0,2); /* Sorteia qual numero deve ser apertado */ for(i=0;i<MAX;i++) { n = randomNumber(0,2); /* Sorteia os numeros da sequencia */ sequence[i] = n; if(n==c) /* Se o numero for o que deve ser pressionado, iguale o pressArray a 1, mostrando que se deve pressionar nesse instante */ pressArray[i] = 1; else pressArray[i] = 0; } showSymbol(simbolo[sequence[0]]); /* Ja acende o primeiro numero da sequencia */ nextNumber(); getHelp(); }
std::string GUIDGenerator::getGUID() { std::string guid = ""; if (_withDate) { guid += currentDateTime(); guid += GUID_SEPARATOR; } guid += nextNumber(); guid += GUID_SEPARATOR; guid += randomString(_lengthOfRandomPart); return guid; }
void loop() { checkWrongPress(); loopTime = millis(); if(loopTime>timer+interval) { checkRightPress(); nextNumber(); getHelp(); checkForNextLevel(); timer = millis(); } }
/*! *\~english * Create new record in system journal. * Record create afte crate new document and use information about doc's * database id, prefix and metadata id(type). * Document number generate automatically by nextNumber(). *\~russian * Добавляет запись в системный журнал. * Запись добавляется после создания документа и использует информацию о его * id в базе данных, префиксе номера и id в конфигурации. * Номер досумента генерируется функцией nextNumber() *\~ *\param idd - \~english database document id.\~russian id базы данных.\~ *\param docPrefix - \~english document number prefix. \~russian перфикс номера документа.\~ *\param type - \~english document metadata id. \~russian id документа в конфигурации.\~ *\return \~english error code.\~russian код ошибки.\~ */ ERR_Code aDocJournal::New( qulonglong idd, const QString & docPrefix, int type ) { //qulonglong Uid =0;// db->uid( md_systemjournal ); aDataTable * t = table(); if ( !t ) return err_notable; //t->exec("LOCK TABLE a_journ WRITE"); //printf("insert into ajourn id=%llu idd=%llu, docPrefix=%s, type=%d\n",Uid,idd, (const char*)docPrefix.local8Bit(), type); // t->exec("LOCK TABLE a_journ WRITE"); QSqlRecord *rec; rec = t->primeInsert(); // get edit buffer for table elements // t->primeInsert(); //ide = rec->value("id").toULongLong(); //rec->setValue("id",Uid); rec->setValue("idd",idd); rec->setValue("typed",type); rec->setValue("num",nextNumber(docPrefix,type)); rec->setValue("pnum",docPrefix); rec->setValue("ddate",QDateTime::currentDateTime()); t->insert(); // insert edit buffer as new line in table //TODO: error handle aLog::print(aLog::Info, tr("aDocJournal new document with idd=%1").arg(idd)); /* t->primeInsert(); t->insert(); t->setSysValue( "id", Uid ); t->setSysValue( "idd", idd ); t->setSysValue( "typed", type ); t->setSysValue( "num", nextNumber(docPrefix,type) ); t->setSysValue( "pnum", docPrefix ); t->setSysValue( "ddate", QDateTime::currentDateTime() ); Update(); t->exec("UNLOCK TABLE"); */ int err = selectDocument( idd ); setSelected(!err); return err; }
/** * @brief HundredNum::next * @return the next NumerotationContext nc at position i */ NumerotationContext HundredNum::next (const NumerotationContext &nc, const int i) const { return (nextNumber(nc, i)); }
int createNewUninterpretedNumber() { return nextNumber(AtomType::LONETSEITIN); }
StringMath::Token StringMath::Lexer::next() { // strip whitespace while(peekWhitespace()) pop(); // note current position const int tokenLine = line; const int tokenColumn = column; // return empty token if no more characters if(input.empty()) return Token(tokenLine, tokenColumn); // search symbol set for longest match (longest is 3 characters) for(int i = 3; i >= 1; i--) { if(symbols.find(peek(i)) != symbols.end()) return Token(Token::Symbol, pop(i), tokenLine, tokenColumn); } // match an identifier ([a-z][a-z0-9]*) if(peekAlpha()) { std::string id = pop(); while(peekAlpha() || peekNumeric()) id += pop(); return Token(Token::Identifier, id, tokenLine, tokenColumn); } // match a binary number (0b[01]*(.[01]*)?) if(peek(2) == "0b") { pop(2); return nextNumber(2, tokenLine, tokenColumn); } // match an octal number (0o[0-7]*(.[0-7]*)?) if(peek(2) == "0o") { pop(2); return nextNumber(8, tokenLine, tokenColumn); } // match a hexadecimal number (0x[0-9a-f]*(.[0-9a-f]*)?) if(peek(2) == "0x") { pop(2); return nextNumber(16, tokenLine, tokenColumn); } // match a decimal number (([0-9]+.?|.)[0-9]*(e-?[0-9]*)?) if(peekNumeric() || peek() == ".") return nextNumber(10, tokenLine, tokenColumn); // match a function ({[\t-~]*}) if(peek() == "{") { pop(); std::string functionText; // collect all the characters comprising the function int unclosed = 1; // counting unclosed brackets enables nested functions while(unclosed > 0) { if(peek() == "{") { unclosed++; functionText += pop(); } else if(peek() == "}") { if(--unclosed > 0) functionText += pop(); else pop(); } else if(peek().empty()) { std::stringstream error; error << "acl::StringMath::Lexer: expected '}' at line " << line << " column " << column << "."; throw std::runtime_error(error.str()); } else functionText += pop(); } // return function if not empty if(functionText.find_first_not_of("\t\n\r ") == std::string::npos) { std::stringstream error; error << "acl::StringMath::Lexer: function at line " << tokenLine << " column " << tokenColumn << " is empty."; throw std::runtime_error(error.str()); } return Token(Token::Function, functionText, tokenLine, tokenColumn); } // return empty token if(!peek().empty()) { std::stringstream error; error << "acl::StringMath::Lexer: unexpected '" << peek() << "' at line " << tokenLine << " column " << tokenColumn << "."; throw std::runtime_error(error.str()); } return Token(tokenLine, tokenColumn); }