jCombobox giving incremental value error on jTable - loops

I am having problems with my code below, the code below shows a jComboBox being populated, when i select an item from this list it is added to the jTable below it.
There is alos code to check for duplicate entries ont he table. If a duplicate entry is found it should increase the qty column by one and not create a seperate entry.
This is where the problem comes in, when I press the back button on this screen and go to a different screen and then come back via same route as the first time, I get an incrementally different qty added to the table row/cell.
I have also included the code that populates the Round Details depending on Round Drop selected from table, for reference, but Im fairly certain the problem lies in the below code. The navigation is as follows...
To get to the below screen... Round Drop panel table of round drops) >> click on table row and taken to associated round details panel >> pressing the Till button takes user to screen with code below...
Test results:
First pass through below code using navigation above gives results as expected
Second pass gives an initial value of 2 (instead of one), and duplicate row increases qty by 2 instead of one
Third pass gives an initial value of 3 (instead of one), and duplicate row increases qty by 3 instead of one
Fourth pass gives an initial value of 4 (instead of one), and duplicate row increases qty by 4 instead of one
...and so on.
Any help, guidance on solution or a better design would be hugely appreciated.
Thanks
/*************Code sample ********************************/
public void tillOperations(String sourceCall) {
final DefaultTableModel model = (DefaultTableModel)main.tillPanel.tblTillSale.getModel();
if (main.tillPanel.cmbTillProdSelect.getItemCount() < 1) {
for (int d = 0; d < roundStockObj.length ; d++) {
main.tillPanel.cmbTillProdSelect.addItem(roundStockObj[d].getDescription());
}}
main.tillPanel.tblTillSale.removeRowSelectionInterval(0, model.getRowCount() - 1);
main.tillPanel.cmbTillProdSelect.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent f)
{
int qty = 1;
for (int index = 0; index < 4; index++) {
addSelectedItem[index] = "";
}
int row;
selectedItem = null;
main.tillPanel.tblTillSale.removeRowSelectionInterval(0, model.getRowCount() - 1);
selectedItem = main.tillPanel.cmbTillProdSelect.getSelectedItem();
for (int d = 0; d < roundStockObj.length; d++) {
if (selectedItem.equals(roundStockObj[d].getDescription())) {
addSelectedItem[0] = roundStockObj[d].getDescription();
addSelectedItem[1] = Integer.toString(qty);
addSelectedItem[2] = Double.toString(roundStockObj[d].getPrice()).trim();
addSelectedItem[3] = Double.toString(roundStockObj[d].getPrice()).trim();
//break;
}
}
if(model.getRowCount() == 0) { //check if model is empty
model.addRow(new String[]{addSelectedItem[0], addSelectedItem[1], addSelectedItem[2], addSelectedItem[3]});
}
else { //check if there is a duplicate row
int duplicateRow = -1;
for (row = 0 ; row < model.getRowCount(); row++) {
if(addSelectedItem[0].equals(main.tillPanel.tblTillSale.getModel().getValueAt(row,0))) {
duplicateRow = row;
break;
}
}
if(duplicateRow == -1) { //if there is no duplicate row, append
model.addRow(new String[]{addSelectedItem[0], addSelectedItem[1], addSelectedItem[2], addSelectedItem[3]});
}
else { //if there is a duplicate row, update
main.tillPanel.jLabel1.setText(addSelectedItem[1]);
DecimalFormat fmtObj = new DecimalFormat("####0.00");
int currentValue = Integer.parseInt(main.tillPanel.tblTillSale.getValueAt(row, 1).toString().trim());
int newValue = currentValue + 1;
Integer newValueInt = new Integer(newValue);
model.setValueAt(newValueInt, row, 1);
double unitPrice = Double.parseDouble(main.tillPanel.tblTillSale.getValueAt(row, 2).toString().trim());
double newPrice = newValue * unitPrice;
Double newPriceDbl = new Double(newPrice);
main.tillPanel.tblTillSale.setValueAt(fmtObj.format(newPriceDbl), row, 3);
}
}
main.tillPanel.tblTillSale.removeRowSelectionInterval(0, model.getRowCount() - 1);
for (int index = 0; index < 4; index++) {
addSelectedItem[index] = "";
}
}
});
//This code loads the specific Round Details, based on the selection form the round drops table
public void displayRoundDropDetails() {
DefaultTableModel model = (DefaultTableModel)main.selectRoundDropPanel.tblSelectRoundDrop.getModel();
if (!loaded) {
for (int d = 0; d < roundDropsData.length; d++) {
if (roundDropsData[d][0].equals(defaultRoundID)) {
model.addRow(new Object[]{roundDropsData[d][3], roundDropsData[d][2],
roundDropsData[d][4], roundDropsData[d][5]});
}
}
loaded = true;
}
main.selectRoundDropPanel.tblSelectRoundDrop.addMouseListener(new MouseAdapter()
{
public void mouseClicked(MouseEvent evt)
{
int row = 0;
row = main.selectRoundDropPanel.tblSelectRoundDrop.getSelectedRow();
for (int index = 0; index < roundDropsData.length; index++) {
if (roundDropsData[index][3].equals(
main.selectRoundDropPanel.tblSelectRoundDrop.getModel().getValueAt(row, 0))) {
main.roundDetailsPanel.txtRoundDetailsAddress.setText(roundDropsData[index][6] + "\n"
+ roundDropsData[index][7] + ", " + roundDropsData[index][8] + "\n" +
roundDropsData[index][9]);
main.roundDetailsPanel.lblRoundDetailsName.setText(roundDropsData[index][2]);
main.roundDetailsPanel.txtRoundDetailsInstuct.setText(roundDropsData[index][10]);
main.roundDetailsPanel.txtDropDetailsIn.setText(roundDropsData[index][4]);
main.roundDetailsPanel.txtDropDetailsOut.setText(roundDropsData[index][5]);
main.roundDetailsPanel.txtRoundDetailsInstruct.setText(roundDropsData[index][12]);
break;
}
}
Globals.CURRENT_COMPONENT = "selectRoundDropPanel";
showRoundDetailsPanel();
}
});
}

