In anylogic. in the system dynamic. i want to use if-else - dynamic

The code is like
if ( evaluaterate<1){
Deliveryrate=min(Oldproduct,ForecastCan);
else
0;
}
It says that syntax errors

Please see my comment and try to get to this:
if (evaluaterate<1)
{
Deliveryrate=min(Oldproduct,ForecastCan);
}
else
{
Deliveryrate = 0;
}

Try this:
Deliveryrate=evaluaterate<1 ? min(Oldproduct,ForecastCan) : 0;

Related

How to read the value of a ReactNative.Style.t property with reason-react-native?

I would like to do the following:
let marginTop =
if (itemInfo##index == 0) {
Style.viewStyle(~marginTop=style##paddingTop, ());
} else {
Style.viewStyle();
}
But I get the following error:
This has type:
ReactNative.Style.t (defined as ReactNative.Style.t)
But somewhere wanted:
Js.t('a)
Does anyone knows how I can read the value?
It doesn't look too good of an idea to do it like so.
But in case you were wondering:
StyleSheet.flatten(styles)##paddingTop

I am trying below code but its throwing similar result every time

I am trying below code but its throwing similar result every time.. Let me know if i am doing something wrong
driver.get("https://www.google.com/search?hl=en&gl=in&tbm=nws&authuser=0&q=The+Telegraph%27s+Production+Manager+To+Take+Over+The&gws_rd=ssl");
java.util.List<WebElement> competitor_name = driver.findElements(By.className("slp"));
for (int i = 0; i < competitor_name.size(); i++)
{
String cmp_name = competitor_name.get(i).findElement(By.xpath("//span[#class='_tQb _IId']")).getText();
System.out.println("Competitor name is : "+cmp_name );
}
Can you try below way which will build correct xpath so that we get out of this issue
String cmp_name = competitor_name.get(i).findElement(By.xpath("span[#class='_tQb _IId']")).getText();

Where clause using some field is not returning any rows in phonegap

I am finding one funny error but not sure whether that is my mistake or not. Below is my code for phonegap storage application. I have to fetch the records by one field in SELECT Query. If I try without where condition it s working but with where clause it is not working. Anyone have an idea on this?
function setDetailWordList()
{
db.transaction(SetDetailWords);
}
function SetDetailWords(tx)
{
alert("Qiuery executing...");
alert('SELECT * FROM DW_Words WHERE word = "'+word+'"');
tx.executeSql('SELECT * FROM DW_Words where word = "'+word+'"', [], SetDetailWordsSuccess);
}
function SetDetailWordsSuccess(tx,results)
{
alert(results.rows.length);
$('#words').html("").listview('refresh');
for (var i=0; i < results.rows.length; i++)
{
$('#words').append('<li><a><div>'+results.rows.item(i).explanation+'</div></a></li>');
}
$('#words').listview('refresh');
//AddEvents();
}

Else without If error... and I don't know why

The code below is action taken when a button is clicked on a simple form. The problem comes with the one if/else block. The If line is not terminated. The Else line is not terminated. But I have a consistent error that my Else exists without an If. I can't see why. I need someone smarter than me to identify what is going on here.
Thank you in advance!
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
FileFilter filter;
filter = new FileNameExtensionFilter("Comma Separated Value files","csv","txt");
JFileChooser chooser;
chooser = new JFileChooser();
chooser.addChoosableFileFilter(filter);
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
int showDialog = chooser.showDialog(this, null);
File selectedFile = chooser.getSelectedFile();
String filename;
filename = selectedFile.getAbsolutePath();
if (filter.accept(selectedFile))
{
jTextField2.setText(filename);
jTextField2.setBackground(Color.white);
else
jTextField2.setText("You Did NOT Select a CSV File.");
jTextField2.setForeground(Color.black);
jTextField2.setBackground(Color.red);
}
}
You are missing the bracket '}' after "jTextField2.setBackground(Color.white);" and else.code is here
if (filter.accept(selectedFile))
{
jTextField2.setText(filename);
jTextField2.setBackground(Color.white);
}
else
{
jTextField2.setText("You Did NOT Select a CSV File.");
jTextField2.setForeground(Color.black);
jTextField2.setBackground(Color.red);
}
The SYNTAX for if-else Block looks like this:-
if {
// statements
} else {
//statements
}
Now if you are having only ONE statement inside the if Or else part then you can afford to skip the curly braces{ } otherwise you surely need to put those curly braces as compiler looks for it can terminate the execution of if statement.
However, it is always recommended to use the braces even if u have only ONE statement inside the if or else part as it improves the readability of the code.
You need to close your "if" and "else" blocks.
Example: if {} else {}.
if (filter.accept(selectedFile)) {
jTextField2.setText(filename);
jTextField2.setBackground(Color.white);
} else {
jTextField2.setText("You Did NOT Select a CSV File.");
jTextField2.setForeground(Color.black);
jTextField2.setBackground(Color.red);
}
The if's closing bracket is missing just before the else.

Password check from the database, what am I doing wrong?

-(IBAction)EnterButtonPressed:(id)sender
{
const char *sql = "SELECT AccessCode FROM UserAccess";
double result = ([Password.text doubleValue]);
if(sql == result )
{
NSLog(#"Correct");
}
else {
NSLog(#"Wrong");
}
}
The main thing you're doing wrong is not sending that SQL query to the database. You probably ought to add in some kind of WHERE clause too. And... well, there's quite a lot wrong with that code to be honest.