i don't know how to use it ?
i = iimPlay("#current",60);
s = iimGetLastExtract();
if (s.indexOf ("Your Answer") != -1)
iimplay ("9kweu_media",60);
else
iimplay ("recaptcha_v2cap:"+s);
Related
As the title, when I create the pdf, accented characters are not shown or appear this ì, how can I solve? I already tried with several encoding, but doesn't works.
Thanks lot in advance
PoDoFo::PdfFont* pFont = document->CreateFont("Liberation Serif", false, false, false, PoDoFo::PdfEncodingFactory::GlobalStandardEncodingInstance());
tablemodelint->SetFont(pFont);
if(dataSel1.GetWeekDay() == wxDateTime::WeekDay::Mon)
giorno = "Lunedì";
else if(dataSel1.GetWeekDay() == wxDateTime::WeekDay::Tue)
giorno = "Martedì";
else if(dataSel1.GetWeekDay() == wxDateTime::WeekDay::Wed)
giorno = "Mercoledì";
else if(dataSel1.GetWeekDay() == wxDateTime::WeekDay::Thu)
giorno = "Giovedì";
else if(dataSel1.GetWeekDay() == wxDateTime::WeekDay::Fri)
giorno = "Venerdì";
else if(dataSel1.GetWeekDay() == wxDateTime::WeekDay::Sat)
giorno = "Sabato";
else if(dataSel1.GetWeekDay() == wxDateTime::WeekDay::Sun)
giorno = "Domenica";
tablemodelint->SetText(1, 0, giorno + ", " + dataSel1.Format("%d-%m-%y").ToStdString());
I got some issue with useState and "if else" statement. I wanted to change displayed text with a click.
When I checking if counter icrement is working, it works, but when I add setText in "if else" statement there is a problem and just doesnt work properly. Icnrement strats to work strange when clicking and change a text is just imposible. Even in console increment looks wrong. Can someone help what I am doing wrong?
let counter = 0;
const [txt, setTxt] = useState("Text1");
const handleClick = (e) => {
if (
e.target.classList.contains("fa-angle-right") || e.target.classList.contains("fa-angle-left")
) {e.target.classList.contains("fa-angle-right") ? counter++ : counter--;
if (counter === 1) {
console.log(counter);
setTxt("Text2");
} else if (counter === 2) {
console.log(counter);
setTxt("Txt3")
} else if (counter > 2) {
counter = 0;
console.log(counter);
setTxt("Text1");
} else if (counter < 0) {
counter = 2;
console.log(counter);
setTxt("Text3");
} else if (counter === 0) {
console.log(counter);
setTxt("Txt1");
}
}
};
Every time setTxt('...') is executed, the component is re-rendered and the function executes again, so counter gets the value of 0.
If you want to preserve the value of your counter between renders, put it as a new state ( const [counter, setCounter] = useState(0) )
OK, #AdriánFernándezMartínez I did that way and its close. Just after first clik, in a first "if" (if (counter === 1)) console shows 0 and i have to click twice to chage it and change Txt (but is should be 1 after setCounter(counter + 1)). Next, in a third "if" (else if (counter > 2)) console shows 3 and again I need to click twice to change Txt (after 1st click its 0 and after 2nd it become 1). Still need help.
const [counter, setCounter] = useState(0);
const [txt, setTxt] = useState("Text1");
const handleClick = (e) => {
if (
e.target.classList.contains("fa-angle-right") ||
e.target.classList.contains("fa-angle-left")
) {
e.target.classList.contains("fa-angle-right")
? setCounter(counter + 1)
: setCounter(counter + 1);
console.log(counter);
if (counter === 1) {
console.log(counter);
setTxt("Text2");
} else if (counter === 2) {
console.log(counter);
setTxt("Text3");
} else if (counter > 2) {
setCounter(0);
console.log(counter);
setTxt("Text1");
} else if (counter < 0) {
setCounter(2);
console.log(counter);
setTxt("Text3");
} else if (counter === 0) {
console.log(counter);
setTxt("Text1");
}
}
};
I'm working on this project where I set up some commands that my TelegramBot can execute. And I would like to add an error message if the command written is wrong. Here is the code:
void handleNewMessages(int numNewMessages){
Serial.print("Handle New Messages: ");
Serial.println(numNewMessages);
for (int i = 0; i < numNewMessages; i++){
// Chat id of the requester
String chat_id = String(bot.messages[i].chat_id);
if (chat_id != chatId){
bot.sendMessage(chat_id, "Unauthorized user", "");
continue;
}
// Print the received message
String text = bot.messages[i].text;
Serial.println(text);
String fromName = bot.messages[i].from_name;
if (text == "/FlashOn") {
flashState = HIGH;
digitalWrite(LED, flashState);
}
if (text == "/FlashOff") {
flashState = LOW;
digitalWrite(LED, flashState);
}
if (text == "/photo") {
sendPhoto = true;
Serial.println("New photo request");
}
if (text == "/PIRON"){
PirControler = 1;
bot.sendMessage(chatId, "PIR Sensor is ON, you will get a notification if a motion is detected.", "");
}
if (text == "/PIROFF"){
PirControler = 0;
bot.sendMessage(chatId, "PIR sensor is OFF, you will no longer receive any notification.", "");
if (text == "/start"){
String welcome = "Hi sir, here are the commands I can execute for you :\n";
welcome += "/Photo : Take a new photo.\n";
welcome += "/FlashOn : Turns LED On.\n";
welcome += "/FlashOff : Turns LED off\n";
welcome += "/PIRON : Activate your PIR sensor.\n";
welcome += "/PIROFF : Shut your PIR sensor down.\n";
// welcome += "/readings : request sensor readings\n\n";
welcome += "You'll receive a photo whenever motion is detected.\n";
bot.sendMessage(chatId, welcome, "Markdown");
}
/*else {
bot.sendMessage(chatId, "I don't understand, sorry. Refer to the commands I showed you above.", "");
} **(Here is the message that I'd like to add)**
}
}
However, by trying to add the last line,
/*else {
bot.sendMessage(chatId, "I don't understand, sorry. Refer to the commands I showed you above.", "");
}*/
It returns an error to all the right commands except for the "/start" one.
Any ideas on how I could do that would be much appreciated :)
Let's make the example smaller
if (text == "/FlashOn") {
do stuff
}
if (text == "/start"){
do stuff
}
else {
report error
}
This code will always test if (text == "/start") regardless of the outcome of if (text == "/FlashOn") and if text is "/FlashOn", it cannot be "/start" and will execute the else and print the error message.
Solution
if (text == "/FlashOn") {
do stuff
}
else if (text == "/start"){
do stuff
}
else {
report error
}
Now if (text == "/start") will not be tested and the else case will not be run if text == "/FlashOn".
What this looks like if fully indented and bracketed:
if (text == "/FlashOn") {
do stuff
}
else {
if (text == "/start"){
do stuff
}
else {
report error
}
}
I want to make a code to assign logic input for my sheet. I use IF to make it. My code ran successfully but the logic didn't work. I have checked it many times, but I couldn't find something wrong. Can you help me with this? I'm stuck. Please review my example sheet and my script for more information. Thank you! https://docs.google.com/spreadsheets/d/1eV2SZ45Gs6jISgh_p6RIx-rfOGlHUM6vF114Mgf6c58/edit#gid=0
function logic(){
var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var activeCell = ss.getActiveCell();
if (activeCell.getColumn() == 1 && activeCell.getRow() > 1 && ss.getSheetName() == "mama" && activeCell.getValue() == "Yes") {
activeCell.offset(0,1).clearContent();
activeCell.offset(0,1).setValue("1");
} if (activeCell.getColumn() == 1 && activeCell.getRow() > 1 && ss.getSheetName() == "mama" && activeCell.getValue() == "Hafl") {
activeCell.offset(0,1).clearContent();
activeCell.offset(0,1).setValue("1/2");
} if (activeCell.getColumn() == 1 && activeCell.getRow() > 1 && ss.getSheetName() == "mama" && activeCell.getValue() == "No") {
activeCell.offset(0,1).clearContent();
activeCell.offset(0,1).setValue(0);
}
}
You can simplify your code this way.
(Note that I use the const variable declaration instead of var (ES6 - V8 engine))
function logic() {
const ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
const activeCell = ss.getActiveCell();
const activeCellValue = activeCell.getValue();
if (activeCell.getColumn() === 1 && activeCell.getRow() > 1 && ss.getSheetName() == "mama") {
switch(activeCellValue) {
case 'Yes':
activeCell.offset(0, 1).clearContent();
activeCell.offset(0, 1).setValue('1');
break;
case 'Half':
activeCell.offset(0, 1).clearContent();
activeCell.offset(0, 1).setValue('1/2');
break;
case 'No':
activeCell.offset(0, 1).clearContent();
activeCell.offset(0, 1).setValue('0');
break;
}
}
}
This way you only have to test the common conditions once.
Using the Switch function clearly shows the behavior of the script depending on the input value 'ActiveCellValue'.
If you need that only one action resolve per run, you need to use else if to chain the statements:
if(statement){
Action
}else if (statement2){
Action2
}else if...
Okay I have a problem. I am using an IF statement. It seems to not run like it should. It works fine without the || condition, but with the || it seems to just pull the text under and not run the ELSE...
var fateText : UI.Text;
var inputText : UI.Text;
function fateBall () {
if(inputText.text == "illuminati"||"Illuminati"){
fateText.text = "We run the entire world. Join us!";
}else{
var myRandomString : String = RandomWordString(1);
fateText.text = myRandomString;
}
}
If i remove the ||"Illuminati" it works great... but like this it assigns fateText.text to "We run the entire world." and not the myRandomString
EDIT REPORT: Okay, the .ToLower() worked great now I am running into a problem where when I add multiple IFs it just bypasses the IFs and just runs the ELSE... any ideas?
function fateBall () {
if(inputText.text.ToLower() == "illuminati"){
fateText.text = "We run the entire world. Join us!";}
if(inputText.text.ToLower() == "satan"){
fateText.text = "Lucifer is the Light Bringer. He leads us against God!";}
if(inputText.text.ToLower() == "devil"){
fateText.text = "Lucifer is the Light Bringer. He leads us against God!";}
if(inputText.text.ToLower() == "lucifer"){
fateText.text = "Lucifer is the Light Bringer. He leads us against God!";}
else{
var myRandomString : String = RandomWordString(1);
fateText.text = myRandomString;
}
}
The condition must be :
if(inputText.text == "illuminati" || inputText.text == "Illuminati")
Otherwise, you can set to lower all the text so as to be case-independant :
if(inputText.text.ToLower() == "illuminati")
An even better way to compare strings is to use the Equals function (C# only though)
if( String.Equals( inputText.text, "illuminati", System.StringComparison.InvariantCultureIgnoreCase)
EDIT further to your EDIT:
string lowerText = inputText.text.ToLower() ;
if(lowerText == "illuminati")
{
fateText.text = "We run the entire world. Join us!";
}
else if(lowerText == "satan")
{
fateText.text = "Lucifer is the Light Bringer. He leads us against God!";
}
else if(lowerText == "devil")
{
fateText.text = "Lucifer is the Light Bringer. He leads us against God!";
}
else if(lowerText == "lucifer")
{
fateText.text = "Lucifer is the Light Bringer. He leads us against God!";
}
else
{
var myRandomString : String = RandomWordString(1);
fateText.text = myRandomString;
}
Try changing the condition from:
inputText.text == "illuminati"||"Illuminati"
To this:
inputText.text == "illuminati"|| inputText.text =="Illuminati"
I don't think you can chain conditions like that.
In addition you may want to just use a lowercase function to simplify your condition. So I believe you can do the following instead.
if(inputText.text.ToLower()=="illuminati")
If you want to check multiple condidtions in one if statement do it like this:
if (var1 == condition1 || var2 == condition2){}
this will check if either one return true, but you can also check if multiple statements are true by using:
if (var1 == condition1 && var2 == condition2){}