Try changing the listener for JComboBox. try using stateChangeListener.

Related

Java - Search only working for array [0], remaining array items returning "not found"

In the following method, searching for an item name that is included in the array should return "(item name) was found and its product id is (item array ID)".
This works for item [0], but if any other item name is entered, they return "That product was not found".
private int findProduct() {
System.out.println("Enter the item to search for:");
while (true) {
for (int i = 0; i < products.length; i++) {
String itemToFind = getNextStringLineFromUser();
String searchText = products[i];
if (searchText.equals(itemToFind)) {
System.out.println(itemToFind + " was found and its product id is " + i);
return i;
}
System.out.println("That product was not found");
return -1;
}
}
}
If anyone has an idea of why this issue is happening, I would be very grateful for some advice on how to resolve the problems.
Thank you in advance for any help.
I got you.
The reason why your method is only right when the target is at index 0, is that your method returns -1 when first time not matched, without examining the other array element. (When a method returned, it terminated.)
Modify and check your code, you will see.
private int findProduct() {
System.out.println("Enter the item to search for:");
while (true) {
for (int i = 0; i < products.length; i++) {
String itemToFind = getNextStringLineFromUser();
String searchText = products[i];
if (searchText.equals(itemToFind)) {
System.out.println(itemToFind + " was found and its product id is " + i);
return i;
}
System.out.println("That product was not found"); // line 1
return -1; // line 2
}
}
}
The line 1 and 2 I commented, should be placed out of the for-loop. If you put them at where they are now, they will be run after the above if-statement run.
So if the first element of array matches with itemToFind, it works normal. When the first element does not match with itemToFind, the below line 2 will be run, your method terminates right away at a wrong timing.
The right code should be:
private int findProduct() {
System.out.println("Enter the item to search for:");
String itemToFind = scanner.nextLine(); // receive the entered string
for (int i = 0; i < products.length; i++) {
String searchText = products[i];
if (searchText.equals(itemToFind)) { // check if matched
System.out.println(itemToFind + " was found and its product id is " + i);
return i; // exit the method
}
}
System.out.println("That product was not found");
return -1;
}

how to find near value?

