samedi 31 janvier 2015

If/Then statements with checkboxes (html)

I'm trying to create an if/then statement that goes along the lines of: if all of the checkboxes are checked then show this image, else show this other image. I'm completly stuck and not sure what to do...


R: Checking dataframe value in "if" statement

I need to fix a mistake in how data was entered in a column, so I wrote a set of "if" statements in a while loop to fix it. But the equal sign in if(df1[n,2] = 1) causes an error. What do I need to change?



while(n<=424){
if(df1[n,2] = 1){
df1[n+1,2] <- df1[1,2]
df1[n+2,2] <- df1[1,2]
n <- n+3

Im having trouble with using mutliple parts to an if/else statement.

This is a pearson myprogramming lab exercise. Not exactly what the error message is referring to. I tried flipping the choice = B and choice = T sections and what occurred was the error message just then said that there was an issue with the choice = B else missing if.





CTest.java:17: error: 'else' without 'if'
else if(choice = T)
^

1 import java.util.Scanner;
2
3 class CTest {
4 public static void main(String [] args) {
5 Scanner stdin = new Scanner(System.in);
6
7 int age = 0;
8 String choice = null;
9
10 System.out.print("Enter your menu selection: ");
11 choice = stdin.nextString();
12 if(choice = S);
13 {
14 if(age <= 21)
15 System.out.println("Vegetable Juice");
16 else System.out.println("Cabernet");
17 }
18 else if(choice = T)
19 {
20 if(age <= 21)
21 System.out.println("Cranberry Juice");
22 else System.out.println("Chardonnay");
23 }
24 else if(choice = B)
25 {
26 if(age <= 21)
27 System.out.println("soda");
28 else System.out.println("IPA");
29 }
30 else
31 {
32 System.out.println("invalid menu selection");
33 }
34
35
36 }
37 }



How do I use relationships btwn 3 integers to determine a triangle and/or what declaration can I use to make this program work?

I am trying to create a program that can use relationships to determine the type of triangle being calculated. I have tried float and double declarations but either way the end result is incorrect and is draving me crazy. Basically the program does not regognize "c" as being equal to a/b for every like value.(Ex. enter 7 7 for sides a and b, and 60 for angle, should yield an equilateral, but does not.) Any ideas as to how I might address this? Thank you so much!



#include <iostream>
#include <cmath>
#define pi 3.14159265358989

using namespace std;

int main()
{
float a, b, c, d, C;


cout << "Hello. I can calculate the missing length of a triangle" << endl;
cout << "by using using the information you provide." << endl;
cout << "Please enter two positive integers between 1-99 and separate them with a space. " << endl;
cin >> a >> b;
cout << "Side 1 equals: " << a << endl;
cout << "Side 2 equals: " << b << endl;
cout << "Please enter the angle between the two sides you just entered. " << endl;
cin >> d;

C = d * (pi / 180); // convert rad to deg
//Compute missing side
c = sqrt((a*a) + (b*b) - 2 * a * b * cos(C));
cout << "The length of the third side of the triangle is: " << c << endl;

if (a == b && b == c) //all sides are equal
cout << "This is an Equilateral Triangle." << endl;

else if (a == b && b != c) // if 2 sides are equal

cout << "This is an Isosceles Triangle. " << endl;

else if (a != b && b != c) // if no sides are equal

cout << "This is a Scalene Triangle. " << endl;


system ("pause");
return 0;


}


checking multiple if statements

let's say I wanted to organize a list of numbers by positive, negative, and floats. how would I get this code to add a number to multiple lists such as pos and flt? For example 5.6. instead of just adding it to pos and moving on to the next one with out checking if 5.6 is a float as well?


Thanks



list_num=[1,-1,-3,5.6,9.0]
neg=[]
pos=[]
flt=[]
for n in list_num:
if n<0:
neg.append(n)
if n>=0:
pos.append(n)
if str(n).isdigit()==False and n>0:
flt.append(n)
print neg
print pos
print flt

if-else code for total price won't compile

what is wrong with this im to make c code for total price with one of three ram options.et ramchoices=1or2or3 /this is where I know my problem lies but don't know how to fix it. the compiler needs a one to one relationship. how do I break this up and still show that ramchoice depends on what I pick and those choices affect price./



int main(void) {
/*declare variables*/
float baseprice;
float total;
float ramchoice;
baseprice=1029.48;

/*ramchoice can be 1 or 2 or 3*/

ramchoice=1||ramchoice=2||ramchoice=3;
total=baseprice+ramchoice;

/*initiate variable*/

scanf("%f",&ramchoice);
if("%f" (ramchoice==1))
{
total=baseprice+179.99;
}
else if("%f" ramchoice==2)
{
total=baseprice+94.99;
}
else if("%f" ramchoice==3)
{
total=baseprice+69.99;
}

printf("total is %f",total);

return 0;
}

For loop reverse order JAGS

I am trying to figure out how to avoid to enter this for loop without using an IF sentence (not present in JAGS).


In other words, I need this loop not to run in reverse order, i.e. when Je[i] - 1 is smaller than 2.



for (j in 2:(Je[i]-1)){
Z[i,j] ~ dnegbin(p[i,j],r[eta[i,j]])
logit(p[i,j]) <- B1[eta[i,j]] + B2*sum(Z[i,1:j-1])
}


When Je[i] - 1 == 1, the loop still runs but in reverse order, so j is first equal to 2 and in the second iteration j is equal to 1.


Does anyone know how to fix this?


JAVASCRIPT if statement won't work

I am making a game where you are supposed to be taken to the second level after you have 10 points on level 1. Here is my function to add points, it has an if statement to take you to the next level (game.html) when your score is 10.



<script>
function addScore(){

scoreDiv = document.getElementById("score");

scoreDiv.innerHTML ++;

if(scoreDiv == 10) {
window.open("Game.html");

}
else {
}
}
</script>


Why isn't it working?


IF statement with Graph API

I'm trying to show from data from Graph API, however I'm new with PHP and I'm struggling to get it to work. I've been working with the old API and have only just managed to convert some old code to new code, so it's a little messy. Can anyone see what's stopping this from functioning?



echo print_r( $graphObject, 1 );
echo "<br><h2><b><u>First Company</u></b></h2>";
echo 'Name: '.$graphObject->getProperty('name').;
echo 'Phone: '

if .$graphObject->getProperty['phone']. {
echo .$graphObject->getProperty('phone');
} else {
echo "No phone number available.";
}


I've managed to get the 'Name', but I'm trying to create an IF statement as the page doesn't have a phone number available.


Misfuctioning if-statement upon choosing numbers [duplicate]


This question already has an answer here:




A list called numbers, includes all prime integers from 1 to 1000. I want to check if a number includes "1" or "7", and if so, remove it from the list numbers



for number in numbers:
number = (list(str(number)))
if any(x in list(str(number)) for x in ("1" or "7")):
number = [int(i) for i in number]
number = (''.join(str(i) for i in number))
numbers.remove(int(number))
print(number)


The problem is, that it is semi-functional. Results are:



1 11 15 19 31 41 51 61 71 81 91 101 105 109 113 117 121 125 129 133 137 141 145 149 153 157 161 165 169 173 177 181 185 189 193 197 201 211 215 219 231 241 251 261 271 281 291 301 311 315 319 331 341 351 361 371 381 391 401 411 415 419 431 441 451 461 471 481 491 501 511 515 519 531 541 551 561 571 581 591 601 611 615 619 631 641 651 661 671 681 691 701 711 715 719 731 741 751 761 771 781 791 801 811 815 819 831 841 851 861 871 881 891 901 911 915 919 931 941 951 961 971 981 991


Expected result is all numbers which include "1" or "7" E.G 7, 17, 37, 107 and so on.


Why is this happening?


Detecting if music has ended in VB.NET

Title says it all - I'm in VB.NET and using Windows Media Player as a base for a music player I'm making. I've got the following code to detect if a currently playing .mp3 file has ended:



'Checks to see if the player is still playing music
While WMPLib.WMPPlayState.wmppsPlaying
If WMPLib.WMPPlayState.wmppsMediaEnded Then
MessageBox.Show("Playing next song")
End If
End While


The while check can successfully see that a music file is being played, however the IF statement doesn't detected when a music file has ended, it actually returns true whilst the media is currently playing. How can I get it to detect when a music file has finished playing?


Java - If statement if both and each

So I have two variables:



int x = 3;
int y = 7;


Then I have this code:



int key = 4; // Can be anything

if (key == x || key == y) {
if (key == x) {
// Do something with x
} else {
// Do something with y
}

// Do something with both x and y
}


I get really annoyed to have to write key == x 2 times, because in my original code that can be something really long like: key == StaticRandomVeryLongNamedClassName.getARandomNumber().


Is there any way to do this without having to write key == x two times?


Thanks.


Python if-else function: Why does the output ignore the else line [duplicate]


This question already has an answer here:




I'm just learning python and I don't understand why the else line doesn't work.


The output of the script always gives me the if line and not the else line no matter the size of "count" :



def donuts(count):
if count>=10: print 'Number of donuts: many'
else: print 'Number of donuts: ' + `count`
count = raw_input("Number of donuts: ")
donuts(count)
raw_input("press<enter>")

vendredi 30 janvier 2015

if in bootstrap table plugin

i used bootstrap table plugin ( http://ift.tt/1JMaSrl )


i have 'Status' field in database


i wand Status is '0' has info (color row is blue), '1' has success(color row is green), '-1' has error(color row is red)


code



<table id="bargain-tbl"></table>

<script>
$(function () {

$('#bargain-tbl').bootstrapTable({

url: "<?php echo $this->createUrl('admanage/JsonBargainDada',array('codeA'=>$_GET['codeA'],'codeB'=>$_GET['codeB'])) ?>",
cache: false,
striped: true,
pagination: true,
pageSize: 10,
pageList: [10, 25, 50, 100],
showToggle: true,
search: true,
showColumns: true,
showRefresh: true,
minimumCountColumns: 1,
clickToSelect: true,
selectItemName: 'barginSelect',
undefinedText:'تعیین نشده',
showPaginationSwitch:true,
toolbarAlign:'left',
checkbox:true,
columns: [ {
field: 'key_uuid',
title: 'انتخلب',
align: 'center',
checkbox: true,

},{
field: 'email',
title: 'ایمیل',
align: 'center',
valign: 'bottom',
sortable: true,

},{
field: 'tel',
title: 'شماهره همراه',
align: 'center',
valign: 'middle',
sortable: true,
}, {
field: 'price',
title: 'قیمت پیشنهادی',
align: 'center',
valign: 'top',
sortable: true,
}, {
field: 'created_datetime',
title: 'تاریخ در خواست',
align: 'center',
valign: 'middle',
clickToSelect: false,
}]
});
});

</script>

[Answered]Python2 string input if-statement script

Below is the script I'm trying to write. I've made other working scripts, including simple if-statement scripts, but I wanted to experiment a bit and try making a script that relies on string inputs instead of integers or floaters.


It goes without saying that I'm still learning and won't require this to do my job, but thanks for trying if you decide to take a crack at it. I spent about an hour with another novice coder trying out tiny adjustments. I'm almost certain it's futile to have the input equal a string to start with, creating my strife.



answer = raw_input("Do you enjoy your work?\n")

print str(answer)
if answer = str("yes") :
print "I'm happy to hear that, " + str(name)"
print "I wonder what being a " + str(title) + " actually means."
print "I don't have the term in my vocabulary. I'm a machine."
raw_input("My script is over soon. Goodbye.\n")
else :
print "I'm sorry to hear that, " + str(name)"
print "I guess being a " + str(title) + " must be difficult."
raw_input("My script is over soon. Goodbye.\n")

JOptionPane and If Statements

I am writing a program for my class and the program compiles and runs. There doesn't seem to be anything wrong with the logic in my "IF Statements" however, each time I get the same results no matter what values I enter for Growth Rate and Inflation. Does anyone see where I am going wrong.


Code:



import java.util.Scanner;
import javax.swing.JOptionPane;

public class Economy
{

public static void main(String[] args)
{
Scanner stdIn = new Scanner(System.in);
double GrowthRate=0; // Economic Growth Rate
double Inflation=0; // Inflation Rate


JOptionPane.showInputDialog ("Enter the Growth Rate % (as a whole number): ");

// System.out.print("Enter the Growth Rate % (as a whole number): ");
//GrowthRate = stdIn.nextDouble();

JOptionPane.showInputDialog ("Enter the Inflation Rate % (as a whole number): ");

//System.out.print("Enter the Inflation Rate % (as a whole number): ");
//Inflation = stdIn.nextDouble();
//System.out.print ("Based on the above information, you should: \n\n");

//First If
if (GrowthRate < 1 && Inflation < 3){
JOptionPane.showMessageDialog(null, "Increase welfare spending, reduce personal taxes, and decrease discount rate.");
}
else
{
JOptionPane.showMessageDialog(null, "Reduce business taxes.");
}
//Second If
if (GrowthRate > 4 && Inflation < 1){
JOptionPane.showMessageDialog(null, "Increase personal and business taxes, and decrease discount rate.");
}

//Third If
if (Inflation > 3 ){
JOptionPane.showMessageDialog(null, "Increase discount rate.");
}




}
} // end main

Why does my code in my if statement not execute?

I have some code that first in the IBAction:



- (IBAction)LGrabCont:(id)sender {
if ([self.LGrab isSelectedForSegment:1]) {
if (LGrabState == FALSE) {
LGrabState = TRUE;
[self.output setString:[self.output.string stringByAppendingString:@"The left grabber is now open\n"]];
[self.output scrollToEndOfDocument:self];
}
} else if ([self.LGrab isSelectedForSegment:0]) {
if (LGrabState == TRUE) {
if (itemXPos == RealLArmX && itemYPos == RealLArmY && itemZPos == RealLArmZ && pickedUp == FALSE) {
[self.output setString:[self.output.string stringByAppendingString:@"You picked up an item!"]];
pickedUp = TRUE;
}
[self.output setString:[self.output.string stringByAppendingString:@"The left grabber is now closed\n"]];
[self.output scrollToEndOfDocument:self];
LGrabState = FALSE;

}
}
}


The variables with the prefix 'Real' are just variables that hold co-ord positions. RArm = Right arm LArm = Left arm. The problem is that when my 'Real' variables are correct and the GrabStates are set to true, the code in the



if ([self.LGrab isSelectedForSegment:0]) {
if (LGrabState == TRUE) {
if (itemXPos == RealLArmX && itemYPos == RealLArmY && itemZPos == RealLArmZ && pickedUp == FALSE) {
[self.output setString:[self.output.string stringByAppendingString:@"You picked up an item!"]];
pickedUp = TRUE;
}


Doesn't execute. Am I doing something wrong with my segmented view IBActions?


CONVERTOR CM TO DM ETC

Hello, i have a problem with my php code, im student of the high school and we just started doing the php and i would like to do convertor something like cm to dm etc. I started doing some php and here is it, i want someone who has a time to help me do the whole convertor.. here is my code:



<form method="post">
<select name="z">
<option name="Vyber" value="">Vyber</option>
<option name="cm" value="cm">cm</option>
<option name="dm" value="dm">dm</option>
<option name="m" value="m">m</option>
</select>
<select name="do">
<option name="Vyber2" value="">Vyber</option>
<option name="cm2" value="cm">cm</option>
<option name="dm2" value="dm">dm</option>
<option name="m2" value="m">m</option>
</select>
<input type="submit" name="submit" value="GO!" />
</form>



<?php

if(isset($_POST['submit'])){
$selected1 = $_POST['z'];
$selected2 = $_POST['do'];
echo "Z " . $selected1 . ":" . "<form name='final' method='post'><input type='text' />" . "<br>";
echo "Do " . $selected2 . ":" . "<input type='text' />" . "<br>";
echo "<input type='submit' value='Vypocitat!' /></form>";
}

if (isset($_POST['cm'], $_POST['dm2'])){
echo $_POST['cm'] * 10;
}

?>

Excel IF arguemtn with 4+ conditions

I'm looking to create a formula with 3+ conditions. I've tried some of the suggestions on this forum but cannot seem to get my formula quite right -- I'm getting a "FALSE" argument usually, so the problem is in the way(s) I'm nesting the arguments, I believe. Here is the situation: There is a number in D13. If D13 is between 2 and 4, then "Text 1". If D13 is <2 and between 4 and 7, then "Text 2". If D13 is >7, then "Text 3". Thanks.


Conditional statement in R dataframe

I have dataframe df as below.



dput(df)
structure(list(X = c(1, 2, 5, 7, 8), Y = c(3, 5, 8, 7, 2), Z = c(2,
8, 7, 4, 3), R = c(6, 6, 6, 6, 66)), .Names = c("X", "Y", "Z",
"R"), row.names = c(NA, -5L), class = "data.frame")
df
class(df)


I have to modify df under two conditions. First: modify df so that it check minimum between X,Y,Z for each row and whichever is minimum get replaced with corresponding value of R. Second case: which is minimum between X,Y,Z,R in each row, it get replaced with maximum between X,Y,Z,and R and create a new df. How should i get that? I tried ifelse and if and else but could not get what i want.. Any help would be appreciated.


Cannot get bash to match whitespaces in a regular expression that is delimited by [[ ]] in an if satement

I am developing what should be a simple script to read a file line by line, assess the contents of each line, and process the line data depending on it line number. For some reason, I cannot get a regex that matches white spaces. [:space:], [[:space:]], [:blank:], \s, \ , , and " " have all failed.


My data is formatted as follows (fastq format):



@SRR573708.2 2 length=100
AAAACGTTAATATTTATTGAAATTGTT
+SRR573708.2 2 length=100
HHHHHHHHHHHHHHHHHHHHHHHHHHH


I would like to reformat it to:



@SRR573708.2/2
AAAACGTTAATATTTATTGAAATTGTT
+SRR573708.2/2
HHHHHHHHHHHHHHHHHHHHHHHHHHH


It is important, however, that I check each line to make sure it is formatted correctly before printing it to a new file. My last attempt at generating a reformatted file produced some really bizzare results at the end of the file. My code is:



i=1
while read LINE; do
if (( $i > 4 )); then break; fi
if (( $i % 4 == 1 )); then
if [[ $data =~ ^@SRR[0-9]{6}[[:blank:]] ]]; then
awk -v IFS=" " -v OFS="" -v ORS="" -v SUFFIX=$SUFFIX -v OUTPUT_FILE=$OUTPUT_FILE ' {print $1,SUFFIX,"\n" } ' <<< $data
i=$(( $i + 1 ))
else
echo -e "error at line ${i}"; echo "${data}"; exit 1; fi
elif (( $i % 4 == 2 )); then echo -e "$LINE"
i=$(( $i + 1 ))

elif (( $i % 4 == 3 )); then
echo $data
awk -v IFS=" " -v OFS="" -v ORS="" -v SUFFIX=$SUFFIX -v OUTPUT_FILE=$OUTPUT_FILE ' {print $1,SUFFIX,"\n" } ' <<< $data
i=$(( $i + 1 ))

elif (( $i % 4 == 0 )); then echo -e "$LINE"
i=$(( $i + 1 ))

else
echo -e "number of liness is not divisible by 4. Program Terminated.\nProblem encountered at line ${i}."
exit 1
fi

done < $INPUT_FILE


I get the error message:



error at line 1
@SRR573708.2 2 length=100


Any suggestions as to how to match a whitespace in a regex if-statement, preferable matching only space and tab characters and not newline characters.


Parse error: syntax error, unexpected 'if' (T_IF), expecting ')'

How can I add a condition inside a php array?


Here is the array



$content['custom_fields'] = array(
array( "key" => "_yoast_wpseo_focuskw", "value" => $_POST["title"] ),
array( "key" => "_yoast_wpseo_metadesc", "value" => $_POST["titleenfa"] ),
array( "key" => "_yoast_wpseo_metakeywords", "value" => $_POST["metakey"] ),
if($_POST["link128"]){
array( "key" => "_link128", "value" => "field_54b398292c295" ),
array( "key" => "link128", "value" => $_POST["link128"] ),
}
if($_POST["link256"]){
array( "key" => "_link256", "value" => "field_54b398092c294" ),
array( "key" => "link256", "value" => $_POST["link256"] ),
}
if($_POST["link320"]){
array( "key" => "_link320", "value" => "field_54b3965495d27" ),
array( "key" => "link320", "value" => $_POST["link320"] ),
}
array( "key" => "country", "value" => "USA" )
);


But I get the PHP Parse error, why I can add a condition inside the array, what's happen??:



Parse error: syntax error, unexpected 'if' (T_IF), expecting ')'



Excel IF blocks in combination with sheet referencing

Im trying to get an re ordered set of columns from a spreadsheet, to do this with out touching the original data ive been using =Sheet1!U71 in column A and then dragging it down to take in U72,U73,U74 etc


This is all fine, but when there are blanks its keeps throwing a 0 into the cell.


Ive been trying to use an if block as below =IF(ISBLANK(Sheet1!U71), ,=Sheet1!U71)


But cant seem to get it to work, is it possible to do this with an if block whilst referencing another sheet, or is it an issue with my IF syntax ?


I cant compare a data grid view cell to a textbox.text in visual basic


Dim string1 As String = EmployeeDataGridView.CurrentRow.Cells(7).Value.ToString()
Dim string2 As String = Password_TextBox.Text


If string2 = string1 Then
MessageBox.Show("hello")

Else
MessageBox.Show("string 1= " & string1 & "string 2= " & string2)

End If


I want the message box to display "hello" but only the other messagebox runs with the message "string 1= yes string 2= yes"


so the two strings both equal "yes" so why is the if statement not running the code?


Compare Elements via jQuery

I'm in a situation where I want to check if two elements (one is clicked and another one a reference) are the same, what I'm trying to do is:



$("#process li").click(function() {
currentElement = $(this);
referenceElement = $("#process li:first-child");
if (currentElement === referenceElement) {
$(".mark").removeClass("mark");
$(this).addClass("mark");
}
});


So what I want is to check if the clicked <li> is the first child of the ul#process and if so first remove a .mark class from another element and then add it to the clicked one. I don't get any working result - ideas anyone?


Arrays - Multiple Files Upload - Delete Parent Array Element Where Child Array ['error'] => 4

Here is my code:


HTML (Multiple Uploads):



<input type="file" name="attached_photo_1" id="attached_photo_1" />
<input type="file" name="attached_photo_2" id="attached_photo_2" />
<input type="file" name="attached_photo_3" id="attached_photo_3" />
<input type="file" name="attached_photo_4" id="attached_photo_4" />
<input type="file" name="attached_photo_5" id="attached_photo_5" />


PHP



$photo_array = array(
$_FILES['attached_photo_1'],
$_FILES['attached_photo_2'],
$_FILES['attached_photo_3'],
$_FILES['attached_photo_4'],
$_FILES['attached_photo_5']
);


Example


Now lets say someone only uploaded images for photo 1 and 2, leaving images 3, 4, and 5 with a $_FILES error code of 4 (meaning no file was uploaded).


Example Output (using <?php print_r($photo_array); ?>):



Array
(
[0] => Array
(
[name] => test.png
[type] => image/png
[tmp_name] => /Applications/XAMPP/xamppfiles/temp/php0JwXJc
[error] => 0
[size] => 3469655
)

[1] => Array
(
[name] => test-2.jpg
[type] => image/jpeg
[tmp_name] => /Applications/XAMPP/xamppfiles/temp/phpv7qFc6
[error] => 0
[size] => 1666451
)

[2] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)

[3] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)

[4] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)

)




MAIN QUESTION:

How Can I remove all of the parent array elements where the child array's [error] => 4? Thus in the example above elements [2], [3], and [4] would be deleted or unset from the array.


dictionary.ContainsKey(input ) ? int value = dictionary[input] : "Not Found" ;

Why this does not work?



dictionary.ContainsKey(input ) ? int value = dictionary[input] : "Not Found";


But it works this way:



if(dictionary.ContainsKey (input)){int values =dictionary[input];}

If statement does not work when condition is met

Here is my code:



var count = 2;
var decrementAmount = 1;

function reduceVariable() {
count -= decrementAmount;
}

$("#button").click(function() {
reduceVariable();
});

if (count == 0) {
$("#avrageReactionTime").html("Hello");
};


When i click my button twice the div that has the id avrageReactionTime does not change to have the text hello. Why do i have this problem...


Java - If statement without block execute action for true or false

How can i do that for example a if statement check if it is true or false and then execute action depends of the output?



if (check true or false) if false do action : if true do action


Something like that do it all in the same line without blocks, it that possible ?


Sorry for my bad English Thanks.


excel if-statement variables that appear under certain conditions

enter link description hereI ulpoaded a file. I am trying to sum all variables that are above "PICK" and it must be on the same line as "W" apears.Book2.xlsx I want to sum 2,25 1,62 but not 3,9 and so on. please help me. I did not try anything already. Book2.xlsx


Remove nodes from nodeset when nodeset length is more than 1

I have an xml like



<Books>
<Book Name="ABC">
<Line No="43"/>
</Book>
<Book Name="XYZ">
<Line No="44"/>
</Book>
</Books>


I have to remove where Name is "ABC" only when where Name is "XYZ" is also present (or where Name is "ABC" is not the only element in the nodeset)


The xslt i prepared is like :



<xsl:stylesheet xmlns:xsl="http://ift.tt/tCZ8VR" version="1.0">
<xsl:output method="xml" indent="yes" />
<xsl:if test="count(Books/Book) > '1'">
<xsl:strip-space elements="*" />
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="Book[@Name='ABC']" />
</xsl:if>
</xsl:stylesheet>


This does not seem to work. What is it that I am doing wrong here.


Passing down symbol from a for loop to an if statement

It seems that a symbol in a "for loop" is local to the loop itself. Is there any way to pass the information about what the symbol is currently representing down to, for example, an if statement?


For example, this generates an error:



int[] myAry = {1, 2, 3};
for (int i : myAry)
if (i == 2);
System.out.println(i);


While this doesn't:



int[] myAry = {1, 2, 3};
for (int i : myAry)
if (i == 2);
System.out.println("Match found!");

Strange php if behaviour with casted to boolean int

let's see if somebody can help me.


I have function called ret_error() which is called when there's an error accessing a table in a database, that means, "could not connect", "record not found" and this like that. This functions returns an array with two keys like this



array('error' => true, 'code' => Model::RECORD_NOT_FOUND);


If I call a function that returns an array built with ret_error() and I inspect the array it is like



$result = array('error' => 1, 'code' => Model::RECORD_NOT_FOUND);


But when I evaluate with an 'if'



if (!$result['error']) {
do something;
}
else {
do something else;
}


Always is evaluated as false even if I cast to a boolean.


This works correctly if evaluated as int such as



if ($result['error'] != 1) {


Is there something I'm missing?.


PHP if then else for all url starting with this domain else do smthn else

I have an easy php question , i want if all the domains starting with for e.g. www.blabla.com/.. do this else for all other domains of the web do smthng else,, my php code with the embeded html is like that,,, how can i avoid all the cases and have just one if and one else and not have elseif... i hope u understand my question ...



<?php if ($item->getPrimaryLink()) : ?></br>

<?php if ($item->getPrimaryLink()->getUrl() == "http://ift.tt/18C5AkT") : ?></br>

<a href="<?php echo $item->getPrimaryLink()->getUrl(); ?>" class="readon"><span><?php rc_e('READ_MORE'); ?></span></a>

<?php elseif ($item->getPrimaryLink()->getUrl() == "http://ift.tt/1yJhnCO") : ?></br>

<a href="<?php echo $item->getPrimaryLink()->getUrl(); ?>" class="readon"><span><?php rc_e('READ_MORE'); ?></span></a>

<?php elseif ($item->getPrimaryLink()->getUrl() == "http://ift.tt/18C5AkV") : ?></br>

<a href="<?php echo $item->getPrimaryLink()->getUrl(); ?>" class="readon"><span><?php rc_e('READ_MORE'); ?></span></a>

<?php elseif ($item->getPrimaryLink()->getUrl() == "http://ift.tt/1yJhkqL") : ?></br>

<a href="<?php echo $item->getPrimaryLink()->getUrl(); ?>" class="readon"><span><?php rc_e('READ_MORE'); ?></span></a>

<?php else : ?></br>

<a href="<?php echo $item->getPrimaryLink()->getUrl(); ?>" class="modal" rel="{size: {x: 1024, y: 550}, handler:'iframe'}"><span><?php rc_e('READ_MORE'); ?></span></a>

<?php endif; ?>


Thank you all and any ideas or suggestions would be really appreciated.. Thank you guys..


Possible Vectorization using If Statements in MATLAB

Suppose I have the following column vectors as



res = 0.81 res2 = -0.28
0.78 -0.41
0.85 -0.62
0.50 -0.56
0.63 -0.11


and I have two fixed constant D = 0.5. Now suppose an element of res1 is called X and an element of res2 is called Y. I have the following conditions



if (X > D && Y < -D)
output = 1
elseif (X < -D && Y > D)
output = -1
else
output = 0
end


My question is this:


Is it possible to "vectorize" these conditions to iterate over the entire vectors res1 and res2, such that my output vector would give (for example) :



output = -1
0
-1
0
1


?


I know I can do it via a loop, but I would prefer to avoid it since these vectors are actually quite large (>10000). I have attempted to use logical indexing, but to no avail (unless I'm implementing it wrong).


Any help would be appreciated!


replace onclick action to display inline output

i want to change the behavior of the button in this function



$STRING .= '<a href="'.$GLOBALS['CORE_THEME']['links']['author'].'/author/'.$author_info->user_login. '" class="btn btn-info btn-lg">'.$CORE->_e(array('auction','41')).'</a>';


to when clicked to display the output of this function



$data = get_user_meta( $authorID, 'cellno', true);
if(strlen($data) > 0){
echo "<span><i class='fa fa-phone'></i> <a href='phone:".$data."' rel='nofollow' target='_blank'</a> </span>";


so that when " class="btn btn-info btn-lg" is clicked it will display the phone number inside it, for now it shows contact author, and opens a new page to the author page.


thanks everybody


jeudi 29 janvier 2015

JavaScript condition always fails

In the below code, the if statement always fails. New to JavaScript, couldn't figure out.


I believe the code is self explanatory. What am I doing wrong?



if (localStorage.user_name === null || localStorage.user_name === 'undefined') {
registerUser(userName);
} else {
login(localStorage.user_name); // Gets executed always... Even if there is no user_name in localStorage.
}

How to choose page using if else in mysql_num_rows

===========



please help me I want my program to choose a site if it has not yet username then it will proceed it to ch_uname.php. Then if the login credentials have already username then it will be preceded to index_profile.php. Thank you in advance.




`if(mysql_num_rows($runcreds)> 0 ) //checking log in forms


{ if(mysql_num_rows($run_uname)>=1 ) //if username has already avalaible(proceed) { $_SESSION['Email_add']=$email; echo "<script>window.open('modules/index_profile.php','_self')</script>"; } if(mysql_num_rows($run_uname)<1)//choouse username if has not yet username { $_SESSION['Email_add']=$email; echo "<script>window.open('forms/ch_uname.php','_self')</script>"; //modules/index_profile.php } } else { echo "<script>alert('Admin details are incorrect!')</script>"; }


}


If ElseIf in Robot Framework

I want get value from Keyword By use else if.


example



String text = ""
If variable > 5
text = "one";
else if variable <5
text = "two";
else
text = "three";




In Robot Framework


I use code.



${txt} Set Variable
${txt}= Run Keyword If ${lenght} > 5 Some Keyword
\ ELSE IF ${lenght} < 5 Some Keyword
\ ELSE Some Keyword
Log ${txt}




EROR !!



In Keyword ELSE IF ; Keyword name cannot be empty

Perl hash data check in IF condition not working

I'm new to perl and I'm working on perl code which use hashes. I wonder why I can't use hash data in a IF condition. For example,


Value of $post_val{'module'} is extension.



print "Module value: $post_val{'module'}\n";

if (chomp($post_val{'module'}) eq "extension") {
print "correct...\n";
} else {
print "wrong...\n";
}


I get following output,



Module value: extension


wrong...



What is going wrong here?


Javascript Difference Between x=10; if(x) and if(x===10)

I understand that in terms of boolean


x = true; if(x) //This is the same as if(x === True) doSomething();


But if one were to set x to a number, then what does the if condition mean? Does the condition mean if(x === true)? If so, why is that?


R : adding the values in a [row,column] only if value is true in (same) row, (different) column

This is what I'm trying to code for in R...


Let's say I have 50 rows and 4 columns. If the value in (row 1, column 2) was greater than 5, then count the value in (row 1, column 4).


For an example: (row,column)


If (1,2) = (6) then count the value in (1,4)


If (2,2) = (8) then count the value in (2,4)


If (3,2) = (4) then DO NOT count the value in (3,4)


And so on....Then add the all the values from column 4.


How would I code this in R? I've tried creating a function, looping, if statements, etc.


Money accumulator buttons

I'm building a project for school and I want to make three money buttons (quarter, nickel and dime) that accumulates their value with every click of the button. When I'm done the text displayed will be grabbed and reParsed back to a double. I have that part done, I'm just drawing a blank on using a button accumulator.



double quarter = 0.0;

if (event.getSource() == quarterButton)
{
Possible loop???
quarter += .25;
}
String quarter2 = Double.toString(quarter);
amountDeposited.setText(quarter2);

Selection Condition Array In PHP

i have PHP code with loop:



$product = Array();
$idx = $idx2 = 0;
while ($data = oci_fetch_array($stmt, OCI_BOTH)) {
if($data['PARENT'] == 0) {
$idx++;
$product[$idx]['id'] = $data['ID'];
$product[$idx]['name'] = $data['NAME'];
}
else {
$product[$idx][0]['attributeName'] = 'DOWNLOAD';
$product[$idx][0]['attributeValue'] = $data['DOWNLOAD'];
$product[$idx][1]['attributeName'] = 'UPLOAD';
$product[$idx][1]['attributeValue'] = $data['UPLOAD'];
}
}
print_r ($test_array);


the array result is:


Array ( [1] => Array ( [id] => 1 [name] => INTERNET [0] => Array ( [attributeName] => DOWNLOAD [attributeValue] => 2048 )



[1] => Array
(
[attributeName] => UPLOAD
[attributeValue] => 512
)

)

[2] => Array
(
[id] => 2
[name] => VOICE
[0] => Array
(
[attributeName] => DOWNLOAD
[attributeValue] =>
)

[1] => Array
(
[attributeName] => UPLOAD
[attributeValue] =>
)
)
)


But i just want show the attributeName and attributeValue for internet only.. i tried to add if($data['NAME'][0]='INTERNET') below while, but it doesn't work, VOICE still has attributeName and attributeValue. Please Help. Thanks


C++ if statements not returning


int main()
{
char command = 'a';
Monster Goblin;Goblin.HP = 5;Goblin.name = "Goblin";
if(command == 'a'){
cout<<"At the main Menu, what to do now? Enter H for a list of commands!"<< endl;
cin>>command;
switch(command)
{
case 'a':
cout<<"Going to the main menu!"<<endl;
command = 'a';
break;
case 'b':
cout<<"Going to command line B"<<endl;
command = 'b';
break;
case 'c':
cout<<"going to command line C"<<endl;
command = 'c';
break;
}

}
if(command == 'b')
{
cout<<"You made it to command line B"<<endl;
cout<<"Now lets try to make it go back to the MM!"<<endl;
command = 'a';
}
if (command == 'c')
{
cout<<"You made it to command line C"<<endl;
}


}


im trying to get it to when I enter b, it will output going to command line B and the other two lines and then return to the main menu, which is 'a', why is it not returning to the main menu if the command char equals 'a'?


How to add "IF NOT EXISTS" to create trigger statement

I am new to sql server and procedures/triggers. I have the following code to create a trigger (it works):



CREATE TRIGGER [dbo].[Insert_WithdrawalCodes]
ON [dbo].[PupilWithdrawalReason]
AFTER INSERT
AS
BEGIN
SET NOCOUNT ON;
UPDATE [dbo].[PupilWithdrawalReason] SET DateCreated=dbo.SYSTEMTIME()
WHERE WithdrawalCodeID IN (SELECT WithdrawalCodeID FROM inserted)
END


How do I conditionally create only if the trigger does not yet exist? What am I doing wrong here? Stackoverflow has good examples of "if not exists", but I can't get this to work in conjunction with a CREATE. Here is one of my failed efforts:



IF NOT EXISTS (select * from sys.objects where type = 'TR' and name = 'Insert_WithdrawalCodes')
CREATE TRIGGER [dbo].[Insert_WithdrawalCodes]
ON [dbo].[PupilWithdrawalReason]
AFTER INSERT
AS
BEGIN
SET NOCOUNT ON;
UPDATE [dbo].[PupilWithdrawalReason] SET DateCreated=dbo.SYSTEMTIME()
WHERE WithdrawalCodeID IN (SELECT WithdrawalCodeID FROM inserted)
END
GO

Combine 2 similar Functions which use IF Java script

I have created two functions that run a similar set of IF statements, one shows the cost of a game, the other its name. I have used "onclick" to display both values in my form. It all works but suffers from bloat. Is there a way to combine both functions to shorten the script?



function GameTitle() {
var textboxValue = document.getElementById("game_id").value;
var message;
if (textboxValue == 1) {
message = "Fantasy World";
} else if (textboxValue == 2) {
message = "Sir Wags A Lot";
} else if (textboxValue == 3) {
message = "Take a Path";
} else if (textboxValue == 4) {
message = "River Clean Up";
} else if (textboxValue == 5) {
message = "PinBall";
} else if (textboxValue == 6) {
message = "Ghost girl";
} else if (textboxValue == 7) {
message = "Dress Up";
} else if (textboxValue == 8) {
message = "Where is my hat?";
} else {
message = "Invalid ID";
}
document.getElementById("game_title").value = message;
}

//Display price of Game
function Cost() {
var textboxValue = document.getElementById("game_id").value;
var cost;
if (textboxValue == 1) {
cost = "0.99";
} else if (textboxValue == 2) {
cost = "0.99";
} else if (textboxValue == 3) {
cost = "1.99";
} else if (textboxValue == 4) {
cost = "1.99";
} else if (textboxValue == 5) {
cost = "3.99";
} else if (textboxValue == 6) {
cost = "3.99";
} else if (textboxValue == 7) {
cost = "1.99";
} else if (textboxValue == 8) {
cost = "1.99";
} else {
cost = "Invalid ID";
}
document.getElementById("cost").value = cost;
}

QA program struggling with ever changing data references

For my project I am building a QA program in exce; to check the data of one sheet against the data of another sheet. The problem here is that one of the sheets is extracted from a database so the formatting and the location of everything is different then in the file I will be checking it against. Another caveat is that this program has to work across multiple workbooks.


My first attempt at this problem was to make sure data in both sheets was sorted similarly. This made it so that all of the data is alphabetically sorted on both sides by the lowest possible matching criteria. I then in turn created a new sheets with basic if statements to then check the data in the appropriate rows.


The problem herein lies with missing data. My current code when dragged down accurately identifies if the data in the corresponding table is correct but doesn't account for if an entire row is missing. It will return a fail for that row then every row below it which is unacceptable for the goal I am trying to accomplish. Also I feel as if the program is hardcoded excessively which leaves me open for problems down the road, if I send this program to lower level employees to run QA they won't know to change references in the program to get the correct answers.


So basically what I am asking is how would you code this so that if an error arose by a row missing it wouldn't destroy the rest of the QA and make it useless but instead recognize that that row is gone return a fail for that row and the corresponding data and move on.


Here is my code very macro recorded heavy, as I am a very new VBAer.



'''''''This section returns the heading of the row I am taking the data from''''
Sheets("Ratings QA").Select
ActiveCell.FormulaR1C1 = "=Sheet1!RC[8]"
''''''''This section returns title headings of each row to ensure they match with title headings from the master'''''''
Range("A2").Select
ActiveCell.FormulaR1C1 = _
"=IF('Detailed Ratings'!R[15]C[8]=Sheet1!RC[8],Sheet1!RC[8],""Fail"")"
Range("A2").Select
Selection.AutoFill Destination:=Range("A2:A400"), Type:=xlFillDefault
Range("B1").FormulaR1C1 = "=Sheet1!RC[8]"
Range("B1").Select
Selection.AutoFill Destination:=Range("B1:BI1"), Type:=xlFillDefault
Range("B2").Select
ActiveCell.FormulaR1C1 = _
"=IF('Detailed Ratings'!R[15]C[8]=Sheet1!RC[8],""Pass"",""Fail"")"
Range("B2").Select
Selection.AutoFill Destination:=Range("B2:B400"), Type:=xlFillDefault
Range("B2:B400").Select
Selection.AutoFill Destination:=Range("B2:BI400"), Type:=xlFillDefault
Range("B2:BI400").Select
Cells.Select
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""Pass"""
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Bold = True
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 5287936
End With
Selection.FormatConditions(1).StopIfTrue = False
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""Fail"""
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Bold = True
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 255
End With
Selection.FormatConditions(1).StopIfTrue = False
With ActiveWindow
.SplitColumn = 0
.SplitRow = 1
End With


One proposed solution that I thought might work but I am unsure how to code would be that if a fail was returned in the first row where title heading should be, would be to include a placeholder row. So instead of just putting fail it would fill that row with fail then skip that range of cells then the following row would continue down the range as if nothing had happened. It would return error and not destroy the QA any ideas as how I can add this as a condition of the if statement.


Thank you,


How to Select * Using Unbound Combobox Lists

Background


I have created an app that brings back records from an SQL database. The query on the database uses two variables in its where clause. These two variables are taken from two unbound combo-boxes which have been populated using two data from the database.


Question


How do I allow the user to select all? I've added "All" to the tops of the unbound lists that the combo-boxes use and then used an if statement to select what SQL statement to use. But this doesn't seem to work.


How to select all records without inputting all list entries into the query?


Example


User selects "All" and "All" in both combo boxes.


App


enter image description here


Code



private void button2_Click(object sender, EventArgs e)
{

String ConnStr = "Data Source=server1; Initial Catalog=db1; User ID=mobile; Password=Password";

SQLSelection();
SqlConnection con = new SqlConnection(ConnStr);
SqlCommand command = new SqlCommand(SQL, con);
con.Open();

command.Parameters.Add("@username", SqlDbType.VarChar).Value = comboBox1.Text;
command.Parameters.Add("@status", SqlDbType.VarChar).Value = comboBox2.Text;

SqlDataAdapter adb = new SqlDataAdapter(command);

using (DataTable dt = new DataTable())
{
adb.Fill(dt);
dataGridView1.DataSource = dt;
con.Close();
}

SQLSelection();
}

private void SQLSelection()
{
if (comboBox1.Text == "All" & comboBox2.Text == "All")
{
String SQL = "SELECT stationID, LocationName, plandate, username, status FROM dbo.joblist WHERE status in ('New','Hold')";
}
else if (comboBox1.Text == "All" & comboBox2.Text == "@status")
{
String SQL = "SELECT stationID, LocationName, plandate, username, status FROM dbo.joblist WHERE status = @status";
}
else if (comboBox1.Text == "@username" & comboBox2.Text == "All")
{
String SQL = "SELECT stationID, LocationName, plandate, username, status FROM dbo.joblist WHERE status = @username";
}
else
{
String SQL = "SELECT stationID, LocationName, plandate, username, status FROM dbo.joblist WHERE username = @username and status = @status";
}

}

MS SQL IF statement on query results

I have the results of the query below emailed everyday 90% of the time empty. I would like to add an if statement to only send the email If (resulting row count>0)



Select Orders.TransactionNumber, Orders.RepNumber, Orders.CustomerID,
Orders.ShipToId, orders.ItemCode, Orders.Quantity, Orders.ReceivedDate,
Orders.TransmitStatus from (select TransactionNumber from Orders
group by TransactionNumber
having COUNT (TransactionNumber)=1) as transa

Inner join Orders on Orders.TransactionNumber=transa.TransactionNumber

where ItemCode=9987 and ReceivedDate > DateADD (day, -4, GetDate() )
Order by ReceivedDate


Add here> If (counted rows>0 send the email else end)


Minimizing multiple if else conditions in cakephp

I have this method in cakephp controller. Here I try to save the user subscription data to the subscription table based on whether the user is already registered to the site or not. I have two form fields named Name and Email. So if a user is logged in and clicks on the subscribe button, the form pop-up comes up with his name and e-mail already filled in the boxes and if he submits it, he will be subscribed. When a user who is not registered and not logged in, but just want to subscribe, he will have an empty subscription form to fill.


Later I added some modifications that if any user, registered or not registered, wants to subscribe with the same e-mail, a pop-up will show saying: "you are already registered". So far I have done this. It works okay but with a lot of if and else conditions. Any idea about how to minimize this will be helpful. I am new to cakephp and all these things. My controller method code is below:



function subscription_add() {
if(!empty($this->data)){
if($this->Session->check('User')){
$is_subscribed = $this->Subscription->find('count', array('conditions'=>array('Subscription.email' => $this->data['Subscription']['email'])));
if($is_subscribed > 0){
$this->Session->setFlash('You are already Subscribed !','default',array(),'E');
$this->redirect(array('action' => 'index'));
}
else{
$this->data['Subscription']['user_type'] = 1;
$this->data['Subscription']['user_id'] = $this->Session->read('User.id');
$this->Subscription->create();
if ($this->Subscription->save($this->data)) {
$this->Session->setFlash('Congrats ! You are Subscribed ', 'default', array(), 'S');
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash('You are not subscribed. Please, try again.', 'default',array(),'E');
}
}
}
else{
$subscribed = $this->Subscription->find('count', array('conditions'=>array('Subscription.email' => $this->data['Subscription']['email'])));
if($subscribed > 0){
$this->Session->setFlash('You are already Subscribed !','default',array(),'E');
$this->redirect(array('action' => 'index'));
}else{
$this->Subscription->create();
if ($this->Subscription->save($this->data)) {
$this->Session->setFlash('Congrats ! You are Subscribed ', 'default', array(), 'S');
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash('You are not subscribed.. Please, try again.', 'default',array(),'E');
}
}
}


}
}

Break If Statement in While loop without breaking the while loop PHP

Ok, So Im creating a while loop for multiple accordions in php. I marked up some php code that ALMOST works. The problem I am having is that I had to nest five different IF statements in a while loop for the five different accordions. The If statements contain the content to be in the accordion. The content is a list of songs in a particular album. What I need to happen is for the If statement containing the content for one accordion to break, but still continue with the original while statement and do this for each accordion. Here is my PHP Code.



if ($result)
{
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC))
{
echo '<div class="col-small-6 col-med-6 col-lg-4 albumContainer">';
echo '<img src=' . $row['Album_Art'] . 'alt="">';
echo '<div class="panel-group" id="accordion">';
echo '<div class="panel panel-default">';
echo '<div class="panel-heading">';
echo '<h2 class="panel-title"><a data-toggle="collapse" data-parent="#accordion" href=' . $row['direction'] . '>' . $row['Title'] . '</a></h2></div><div id=' . $row['destination'] . ' class="panel-collapse collapse"><div class="panel-body"> <ol>';
if($result1)
{
while ($row1 = mysqli_fetch_array($result1, MYSQLI_ASSOC))
{
echo '<li>' . $row1['Name'] . '</li>';
};
};
if($result2)
{
while($row2 = mysqli_fetch_array($result2, MYSQLI_ASSOC))
{
echo '<li>' . $row2['Name'] . '</li>';
}
};
if($result3)
{
while($row3 = mysqli_fetch_array($result3, MYSQLI_ASSOC))
{
echo '<li>' . $row3['Name'] . '</li>';
}
};
if($result4)
{
while($row4 = mysqli_fetch_array($result4, MYSQLI_ASSOC))
{
echo '<li>' . $row4['Name'] . '</li>';
}
};
if($result5)
{
while($row5 = mysqli_fetch_array($result5, MYSQLI_ASSOC))
{
echo '<li>' . $row5['Name'] . '</li>';
}
};
if($result6)
{
while($row6 = mysqli_fetch_array($result6, MYSQLI_ASSOC))
{
echo '<li>' . $row6['Name'] . '</li>';
}
};
echo '</ol>';
echo '<h3>available at:</h3><a href=' . $row['Location'] . '>iTunes</a>
<a href=' . $row['Location2'] . '>Amazon</a>
<a href=' . $row['Location3'] . '>United Interests</a></div>';
echo '</div></div></div></div>';
}
mysqli_free_result ($result);
}
else
{
echo '<p class="error">The current users could not be retrieved. We apologize for any inconvenience.</p>';
echo '<p>' . mysqli_error($dbcon) . '<br><br />Query: ' . $q . '</p>';
}
mysqli_close($dbcon);
?>


Any insights on how to make this work for me would be greatly appreciated. I cant use Jquery for the accordion because of how the code was previously structured.


Can anyone show me why does it give me variable not initialized?

Every time I try to compile this it shows me d1 variable may not be initialized. I think problem may in the else if. Tell me how to run 2 statements in else if.



import java.util.Scanner;
class IDC {

public static void main(String[] args) {

Scanner scan = new Scanner(System.in);

System.out.println(" ");
System.out.println("Input ID card no...");

String x = scan.next();


x = x.substring(0, x.length() - 1); //removing the last char of the string

String CardNo = x;

String y = x = x.substring(0, x.length() - 7); //birthday

y = "19" + y; //birth year = y




String CardNO1 = CardNo.substring(0, CardNo.length() - 4);

//System.out.println(CardNO1);

CardNO1 = CardNO1.substring(2);

//System.out.println(CardNO1);

//gender

int g = Integer.parseInt(CardNO1); //converting string to int
String G;
if (g < 500) {
G = "Male";
} else {
G = "female";
}
//System.out.println(G);
double C = Integer.parseInt(CardNO1);
if (C > 500) {
C = C - 500;
} else {
C = C;
}
//calculating month and the day of birth

double d1;
int Month;
//

if (C < 31) {
Month = 1;
d1 = C;
} else if (C <= 60) {
Month = 2;
d1 = C - 31;
} else if (C <= 91) {
Month = 3;
d1 = C - 60;
} else if (C <= 121) {
Month = 4;
d1 = C - 91;
} else if (C <= 152) {
Month = 5;
d1 = C - 121;
} else if (C <= 182) {
Month = 6;
d1 = C - 152;
} else if (C <= 213) {
Month = 7;
d1 = C - 182;
} else if (C <= 244) {
Month = 8;
d1 = C - 213;
} else if (C <= 274) {
Month = 9;
d1 = C - 244;
} else if (C <= 305) {
Month = 10;
d1 = C - 274;
} else if (C <= 335) {
Month = 11;
d1 = C - 305;
} else if (C <= 366) {
Month = 12;
d1 = C - 335;
} else {
Month = 00;
}
//double d1;

System.out.println(" ");

System.out.println("Your Birthday... ");
System.out.println("Date.." + d1);
System.out.print("Month.. " + Month);
System.out.println(" Year.. " + y);

System.out.println(" ");

System.out.println("Your Gender...");
System.out.println(G);

}

}

AS3 How to make an If Else Statement using Tweenlite?

In this example I have 3 panels.


Goal: Have the color of these mcs: "panel1.tab1.Bgr" "panel2.tab2.Bgr" and "panel3.tab13.Bgr" tween to #2ea0dd on mouseOver and then on mouseOut tween back to their original color (tintAmount:0). I can't figure out how to accomplish this :-(


I have this function:



function onMouseOver(e:MouseEvent):void {
var mousedOver:MovieClip = MovieClip(e.target);

for(var i:int=0; i<numChildren; i++) {
var mc:MovieClip = MovieClip(getChildAt(i));

if(mc.props.ind <= mousedOver.props.ind)


//if it is, animate to the top TweenLite.to(mc, .5, {y:mc.props.ty});


//if not animate to the bottom



else
TweenLite.to(mc, .5, {y:mc.props.by});
TweenMax.to(panel1.tab1.tab1Bgr, 1, {colorTransform:{tint:0x2ea0dd, tintAmount:1}});
}}


Any help much appreciated. THANK YOU!


JavaScript var getElementById if statement not working

I can't figure out how to code this in JavaScript/html: I basically need an option so the customer can pick the language he wants and based in the he can see what promotion is available in that language and choose the one he wants.



<script>
Function PromoLanguage(){
Var language = document.getElementById('languages');
Var a = language.selectedIndex;
If (a == 1){
Document.getElementById('French').style.display = display;
}
Else if (a == 2){
Document.getElementById('English').style.display = display;
}
Else if (a == 3){
Document.getElementById('German').style.display = display;
}
Else () {}
}
</script>
<body>
<select onchange="PromoLanguage()" id='languages'>
<option>French</option>
<option>English</option>
<option>German</option>
</select>

<select id='English' style='display: none'>
<option>ENGLISHPROMO1</option>
<option>ENGLISHPROMO2</option>
<option>...</option>

<select id='French' style='display: none'>
<option>FRENCHPROMO1</option>
<option>FRENCHPROMO2</option>
<option>...</option>

<select id='German' style='display: none'>
<option>GERMANPROMO1</option>
<option>GERMANPROMO2</option>
<option>...</option>

How do I check to see if a word contains a letter or group of letters?

I am working on a program for my CompSci I class and I'm entirely stuck. The assignment is to use if statements to check whether a particular string contains a letter or group of letters. I have a class created for this and I've laid out everything, but I just don't know how to begin searching for the characters. I'm really new to Strings and Return methods. I looked for similar questions already, but none really helped with what I was looking for. I would appreciate some help.


My code so far: Main:



import static java.lang.System.*;

public class Lab04e
{
public static void main(String[] args)
{

}
}


StringChecker:



import static java.lang.System.*;
public class StringChecker {

private String check;

public void StringChecker()
{
check = "";
}

public void StringChecker(String s) //constructor
{
check = s;
}

public void setString(String s) //set string
{
check = s;
}

public boolean letterExists(char a)
{
return false;
}

public boolean findSubString(String s)
{
return false;
}

public String toString()
{
return check +"\n\n";
}
}

Python Programming: Multiline Comments before an Else statement

I was working with simple if-else statements in Python when a syntax error came up with the following code.



"""
A multi-line comment in Python
"""
if a==b:
print "Hello World!"

"""
Another multi-line comment in Python
"""
else:
print "Good Morning!"


This code gives a syntax error at the "else" keyword.


The following code however does not:



"""
A multi-line comment in Python
"""
if a==b:
print "Hello World!"

#One single line comment
#Another single line comment
else:
print "Good Morning!"


Could anyone tell me why this happens? Why does the Python interpreter not allow multi-line comments between if-else statements?


Program Not Calculating Properly Given All Variables

[Still Learning...] While trying to create a program to calculate the advantage/disadvantage of a blackjack table given all rule variations, this calculator only displays the initial input from the user for the number of decks. All of the other rules from the user seem to be completely ignored when it is run. For example, with 6-decks, the result is always -0.54% regardless of whatever you enter for the rest of the rules. It only takes into account the number of decks. How do I resolve this issue? The code is here:



{ public static void main(String[] args){ double edge = 0;

Scanner sc = new Scanner(System.in);
System.out.println("How many decks (1, 2, 4, 6, 8)");
int decks = sc.nextInt();
System.out.println("Dealer hits Soft 17 (Y or N)");
String soft17 = sc.next();
System.out.println("Double after splits (Y or N)");
String doubleAfterSplit = sc.next();
System.out.println("Double 10/11 only (Y or N)");
String double1011 = sc.next();
System.out.println("Double 9/10/11 only (Y or N)");
String double91011 = sc.next();
System.out.println("Resplit Aces (Y or N)");
String rSA = sc.next();
System.out.println("Late Surrender (Y or N)");
String lateSurrender = sc.next();
System.out.println("Early Surrender (Y or N)");
String earlySurrender = sc.next();
System.out.println("Lose all doubles/splits vs. Natural (Y or N)");
String loseAllDS = sc.next();
sc.close();

//Number of Decks Option
if (decks == 1) {
edge += 0.01;
} else if (decks == 2) {
edge -= 0.32;
} else if (decks == 4) {
edge -= 0.49;
} else if (decks == 6) {
edge -= 0.54;
} else if (decks == 8) {
edge -= 0.57;
} else {
System.out.println("You made a mistake. Start over.");
}

//Soft 17 Options
if (soft17 == "Y") {
edge -= 0.20;
} else {
edge += 0;
}

//Double After Splits Option
if (doubleAfterSplit == "Y") {
edge += 0.14;
} else {
edge += 0;
}

//Double 10 and 11 Only Option
if (double1011 == "Y") {
edge -= 0.17;
} else {
edge += 0;
}

//Double 9, 10, and 11 Only Option
if (double91011 == "Y") {
edge -= 0.08;
} else {
edge += 0;
}

//Resplit Aces Option
if (rSA == "Y") {
edge += 0.08;
} else {
edge += 0;
}

//Late Surrender Option
if (lateSurrender == "Y") {
edge += 0.08;
} else {
edge += 0;
}

//Early Surrender Option
if (earlySurrender =="Y") {
edge += 0.65;
} else {
edge += 0;
}

//Lose on All Doubles and Splits vs Natural Option
if (loseAllDS == "Y") {
edge -= 0.11;
} else {
edge += 0;
}

if (edge >= 0) {
System.out.println("Your advantage is: " + edge + "%");
} else {
System.out.println("Your disadgantage is: " + edge + "%");
}


}

Format multiple if-else statements into methods

I have a program that checks for user date input and displays the output of the next date. However, I am using multiple if-else statements for the program.


I would like to alter it so that it will use methods to do the calculation instead of the repeated codes.


Below is an example of my code, take March and April for an example, one with 30 days, one with 31 days:



public class calDate{

public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
boolean dateValid = false;
int day = 0;
int month = 0;
int year = 0;
int nextDay = 0
int nextYear = 0;
String nextMonth = "";

System.out.print("Day: ");
day = scan.nextInt();

System.out.print("Month: ");
month = scan.nextInt();

System.out.print("Year: ");
year = scan.nextInt();

while (month < 1 && month > 12) //check if month is within 1 to 12
{
dateValid = false;
}

if ((month == 3) && (day >= 1 && day <= 31))
{
dateValid = true;
nextDay = day + 1;
nextMonth = " March ";
nextYear = year;

if (day == 31) {
nextDay = 1;
nextMonth = " April ";
nextYear = year;
}
}

else if ((month == 4) && (day >= 1 && day <= 30))
{
dateValid = true;
nextDay = day + 1;
nextMonth = " April ";
nextYear = year;

if (day == 30)
{
nextDay = 1;
nextMonth = " May ";
nextYear = year;
}
}
if (dateValid)
{
System.out.println("Tomorrow's date is: " + nextDay + nextMonth + nextYear);
}

else
{
System.out.println("Invalid input");
}
}


There are many repeated values, such as dateValid, nextDay, nextMonth, nextYear. How may I format my code so that I can put the statements into separate methods? Thank you.


Javascript Variables in if statement. Numeric versus String

I have a HTML select tag. Depending on the selected item in the listbox I want to write this value in a ordering sheet. The ordering sheet is made of several td: Prod1, Prod2, Prod3 ... It must be simple but I can't see it. How come this code:



var compteur = 0;
function Add_Product() {
var e = document.getElementById("SelectionProduct");
var strProduct = e.options[e.selectedIndex].text;
if (compteur = 0) {
document.getElementById('Prod1').innerHTML = strProduct;
compteur++;
}
}


doesn't execute the line:



document.getElementById('Prod1').innerHTML = strProduct;


But this one, which is of no use for my purpose, does:



var compteur = "0";
function Add_Product() {
var e = document.getElementById("SelectionProduct");
var strProduct = e.options[e.selectedIndex].text;
if (compteur = "0") {
document.getElementById('Prod1').innerHTML = strProduct;

}
}


Thanks.


Why is this bash IF statement not working?


if [[ $DATA == *?xml* ]]
then
if [[ $DATA == *misuse* ]]
then echo "Misuse" >> $OUTPUTPAST2
else echo "All Good" >> $OUTPUTPAST2
fi
else echo "Not xml" >> $OUTPUTPAST2
fi


Where $DATA does not contain the string ?xmlI am expecting an output of Not xml, but I am getting output of All Good.


What am I doing wrong?


Javascript - check if there are any elements in an array

Trying to write an if statement to check if there are any elements in an array. If there is nothing inside it, then don't executing a function:


Blocks[{a},{b} etc ]


if (there is nothing inside the blocks array), don't execute checkBlocks().


Thank you all.


mercredi 28 janvier 2015

How to use the 'if' statement in matlab?

I have a cell array of size 5x5 as below



B= 00 10 11 10 11
01 01 01 01 11
10 00 01 00 01
10 10 01 01 11
10 10 10 00 10


And two column vectors



S1= 21
23
28
25
43

S2= 96
85
78
65
76


I want to create a new cell array of the same size as B say 5x5 such that it satisfies the following condition



Final={S1 if B{i}=11
S1 if B{i}=10
S2 if B{i}=01
S2 if B{i}=00


So the resulting output would be something like this



Z = s2 s1 s1 s1 s1
s2 s2 s2 s2 s1
s1 s2 s2 s2 s2
s1 s1 s2 s2 s1
s1 s1 s1 s2 s1
ie Z= 96 21 21 21 21
85 85 85 85 23
28 78 78 78 78
25 25 65 65 25
43 43 43 76 43


I tried using the if condition but i get error saying 'Error: The expression to the left of the equals sign is not a valid target for an assignment.'



for i=1:1:128
for j=1:1:16
if fs{i,j}=00
Z{i,j}=S1{i,j}
elseif fs{i,j}= 01
Z{i,j}=S2{i,j}
elseif fs{i,j}= 10
Z{i,j}=S1{i,j}
elseif fs{i,j}= 11
Z{i,j}=S2{i,j}
end
end


I think I'm making a mistake in the if statement as well as the expressions I'm using. Where am i going wrong? Please help thanks in advance.


python 3 using multiple or and’s in an if statement

The code that follows always returns 'orange' I've found other ways to do what I want but I do not understand why this does not work.



color1 = input('select first color')
color2 = input('select second color')
if 'color1' == 'red' or 'yellow' and 'color2' == 'red' or 'yellow':
print('orange')
else:
print('something else')

issue with variable types

I am supposed to make a shipping program that asks the user some basic questions. Here are the instructions: An online shopper searches web to find an item and purchase is from the state with the lowest tax rate. Write a simple C++ program to do the following: Ask the user for the unit price of the item, the number of items the shopper wants to purchase, the name of the first state, the tax rate in the first state, the name of the second state and the tax rate in the second state. Then, calculate the total cost for each state and decide from which state the shopper should buy the item. Display the following to shopper: The unit item cost, the number of items purchased, the name and tax rate of the first state, the name and tax rate of the second state, and your recommendation on from which state the shopper should make the purchase.


List ALL literals and variables in your program.


Here is my code so far:



#include <iostream>
#include <cmath>
#include <cstring>

using namespace std;

int main()
{
double itemPrice, numberItem, taxRate, totalCost;
double stateTax1, stateTax2;
int stateName1, stateName2;

// ask the item's price
cout << "What is the price of the item?\n";
cin >> itemPrice;

// ask the # items
cout << "How many items are you going to purchase?\n";
cin >> numberItem;

// ask the name of the first state
cout << "What state are you having it shipped to?\n";
cin >> stateName1;

// ask the tax rate of the first state
cout << "What is the tax rate in " << stateName1 << "?\n";
cin >> stateTax1;

// ask the name of the second state
cout << "What state are you having shipped from?\n";
cin >> stateName2;

// ask the tax rate of the second state
cout << "What is the tax rate in " << stateName2 << "?\n";
cin >> stateTax2;

// first if the first state has a lower tax rate
// else if second state has lower tax rate
if (stateTax1 < stateTax2)
{
totalCost = itemPrice * numberItem * stateTax1;

cout << "The item cost is " << itemPrice << ".\n";
cout << "The number of items is " << numberItem << ".\n";
cout << "The name of the first state is " << stateName1 << ".\n";
cout << "The tax rate of the first state is " << stateTax1 << ".\n";
cout << "The name of the second state is " << stateName2 << ".\n";
cout << "The tax rate of the second state is " << stateTax2 << ".\n";
cout << "You should consider purchasing the item from " << stateName1 << ".\n";
}
else
{
totalCost = itemPrice * numberItem * stateTax2;

cout << "The item cost is " << itemPrice << ".\n";
cout << "The number of items is " << numberItem << ".\n";
cout << "The name of the first state is " << stateName1 << ".\n";
cout << "The tax rate of the first state is " << stateTax1 << ".\n";
cout << "The name of the second state is " << stateName2 << ".\n";
cout << "The tax rate of the second state is " << stateTax2 << ".\n";
cout << "You should consider purchasing the item from " << stateName2 << ".\n";
}
return 0;
}


My question is how do I get the stateName variables to work properly. I am sure this is some basic string thing I should know but I do not. other than that I believe the rest of my code works properly. though any and all tips would be greatly appreciated.


Cobol: Data Validation

I'm trying to code a program to determine if different kinds of errors appear in a given file. I'm going to post my entire code, because I honestly have no idea where I'm going wrong here. It's just abending on me. The data validation is 2100-error-checking.



ENVIRONMENT DIVISION.
* defines the external files - an input file and output file
INPUT-OUTPUT SECTION.
FILE-CONTROL.


SELECT DATVAL02 ASSIGN TO DATAIN
FILE STATUS IS EF-STATUS.

SELECT REPORT-FILE ASSIGN TO DATAOUT
FILE STATUS IS PF-STATUS.

DATA DIVISION.

FILE SECTION.
FD DATVAL02.
01 SALES-RECORD.
05 RECORD-CODE PIC XX.
05 FILLER PIC X.
05 VEND-NUM PIC X(8).
05 YEAR-DUE PIC 99.
05 MONTH-DUE PIC 99.
05 DAY-DUE PIC 99.
05 VEND-NAME PIC X(20).
05 FILLER PIC XXX.
05 AMT-DUE PIC S9(6)V99.

FD REPORT-FILE.
01 REPORT-RECORD PIC X(80).

WORKING-STORAGE SECTION.

01 FLAGS-AND-ACCUMLATORS.
05 VALID-RECORDS PIC S99.
05 INVALID-RECORDS PIC S99.
05 EF-STATUS PIC 99 VALUE 0.
05 PF-STATUS PIC 99 VALUE 0.
05 A-ERROR PIC X VALUE SPACE.
05 C-ERROR PIC X VALUE SPACE.
05 E-ERROR PIC X VALUE SPACE.
05 F-ERROR PIC X VALUE SPACE.
05 B-ERROR PIC X VALUE SPACE.
05 D-ERROR PIC X VALUE SPACE.
05 G-ERROR PIC X VALUE SPACE.
05 H-ERROR PIC X VALUE SPACE.
05 I-ERROR PIC X VALUE SPACE.
05 A-AST PIC XX VALUE SPACES.
05 BC-AST PIC X(8) VALUE SPACES.
05 D-AST PIC XX VALUE SPACES.
05 E-AST PIC XX VALUE SPACES.
05 F-AST PIC XX VALUE SPACES.
05 G-AST PIC X(15) VALUE SPACES.
05 I-AST PIC X(8) VALUE SPACES.
05 END-OF-FILE PIC XXX VALUE "NO".
05 ERROR-FLAG PIC XXX VALUE SPACES.
05 ERROR-FLAG2 PIC XXX VALUE SPACES.
05 VC PIC XX VALUE "VC".
05 NOO PIC XX VALUE "NO".
05 D-CHECK PIC S9999999V99.


01 HEADING-LINE-1.
05 PIC X(15) VALUE SPACES.
05 PIC X(24) VALUE
"VENDOR RECORD VALIDATION".
05 PIC X(24) VALUE SPACES.
05 PIC X(6) VALUE
"PAGE 1".

01 HEADING-LINE-2.
05 PIC XX VALUE
"RC".
05 PIC X VALUE SPACE.
05 PIC X(8) VALUE
"VENDOR #".
05 PIC XX VALUE SPACES.
05 PIC X(8) VALUE
"DATE DUE".
05 PIC XX VALUE SPACES.
05 PIC X(11) VALUE
"VENDOR NAME".
05 PIC X(6) VALUE SPACES.
05 PIC X(10) VALUE
"AMOUNT DUE".
05 PIC XXX VALUE SPACES.
05 PIC X(16) VALUE
"-- ERROR CODES--".

01 DETAIL-LINE.
05 RECORD-CODE-OUT PIC XX.
05 PIC X VALUE SPACE.
05 VEND-NUM-OUT PIC 9(8).
05 PIC XX VALUE SPACES.
05 YEAR-DUE-OUT PIC XX.
05 MONTH-DUE-OUT PIC XX.
05 DAY-DUE-OUT PIC XX.
05 PIC XX VALUE SPACES.
05 VEND-NAME-OUT PIC X(20).
05 PIC XX VALUE SPACES.
05 AMT-DUE-OUT PIC 999,999V99.
05 PIC XX VALUE SPACES.
05 A-ERROR-OUT PIC X.
05 PIC XX VALUE SPACES.
05 B-ERROR-OUT PIC X.
05 PIC XX VALUE SPACES.
05 C-ERROR-OUT PIC X.
05 PIC XX VALUE SPACES.
05 D-ERROR-OUT PIC X.
05 PIC XX VALUE SPACES.
05 E-ERROR-OUT PIC X.
05 PIC XX VALUE SPACES.
05 F-ERROR-OUT PIC X.
05 PIC XX VALUE SPACES.
05 G-ERROR-OUT PIC X.
05 PIC XX VALUE SPACES.
05 H-ERROR-OUT PIC X.
05 PIC XX VALUE SPACES.
05 I-ERROR-OUT PIC X.

01 ASTERISK-LINE.
05 A-AST-OUT PIC XX.
05 PIC X VALUE SPACE.
05 BC-AST-OUT PIC X(8).
05 PIC XX VALUE SPACES.
05 D-AST-OUT PIC XX.
05 PIC X VALUE SPACE.
05 E-AST-OUT PIC XX.
05 PIC X VALUE SPACE.
05 F-AST-OUT PIC XX.
05 PIC XX VALUE SPACES.
05 G-AST-OUT PIC X(15).
05 PIC XX VALUE SPACES.
05 I-AST-OUT PIC X(8).
05 PIC XX VALUE SPACES.
05 H-AST-OUT PIC X(8).

01 RECORD-TOTALS.
05 PIC X(16) VALUE
"VALID RECORDS: ".
05 VALID-RECORDS-OUT PIC 99.
05 PIC XX VALUE SPACES.
05 PIC X(17) VALUE
"INVALID RECORDS: ".
05 INVALID-RECORDS-OUT PIC 99.

PROCEDURE DIVISION.

1000-MAIN-CONTROL.
PERFORM 2000-INITIALIZE.
PERFORM UNTIL END-OF-FILE = "YES"
READ DATVAL02
AT END
MOVE "YES" TO END-OF-FILE
NOT AT END
PERFORM 2100-ERROR-ROUTINE
IF ERROR-FLAG = "YES"
PERFORM 2500-PROCESS
PERFORM 3000-PROCESS
END-IF
IF ERROR-FLAG = "NO"
PERFORM 2500-PROCESS
END-IF
END-PERFORM.
PERFORM 4000-PROCESS.
PERFORM 4500-TERMINATE.
STOP RUN.

2000-INITIALIZE.
OPEN INPUT DATVAL02.
OPEN OUTPUT REPORT-FILE.

WRITE REPORT-RECORD FROM HEADING-LINE-1.
WRITE REPORT-RECORD FROM HEADING-LINE-2.

2100-ERROR-ROUTINE.
MOVE "NO" TO ERROR-FLAG.
MOVE "NO" TO ERROR-FLAG2.

IF VEND-NUM = SPACES
MOVE "YES" TO ERROR-FLAG
MOVE "********" TO BC-AST-OUT
MOVE "B" TO B-ERROR-OUT
END-IF.


IF ERROR-FLAG = "YES"
ADD 1 TO INVALID-RECORDS
END-IF.

IF ERROR-FLAG = "NO"
ADD 1 TO VALID-RECORDS
END-IF.



2500-PROCESS.
MOVE RECORD-CODE TO RECORD-CODE-OUT.
MOVE VEND-NUM TO VEND-NUM-OUT.
MOVE YEAR-DUE TO YEAR-DUE-OUT.
MOVE MONTH-DUE TO MONTH-DUE-OUT.
MOVE DAY-DUE TO DAY-DUE-OUT.
MOVE VEND-NAME TO VEND-NAME-OUT.
MOVE AMT-DUE TO AMT-DUE-OUT.

WRITE REPORT-RECORD FROM DETAIL-LINE.

3000-PROCESS.
WRITE REPORT-RECORD FROM ASTERISK-LINE.

4000-PROCESS.
MOVE VALID-RECORDS TO VALID-RECORDS-OUT.
MOVE INVALID-RECORDS TO INVALID-RECORDS-OUT.
WRITE REPORT-RECORD FROM RECORD-TOTALS.

4500-TERMINATE.
CLOSE DATVAL02, REPORT-FILE.


Data in looks as such...



VC 10045380051005ABC ELECTRONICS 00001298
VT 000000 00020000


Looking to achieve this



XX 9AAA9999 99/99/99 SHIFTED 12A 4GL 78 A C E F H I
** ******** ** ** *************** *** *** **


where * are under error's in the data. And letters show what error's are found. Thanks for your time.