mercredi 1 juillet 2020

change image with for loop statement in Xamarin

I have 13 images shown in page ,one of them is fixed and others changed depend on some data ,i made 12 if statement and it works ,but is there way to create one if statement with for loop like thus :

for (int i = 2; i >= 13; i++)
            {
                if (m_id >= i)
                {
                    
                    "image" + i.Source = ImageSource.FromFile("months" + i + ".png");
                }
                else
                {
                    "image" + i.Source = ImageSource.FromFile("months"+i+"closed.png");
                }
            }

Excel - is there a BUT function?

I am currently trying to figure out a formula; I have the following: =IF(G18>109,"A*",IF(G18>103,"A",IF(G18>85,"B",IF(G18>67,"C","F"))))

This allows me to work out grades for my students in my French class but I want to add another part to the formula... I want it so that if C18:F18 says "INC", then the cell this formula is in says "inc" for an incomplete course.

Is that possible?

javascript if statement not working in while loop

I'm not sure what's missing. I tried applying the while under the 'ifs' and 'if elses' and while won't function unless it's on top. But the initial if is the only one coming up as undefined and I can't figure out why that is? I'm newer so sorry if it's a little messy.

you like to go on, musical, tropical, or adventurous?");

switch(vacationType){
    case "musical":
        alert("Musical! Sounds nice!")
            break;
    case "tropical":
        alert("Tropical! Nice!")
            break;
    case "adventurous":
        alert("Adventure Time!")
            break;}

while(vacationType != "musical" && vacationType != "tropical" && vacationType != "adventurous") {
    vacationType = prompt("Oops! Lets try again: musical, tropical, or adventurous?");
}
if(vacationType == "musical"){
    destinatiion = "New Orleans";
}
else if (vacationType === "tropical"){
    destination = "a tropical beach vacation in Mexico";
}
else if (vacationType === "adventurous"){
    destination = "a whitewater rafting adventure in the Grand Canyon";
}```


QR Code verification for if-else statements

I am writing a code for a QR Code Scanner which scans only recognizes specific QR Codes and redirects to another activity. Here's the code

@Override
public void handleResult(Result result) {
    final String scanResult = result.getText();
    if (scanResult.equals("abcd")) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("Scan");
        builder.setMessage("QR Code verified. Proceed?");
        builder.setPositiveButton("Continue", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                Intent intent1 = new Intent(MainActivity.this, buttons.class);
                startActivity(intent1);
            }
        });
        builder.setNegativeButton("Close", null);
        
    }
    else {
        Toast.makeText(this, "unrecognized", Toast.LENGTH_LONG).show();
        scannerView.resumeCameraPreview(MainActivity.this);


    }
  }
}

The code works for the else statement, ie, if the result isn't "abcd", the Toast message is displayed.

But when the result is "abcd", the scanner freezes and the intent i have added, ie, buttons.class to be launched doesnt work (the activity doesnt start). The app is stuck on the scanned QR Code and doesnt move ahead. How do i fix that?

Add a new column in R based on other columns

I'm trying to clean up a data sheet that has multiple test results. We're considering a positive from any of the results to mean the person is positive. So I'm trying to create a code where if any of the test results are positive, then the diagnosis is positive. If there are no positives and at least one negative, then the diagnosis is negative (ex. Patients 4, 5 and 6). I also want to omit rows where there are no results (ie. NA) for all of the rows (ex. Patient 8). Can anyone help me with this? I tried this ifelse statement, but it's not working

practice$Diagnosis = ifelse((testresult_1 == "1"|testresult_2 == "1"|testresult_3 == "1"), "Positive", "Negative")
Patient ID     testresult_1   testresult_2    testresult_3  Diagnosis
1                Positive      Negative        Negative     Positive
2                Positive      Positive        Negative     Positive
3                Negative      Negative        Positive     Positive
4                Negative      Negative        Negative     Negative
5                Negative      Negative        NA           Negative
6                Negative      NA              NA           Negative
7                Positive      NA              NA           Positive
8                NA            NA              NA            NA

Testing css values with jQuery if statement

I am trying to create an on-scroll animation but I am quite unfamiliar with JQuery. At this point I can make the div element rotate, relative to the page scroll position, but I want it to have a static value once it reaches a certain degree. So I've tried to add an if statement but I'm not sure how to go about it. Please let me know what I'm doing wrong.

$(document).ready(function(){
    $(document).scroll(function(){
    var scollHeight = $(document).height(); 
    var maxRotate = 55;
    var rotateVal =  2 + (($(document).scrollTop()* maxRotate) / scollHeight)*4;
    
    
    $("#bag-holder").css("transform", "rotate("+(-rotateVal)+"deg)");

    if($("#bag-holder").css("transform", "rotate") > 90 + "deg") { 
      $("#bag-holder").css("transform", "rotate(110deg)");
    }

  });

});
*{
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}

body{
    background-image: linear-gradient(to top, 
    #a18cd1 0%, 
    #fbc2eb 100%);
    height: 200vh;
    overflow-x: hidden;
  }

#plastic-bag{
    transform: scale(0.1);
    transform-origin: center;
}

#bag-holder{
    position: fixed;
    top: -90%;
    left: 0;
    transform-origin: center;
    z-index: 50;

}
<html>
<head>
  <title>Supa Ginja</title>
  <link rel="stylesheet" href="style.css">
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="script.js"></script>
</head>


<div class="item-holder" id="bag-holder" data-type="parallax" data-depth="3">
  <img id="plastic-bag" src="SupaGinja-pic.png">
</div>


</html>

using else if in a function in R

I 'm trying to use else if within a function in R

new<-function(a,b,c,d){
if (a==1){
var1<-100+100+100
var2<-500+500+500
var3<-500-100

}else if (a==2){
var1<-100+100
var2<-500+500
var3<-500-10
} else if (a==3){
var1<-100
var2<-500
var3<-500
}

b<-var1-var2

c<- var2+var3

d<-var3-var1

if (b<100)
{print ("the value is good")
}else if (b>100)
{ print("check teh value")
}else 
{print ("repeat")
}
}

output<-new(3,b,c,d)

I feel something fundamental is wrong with this which I m missing. I 'm trying to use else if to populate the values to be used as an input to call the same fucntion.

Help is greatly appreciated