Iam trying to see if there is a shorter method in being able to find the nearest value in a linear search algorithm if the value you are searching for doesnt exist,without using any searching / sorting built in methods. Thank you.
Here is my current method below,although my attempt seems inefficent.
(iam assuming the array is already sorted)
public void LinearSearchNearest(int[] data, int target, string dataname)
{
Console.WriteLine(dataname + ": ");
int StepsNearest = 0;
int n = data.Length;
StepsNearest++;
// Check for corner cases (check the value is actually within range of the array)
if (target < data[0])
{
Console.WriteLine($"Closest value : {data[0]}, Position : {1} (value outside of array bounds) ");
Console.WriteLine($"Num of Steps is : {StepsNearest}");
return;
}
if (target > data[n - 1])
{
Console.WriteLine($"Closest value : {data[n - 1]}, Position : {n} (value outside of array bounds) ");
Console.WriteLine($"Num of Steps is : {StepsNearest}");
return;
}
int closestVal = 0;
int position = 0;
int found = 0;
int targetCount = 0;
Console.Write("Value is at positions : ");
for (int i = 0; i < data.Length; i++)
{
StepsNearest++;
if (data[i] == target)
{
targetCount++;
found++;
Console.Write($"{i + 1}, ");
}
else
{
StepsNearest++;
// Compare closest value currently to new value to see which one is closer to target
long along = data[i];
long blong = closestVal;
long clong = target;
var distanceA = Math.Abs(clong - along);
var distanceB = Math.Abs(clong - blong);
if (distanceA < distanceB)
{
closestVal = data[i];
position = i + 1;
}
}
}
// Check if target value was found or not in the array given
string result = (found == 0) ? $"Closest value : {closestVal}, Position : {position} " +
$"\nNum of Steps is : {StepsNearest}" : $"\nNum of Steps is : {StepsNearest}";
Console.WriteLine(result);
}
UPDATE CODE
public void LinearSearchNearest(int[] data, int target, string dataname)
{
Console.WriteLine(dataname + ": ");
StepsNearest = 0;
int closestVal = 0;
int position = 0;
int found = 0;
int minDistance = int.MaxValue;
Console.Write("Value is at positions : ");
for (int i = 0; i < data.Length; i++)
{
StepsNearest++;
if (data[i] == target)
{
found = 1;
Console.Write($"{i + 1}, ");
}
else
{
StepsNearest++;
// Compare closest value currently to new value to see which one is closer to target
int distance = System.Math.Abs(data[i] - target);
if (distance < minDistance)
{
minDistance = distance;
closestVal = data[i];
position = i + 1;
}
}
}
// Check if target value was found or not in the array given
string result = (found == 0) ? $"Closest value : {closestVal}, Position : {position} " +
$"\nNum of Steps is : {StepsNearest}" : $"\nNum of Steps is : {StepsNearest}";
Console.WriteLine(result);
}
If the array is assumed to be sorted as you said in the comments, then you could just walk through the array until you find a value that's equal to or larger than the target. If the value is equal, then of course we'd return that index.
If the value is larger, then we compare the difference of this value and the target with the difference of the previous value and the target, and return the index of the value with the smallest difference.
If we never find an equal or larger value, then we return the last index:
public int GetIndexOfNearest(int[] data, int target)
{
if (data == null) throw new ArgumentNullException(nameof(data));
if (target <= data[0]) return 0;
if (target >= data[data.Length - 1]) return data.Length - 1;
for (int i = 0; i < data.Length; i++)
{
// If we find a match, return that index
if (data[i] == target) return i;
// If this value is greater than the target then we either
// return this index or the previous index, depending
// on which one has the smallest diff with the target
if (data[i] > target)
{
var thisDiff = Math.Abs(data[i] - target);
var prevDiff = Math.Abs(data[i - 1] - target);
if (thisDiff < prevDiff) return i;
else return i - 1;
}
}
// We should never get here, since this is the case where all the items are smaller
// than the target, which we checked in the third line, but the compiler requires it
return data.Length - 1;
}
You can do all in one iteration. This will either find the first exact match or the nearest element to the search value in an UNORDERED array. If there are multiple elements with the same distance to the search value, it will find the first one.
let values = [...]; //your value list
let search = ...; //your value to search
let index = 0; //index where element is found
for (let i = 0; i < values.length; i++) {
// if the current element is an exact match, set the index to i
// and break the loop
if (values[i] == search) {
index = i;
break;
}
// else if current element is "nearer" to the searchvalue than
// the previously remembered, remember the current index
else if (abs(values[i] - search) < abs(values[index] - search)) {
index = i;
}
}
If you assume, that your array is already sorted you could do it as follows
let values = [...]; //your value list
let search = ...; //your value to search
let index = 0; //index where element is found
for (let i = 0; i < values.length; i++) {
// if the current element is an exact match, set the index to i
// and break the loop
if (values[i] == search) {
index = i;
break;
}
// while the current value is less then the search value,
// just remember the index
else if (values[i] < search) {
index = i;
}
// if the current value is greater then the search value
// check whether the previous or the current element is nearer to the search value
else if (values[i] > search) {
index = abs(search - values[i]) < abs(search - values[index])
? i
: index;
break;
}
}
Shorter? Maybe. What I have to offer is (hopefully) faster.
Let's summarize what you are looking for:
IN: Array of int, sorted (ascending order)
IN: target int value.
OUT: Array of all indices with values with minimal distance to target.
Given, that the data contains sorted data allows us to pick an algorithm, which performs more quickly than linear search. Linear search (O(N)) would be our only choice were the data in the array not sorted.
But as data is sorted, we can do binary search, which has O(log n) runtime.
With the help of binary search, we can find 1 or 2 candidates, which have the minimal distance to target.
Then, it is just a matter of looping towards the left and towards the right as long as there are values with that same minimal distance as our minimal candidate had.
A wall of code says more than 1000 words, right? Here we go:
using System;
using System.Linq;
using System.Collections.Generic;
namespace nearest
{
class Program
{
static int BinarySearchClosest( int[] data, int target, int left, int right)
{
if (right < left)
throw new ArgumentException(nameof(right));
if ((right - left) < 2)
return left;
var mid = left + (right - left) / 2;
if ( target > data[mid])
return BinarySearchClosest(data,target, mid, right);
else
return BinarySearchClosest(data,target, left, mid);
}
static int IndexOfClosestExistingValue( int[] data, int target) {
if (null == data) throw new ArgumentNullException(nameof(data));
if (0 == data.Length)
return -1;
// 1.Do a binary search to get within the same zip code of what
// we are looking for.
var ballpark = BinarySearchClosest(data, target, 0, data.Length);
// 2. we are close. The real minimum distance is either
// Math.Abs(data[ballpark]-target) or
// (Math.Abs(data[ballpark+1]-target) IFF (ballpark+1) < data.Length).
var minDist = Math.Abs(data[ballpark]-target);
var imin = ballpark;
if (((imin+1) < data.Length) && (Math.Abs(data[imin+1]-target) < minDist)) {
minDist = Math.Abs(data[imin+1]-target);
imin = imin + 1;
}
return imin;
}
static int[] IndicesOfClosestExistingValues( int[] data, int target)
{
List<int> result = new List<int>();
var imin = IndexOfClosestExistingValue(data, target);
if (imin >= 0) {
var minDist = Math.Abs(data[imin]-target);
result.Add(imin);
// Add equally good matches to the left of imin to the result.
for (var i = imin - 1;
i >= 0 && Math.Abs(data[i]-target) == minDist; i--) {
result.Add(i);
}
// Add equally good matches to the right of imin to the result.
for (var i = imin +1;
i < data.Length && Math.Abs(data[i]-target) == minDist; i++) {
result.Add(i);
}
}
return result.ToArray();
}
internal struct TestCase {
internal int[] data;
internal int target;
internal int[] expected;
}
static string TestCaseToString( TestCase tc) {
var sb = new System.Text.StringBuilder();
sb.AppendFormat(
"TestCase{{ data = {{{0}}}, target = {1}, expected = {{{2}}}}}",
string.Join(", ", tc.data),
tc.target,
string.Join(", ", tc.expected));
return sb.ToString();
}
static void Main(string[] args)
{
TestCase[] testCases =
{ new TestCase{
data = new int[]{},
target = 42,
expected = new int[]{} }, // data.Length == 0
new TestCase{
data = new int[]{1},
target = 42,
expected = new int[]{0} }, // data.Length == 1
new TestCase{
data = new int[]{1, 41, 45, 99},
target = 42,
expected = new int[]{1} }, // somewhere in the middle
new TestCase{
data = new int[]{100,101,102},
target = 42,
expected = new int[]{0} }, // far left
new TestCase{
data = new int[]{1,2,3},
target = 42,
expected = new int[]{2} }, // far right
new TestCase{
data = new int[]{1,1,1,1},
target = 42,
expected = new int[]{3,2,1,0} }, // multiple matches left
new TestCase{
data = new int[]{100,100,100,100},
target = 42,
expected = new int[]{0,1,2,3} }, // multiple matches right
new TestCase{
data = new int[]{41,41,41,41,43,43,43,43},
target = 42,
expected = new int[]{3,2,1,0,4,5,6,7} }, // multiple matches both sides
new TestCase{
data = new int[]{4,6},
target = 5,
expected = new int[]{0,1} } // multiple disjoint matches
};
int failCounter = 0;
int testCaseIndex = 0;
foreach ( var tc in testCases ) {
try {
int[] actual =
IndicesOfClosestExistingValues(tc.data, tc.target);
bool verdict = Enumerable.SequenceEqual(actual, tc.expected);
if (false == verdict)
failCounter++;
Console.WriteLine(
"{1}: {0}, actual = {{{2}}}",
TestCaseToString(tc),
verdict == true ? "OK" : "FAILED",
string.Join(", ", actual));
}
catch (FormatException) {
Console.WriteLine("{0}: FAULTED", testCaseIndex);
}
catch (ArgumentNullException) {
Console.WriteLine("{0}: FAULTED (argument null)", testCaseIndex);
}
finally {
testCaseIndex++;
}
}
Console.WriteLine("Done. ({0} tests failed.)", failCounter);
}
}
}
I did not use C# in many years and if you want to explore algorithms without a lot of lines of code and typing, I strongly recommend to use a more terse language (unless you really want to learn C#). F# is an attractive alternative as it uses the same run time, has the same default libraries and is much more easy on your fingers.

Ignore blank values in WPF chart control

I am working on WPF application which includes WPF chart. I am facing a situation.
I want to draw the chart only for values by ignoring blank values.
In application the data is contained by a datagrid and same data will be reflected in the graph, but datagrid having blank values(DBNull.Value).
So, I want to generate graph with only values by ignoring the blank values.
Here is my code for generating graph.
for (int col = 1; col < dtGeneric.Columns.Count; col++)
{
valueList = new List<KeyValuePair<string, double>>();
gLineSeries= new System.Windows.Controls.DataVisualization.Charting.LineSeries();
for (int row = 0; row < dtGeneric.Rows.Count - 1; row++)
{
if (string.IsNullOrEmpty(XaxisValue))
{
XaxisValue = "0";
}
YAxisValue = dtGeneric.Rows[row][col].ToString();
if (string.IsNullOrEmpty(YAxisValue))
{
YAxisValue = "0";
}
valueList.Add(new KeyValuePair<string, double>(XaxisValue, Convert.ToDouble(YAxisValue)));
}
gLineSeries.DependentValuePath = "Value";
gLineSeries.Style = gLineSeries.PolylineStyle;
gLineSeries.IndependentValuePath = "Key";
gLineSeries.ItemsSource = valueList;
gLineSeries.Title = dtGeneric.Columns[col].Caption.Replace('_', '.').ToString();
gLineSeries.AnimationSequence = AnimationSequence.FirstToLast;
chartControl.Series.Add(gLineSeries);
}
}
As you can see in the code, I have used keyvaluepair to draw the graph. So I am unable to add null value in the Value of keyvaluepair. I have tried with double.NaN but that is not working.
I have iterated all the columns because all the column will have its separate graph.
I have tried one logic to create the graph which is:
for (int col = 1; col < dtGeneric.Columns.Count; col++)
{
valueList = new List<KeyValuePair<string, double>>();
gPositionLineSeries = new System.Windows.Controls.DataVisualization.Charting.LineSeries();
for (int row = 0; row < dtGeneric.Rows.Count - 1; row++)
{
if (!string.IsNullOrEmpty(dtGeneric.Rows[row][0].ToString()) && !string.IsNullOrEmpty(dtGeneric.Rows[row][col].ToString())) //Null values will be ignored for graph generation...
{
XaxisValue = dtGeneric.Rows[row][0].ToString();
YAxisValue = dtGeneric.Rows[row][col].ToString();
valueList.Add(new KeyValuePair<string, double>(XaxisValue, Convert.ToDouble(YAxisValue)));
}
else
{
continue;
}
}
}
Above code is working fine but the X-axis values in the graph is not in order.
Please tell me some solution.
use below code in if block
string.IsNullOrEmpty(row.Cells[clm.Index].Value.ToString())

How to create a macro on a condition inside a if statement

I need to iterate a for loop nested inside of a while loop for several different conditions.
The only change in the code for each statement is the comparison condition to apply.
Turns out I am copy-pasting all of the code multiple times and changing the direction of the greater-less than symbol.
for example:
if (direction.horizontal == UIScrollDirectionLeft) {
int column = startColumn+1;
while (column < maxAllowed) {
for (int row = minRow; row < maxRow; row++) {
repeated code
}
column++;
} else {
int column = minColumn -1;
while (column >= 0) {
for (int row = minRow; row < maxRow; row++) {
repeated code
}
column--;
}
}
Is it possible to do a macro for the condition operator in order to facilitate code reuse?
I would really like something which could look like this:
int startColumn = (direction.horizontal == UIScrollDirectionLeft) ? (startColumn+1) : minColumn -1;
SignOfOperator theSignInTheWhile = (direction.horizontal == UIScrollDirectionLeft) ? "<" : ">=";
int conditionToTestInWhile = (direction.horizontal == UIScrollDirectionLeft) ? maxAllowed : 0;
while(startColumn,theSignInTheWhile,conditionToTestInWhile) {
// repeated code
}
I have another 4 cases like the one above...
You only need the loop code once. Just change the step value and terminating value. For example:
int start_column, end_column, column_step;
:
switch (direction.horizontal) {
case UIScrollDirectionLeft:
column = start_column + 1;
column_step = 1;
end_column = max_allowed;
break;
case UIScrollDirectionRight:
column = min_column - 1;
column_step = -1;
end_column = -1;
break;
:
}
while (column != end_column) {
for (int row = minRow; row < maxRow; row++) {
repeated_code();
}
column += column_step;
}

The array of index value is not starting from 0

I have 2 buttons to load the different texture images and when i press the 1st it loads the 4 images in textures and when i press the 2nd button it loads the 3 images in textures. But the problem is when i press the 1st button it loads the 4 images and when i press the 2nd it loads the images but it starting from 5th place. I can't reset the value to 0 when i press the second button.
private int clonevalue = 0;
public int i = 0;
string response = www.text;
IDictionary search = (IDictionary) Json.Deserialize(response);
IList linksObject = (IList) search["Products"]; //Here searching only products array
foreach (IDictionary modellinksArray in linksObject) {
string cat_id=string.Format("{0} ", modellinksArray["category_id"]); //From products array getting the category_id
//int catd_id_int = int.Parse(cat_id); //Converting the string value to integer
if(cat_id == myId){//Now, i have used static code value of 4 and if the value match and we can gets only matching category model. Here you can pass the id value of category list selected.
int clonevalue = 0;
int i = 0;
// i = 0;
cloneGO = Instantiate(myScrollTexture)as GameObject;
cloneGO.transform.parent = parentObject.transform;
cloneGO.transform.localPosition =new Vector3(127,30,0);
cloneGO.transform.localScale =Vector3.one;
cloneGO.name = "cloneScrollTexture"+i;
string myTexture = string.Format("{0} ", modellinksArray["imageurl"]);
string modelUrl = string.Format("{0} ", modellinksArray["modelurl"]);
i++;
//StartCoroutine(Load3D(modal3d,modal3d));
cloneGO.GetComponent<dynamicmodelload>().modelURL = modelUrl;
//Destroy(cloneGO);
WWW www1 = new WWW(myTexture);
Debug.Log("text"+myTexture);
yield return www1;
//if(!www1.isDone){
//yield return null;
//}
//if(www1.isDone){
Debug.Log (clonevalue);
//clonevalue = 0;
//DebugConsole.Log (clonevalue);
myTextureObject = GameObject.Find ("cloneScrollTexture" + clonevalue);
//Debug.Log (myTextureObject);
clonevalue++;
Debug.Log (myTexture);
myTextureObject.GetComponent<UITexture>().mainTexture = www1.texture;
Debug.Log ("myTextureObject"+myTexture);
//DebugConsole.Log ("myTextureObject"+myTexture);
if (myTextureObject.name == "cloneScrollTexture"+evenValues) {
myTextureObject.transform.localPosition =new Vector3(-81,30,0);
evenValues +=2;
Debug.Log (evenValues);
//DebugConsole.Log (evenValues);
}
if(myTextureObject.name == "cloneScrollTexture"+yevenValue){
yValue += 210;
Debug.Log("yevenValue"+yevenValue);
//DebugConsole.Log("yevenValue"+yevenValue);
yevenValue +=2;
}
//for(int i=0; i< 2; i++){
Debug.Log ("yValue"+yValue);
//DebugConsole.Log ("yValue"+yValue);
myTextureObject.transform.localPosition -=new Vector3(0,yValue,0);
Debug.Log ("myTextureObject"+myTextureObject.transform.localPosition);
//evenValues +=2;
// test = 5;
}
when i press the 1st button and the clone value passing to 0. So, the texture image properly loading in the 0th position but when i press the second button the clonevalue passing to number 5. so, the texture image displaying in the 5th place. So, how can i reset the clonevalue 0 when i press the 2nd button. So, that i can easily pass to 0.

Resources