w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Perl get value of variable from while(1) loop when sub() change it
According to this As just mentioned, all variables are, by default, thread local. To use shared variables, you need to also load threads::shared: thread local means you won't see changes outside your thread, so after you create your thread, each thread (logically) has it's own copy of all the variables.

Categories : Perl

Change index variable within ruby loop
actually the for semantic is the following: for(executed_once_before_all; test; execute_every_loop) { /* code */ } and so, in ruby: executed_once_before_all while test do execute_every_loop # code end so your exemple is like this: k = 0 while k < 10 do k += 1 k = 8 if (k == 5) end

Categories : Ruby

How to change variable name inside loop dynamically in C#?
You might have the wrong approach. What you need to do with your state object is add it to a collection, and work it from there. It's much easier to track this way. Example with a local list for use after the loop, in the function: public void MyFunction() { List<State> states = new List<State>(); foreach (var item in listViewStates.Items) { State s = new State { //Set state properties }; states.Add(s); } //Use your states here, address with brackets //states[0].ID ... } Example with a class-level list for later use outside the function: List<State> _states; public void MyFunction() { _states = new List<State>(); foreach (var item in listViewStates.Items) { State s = new S

Categories : C#

Change name or variable of TextView everytime it goes through a loop - Android
Basically, commentView is of type TextView and it is not of type Array and you have to initialize the TextView as below: TextView commentView = new TextView(this); and in onPostExecute() assign a random value as below: protected void onPostExecute(JSONObject json2){ for(int i=0; i<5; i++) { commentView.setText(json2.getArray(i)); } } or if you want the random JSON text to multiple textViews do it as below: TextView[] commentView = new TextView[TextViewCount]; @Override protected void onPreExecute() { super.onPreExecute(); for(int i = 0; i < textViewCount; i++) { commentView[i] = new TextView(this); } } @Override protected void onPostExecute(JSONObject json2) { for(int i = 0; i < 5; i++) { commentView[i

Categories : Android

Create data frame and change variable each iteration in for loop or apply
Create objects df.x as empty lists: df.a <- list() df.b <- list() df.c <- list() Then access (and write to) individual dataframes using double square backets: for (i in 1:10) { df.a[[i]] <- data.frame(...) df.b[[i]] <- data.frame(...) df.c[[i]] <- data.frame(new.col.A=df.a[[i]]$column1, new.col.B=df.b[[i]]$column2) }

Categories : R

Unable to use $.parseJSON on string variable constructed with array variable
There are quotes Inside your html strings: "html":"<fieldset id="formelement_1" class="radio"> This is totally broken (the string values ends at id="). You need to escape quotes with ". EDIT: of course this is the answer "why it doesn't work". The better way to do it is indeed to serialize your objects with JSON.stringify, which takes care of this issues and others, as suggested in Kevin's comment.

Categories : Jquery

Unable to change permission of the sdcard(emulator),can any1 guide me how to change them?
You first need to create an SD Card image. This can be done in the AVD Manager at the same time as creating the AVD image. The SD Card image has to be mounted too (i.e. if you use an already mounted SD Card). When no card is mounted, /sdcard is treated as a folder of /system. So when you try to write to /sdcard on an AVD image without an SD Card mounted it tries to write to /system which is read-only. Update: Make sure your SD card is mounted correctly. Use adb shell (or adb shell emulator-5554 when your real device is also plugged in) and enter df in the shell. The output should look like this Filesystem Size Used Free Blksize /dev 378M 32K 378M 4096 /mnt/asec 378M 0K 378M 4096 /mnt/obb 378M 0K 378M

Categories : Android

Can a termination variable in a condition of for loop be changed inside the loop?(Java)
The string length gets calculated every loop, and your for could throw an IndexOutOfBoundsException if your string becomes too short. IMHO yours is a very bad practice, for loops are intended to make a determined number of loops and should never be stopped, also their stop condition should never be changed inside the loop, you should use a while if you don't know how many iterations you want to do. But this is my personal opinion :)

Categories : Java

For Loop/Each Loop variable storage and comparison (jQuery or Javascript
you can use index in $.each() like $('.searchMe').each(function(index){ var id = $(this); sortUp += 1, sortDown -= 1; if (test) {// don't know what is test, let it is predefined id.attr("name", sortUp);// no need to add "" } else { id.attr("name", sortDown); } if ($('.searchMe').eq(index-1).length && id.attr("name") > $('.searchMe').eq(index-1).attr("name") ) { id.insertBefore($('.searchMe').eq(index-1)); } }); Or Alternatively you can define lastid like var lastId='';// let it be global $('.searchMe').each(function(index){ var id = $(this); sortUp += 1, sortDown -= 1; if (test) {// don't know what is test, let it is predefined id.attr("name", sortUp);// no need to add "" } else { id.attr("name", sortD

Categories : Javascript

What is the purpose of using final for the loop variable in enhanced for loop?
Adding final keyword makes no performance difference here. It's just needed to be sure it is not reassigned in the loop. To avoid this situation which can lead to confusions. for(Animal animal : animalList){ //do some function animal = anotherAnimal; // use animal variable here } You could also need to use this variable in anonymous function inside the loop

Categories : Java

DB2 Stored Procedure. How can I dynamically create a variable name inside a loop using the iteration variable?
Generally speaking, if you find yourself in the situation where you have to store an unknown number of variables, it is an indication of an incorrect program design. Why do you think you need to store every row in memory? Databases are optimized for set processing. However, if you insist on doing things your way, consider using arrays; an array can grow as you add elements to it (until it consumes all application memory and crashes the database, but that's none of your concern, right?)

Categories : SQL

Create XSLT variable that is a copy of XML, append nodes, loop through variable and output values
This should do it: <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl" > <xsl:output method="text" /> <xsl:template match="/query"> <xsl:variable name="xmlFragment"> <query> <xsl:copy-of select="*"/> <row> <Name>Mark</Name> <ID>14</ID> </row> </query> </xsl:variable> <xsl:for-each select="msxsl:node-set($xmlFragment)/query/*"> <xsl:value-of select="Name"/> <xsl:text xml:space="preserve"> </xsl:text> <xsl:value-of select="ID"/> <

Categories : Xslt

i want to use the variable out of the loop but the variable defined in the while loop
//SQL for display dish information of each category $query3="SELECT cat_id FROM restaurant_category WHERE cat_name={$display1}"; $result3=mysql_query($query3); $display3=mysql_query($result3); This appears to be an error, calling mysql_query on $result3. It should probably be $display3 = mysql_fetch_row($result3) And here: $display1 = null; while($i<$rowNum1) { $display1=mysql_result($result1,$i,"cat_name"); //display category name while($j<$rowNum2) { //display dish information } } Possible syntax errors in there. Also add $display1 outside of the while scope. Also oblig: mysql_* functions are depreciated.

Categories : PHP

Error "use of unassigned local variable" when using do while loop and bool variable in c#
You assign a value in the if, and the else if, but not in the else clause. If that final else is hit, the value is never assign to that variable. Looking at your code, it should probably be assigned a true value in that else. That will fix the problem for you.

Categories : C#

Reassign loop variable inside for loop. Bug?
Because $i = 0 is not always executed. It is only executed if the account did not exist. The account is then created, so on the next pass $i is not reset to 0. You need the context around the code as well. A simplified view of just this behavior: for($i = 0; $i < $numAccounts; $i++) { $accountExistsQ = mysql_query("SELECT id FROM networkBlocks WHERE accountAddress = '".$transactions[$i]["txid"]."' ORDER BY blockNumber DESC LIMIT 0,1")or die(mysql_error()); $accountExists = mysql_num_rows($accountExistsQ); if(!$accountExists) { mysql_query("INSERT INTO `networkBlocks` (`blockNumber`, `timestamp`, `accountAddress`, `confirms`, `difficulty`) ". "VALUES ('$assoc_block', '$assoc_timestamp', '" .$transactions[$i]["txid"]. "', '" .$transactions[$i]["confirmations"]

Categories : PHP

How can I increment a variable using a loop while using another loop at the same time?
What about int i;//counter for (i=0; i<=LENGTH; i++) { printf("Player %i ", i + 1); printf("Name: "); fgets(name[i], MAXLENGTH, stdin); ...

Categories : C

How do I use variable names using a for loop to reference a number in the variable name?
Use this $e = ${'_SESSION_Job10'.$x}; // $e = $_SESSION_Job101; actual variable here Live Demo instead of $e = '$_SESSION_Job10'.$x; // $e = '$_SESSION_Job101'; // string here Edit You have to use array like this ${'_SESSION_Job10'.$x}['progress']; Demo

Categories : PHP

Change normal loop to Parallel loop
This worked on my linqpad. I just renamed your Task class to Work and also returned an IEnumerable<T> from GetAllTasks: class Work { int _delay; private Work(int delay) { _delay = delay; } public void Execute() { Thread.Sleep(_delay); } public static IEnumerable<Work> GetAllTasks() { Random r = new Random(4711); for (int i = 0; i < 10; i++) yield return new Work(r.Next(100, 5000)); } } static class TaskExecuter { public static void Execute() { foreach (Work task in Work.GetAllTasks()) { task.Execute(); } } } void Main() { System.Threading.Tasks.Parallel.ForEach(Work.GetAllTasks(), new Action<Work>

Categories : C#

unable to get out the Loop
You question is unclear but explore that : private void remove(){ HSSFWorkbook wb = null; HSSFSheet sheet=null; try { FileInputStream is = new FileInputStream("C:/juni.xls"); wb = new HSSFWorkbook(is); sheet = wb.getSheetAt(0); //Tagging the loops OuterLoop : for (Row row: sheet) { InnerLoop : for (Cell cell: row) { if (cell.getCellType() == Cell.CELL_TYPE_STRING) { if (cell.getRichStringCellValue().getString().trim().contains("POST")) { row_count_post_1 = row.getRowNum(); DashBoard.txt.setText("Processed the STRING "POST" on Row#" + row_count_post_1); HSSFRow removingRow = sheet.getRow(row_count_post_1);

Categories : Java

Android - Proper way to listen for variable change, and do something upon change?
You must set your variable via a setter method. Then, you can be reactive to that change. public void setMyVariable(int value) { this.myVariable = value; if (myVariable == 1) { doSomethingWhen1(); } else if (myVariable == 0) { doSomethingWhen0(); } } A more elegant way to do that will be an observer pattern, Here you can find more detailed documentation about it. You must certainly avoid while(true) loops on mobile device, it will drain your battery and you are also blocking the UI thread. That's the reason why your UI is unresponsive and your cellphone it's quite hot.

Categories : Android

change value variable javascript if select field value change
Use a ternary operator to switch between 0 and .1 based on the select value var fees = ($("#select").val() === "cc" ? 0.1 : 0); You should wrap this in a function, and bind the select element to this function on change. e.g. : var sel = $("#select"); function setValue() { var total = 0, fees = (sel.val() === "cc" ? 0.1 : 0); // ternary $("#sub_total").val(total); $("#fee").val(fees); $("#sum").val(fees + total); // sum } setValue(); // call function sel.bind('change', setValue); // bind function to onchange of the select element

Categories : Javascript

Unable to get proper output of if-else loop
You need to add an space in the 2nd condition: [["${arr[1]}" == "MySQL-client-5.6.5_m8-1.rhel5"]] ^ ^ / - here here - so it is [[ "${arr[1]}" == "MySQL-client-5.6.5_m8-1.rhel5" ]]

Categories : Shell

Unable to store results of a loop
Here's a strategy with a little less code: library(exactRankTests) # sample data realdata <- data.frame(matrix(rnorm(1000),nrow=40)) # odd row indices x <- seq(1,nrow(realdata)-1,by=2) pvals <- vector(length=length(x)) # empty vector for(i in seq_along(x)) pvals[i] <- wilcox.exact(as.numeric(realdata[x[i],]), as.numeric(realdata[x[i]+1,]), alternative="greater", conf.level=0.95)$p.value

Categories : R

Unable to add 30 days to date within loop
$numPayments = 5; $nextPaymentDate = new DateTime; $interval = new DateInterval('P30D'); for ($i = 0; $i <= $numPayments; $i++) { $nextPaymentDate->add($interval); echo $nextPaymentDate->format('m-j-Y g:i a') . " "; } The advantage of this way of creating the initial date and this way of looping is that everything (the number of payments, the number of days to add and the output format for the calculated dates) is just written once in the code. If you need to change any of them in the future, you will only need to change it in one place.

Categories : PHP

Change global variable value with a local variable
There are 2 possible options: Change the 2nd parameter name (from blnUpgradeLocal to something else) in the function declaration Change the global variable value using window.blnUpgradeGlobal reference The former is better

Categories : Javascript

js Change variable will affect to original variable
Objects are always passed around by reference. a and this.i refer to the exact same object. To get different objects, you'd need to just do this.i = {c:1}; or similar.

Categories : Javascript

ajax API call Variable {variable} - How do I change it
You need to build up the URL dynamically, based on each account parameter. You could use a small reusable function for that: function createEvent(account, eventData, callback) { var url = "/events/" + account + "/events"; $.ajax({ type: "POST", url: url, data: eventData }).done(callback); } Then, to use it: var event = { name: "Marcus", location: "HERE" }; // Get some_account_number from somewhere... createEvent(some_account_number, event, function(msg) { alert( "CREATE EVENT Data Saved: " + msg ); });

Categories : Javascript

Binary Search in Python 2 variable not updating causing an infinite loop.....why is the variable not updating?
def binary_search (z, A, start, end): if end < start: return None else: mid = start + (end - start) / 2 if (z < A[mid]): return binary_search(z, A, start, mid-1) elif (z > A[mid]): return binary_search(z, A, mid+1, end) else: return mid I changed a couple of things around. I check first changed end < start: because if len(A) == 0: will stay constant and won't allow you to use it as a base case. Also, you when you a returning the binary search you need to skip the mid value, because that's the one you are returning. I tested the code and it works!

Categories : Python

VBA-Query Loop - Unable to convert to Form reference
You need to loop through the Selected items of your ListBox, and build a comma separated list that you will then be able to use with a SQL IN clause: SELECT * FROM dbo_Animals WHERE filed1 IN ("elephant", "giraffe", "lion") To build such a string, you can find some help here.

Categories : Vba

Unable to inspect variable
You're close. Your code doesn't works, because the variable $return in the while ( my $return ne "" ) { is another variable (declared in the scope of while) as your first $return. You can try the next: use 5.014; use warnings; chk_proc('[M]Installer'); #use the [] trick to avoid the 'grep -v grep :) sub chk_proc{ while( qx(ps -eaf |grep $_[0]) ) {sleep 5} };

Categories : Perl

unable to use session variable
It's always good idea to check if session is already exists. Try: if (!session_id()) session_start(); And try to var_dump($_SESSION); in 3rd controller after session_start() to check what is inside.

Categories : PHP

Unable to change JLabel value
From the exception you've posted, it seems the code you've shown us is in a static method, maybe main(), while the variable sysname is an instance variable, possibly declared as private JLabel sysname; You cannot access an instance field without an instance, ie from a static context.

Categories : Java

bash script unable to get the variable
To pass in the value of a shell script variable into awk you should the -v option like so: awk -v tick="$ticket" -v RS="--+" -F'|' ' $0~tick{print $1}' Do not do what unxnut suggests as $1 will be interpreted as the first argument to the script and not the first field in the record by awk. This may solve your problem temporarily but your script has some very bad practices in it and to get some actual help you should tell us what you are trying to do, show the input and the expected output and we can show the right approach.

Categories : Bash

Unable to fill input value with PHP variable
Don't change the window location in the success of your ajax call. The call is posting the data to test.php and you are getting your response back there. Then you are redirecting to the page with a blank post which results in just the asterisks. If you only want to display the results from test.php change your $.ajax call to the following: $.ajax({ url: 'test.php', data: data1, type: 'POST', success: function(response) { $('html').replaceWith(response); } }); Or if you do want to change the page, forget about the ajax and just post the form to test.php

Categories : PHP

Unable to subtract a table value via variable
We don't have enough information, but since you don't perform ANY error handling or validation that SQL resultset is returned, it could be an error caused by issues such as: no rows returned in first query some other parsing issue not directly evident I would propose that you use temporary strings and echo the actual SQL queries. Continue by actually testing them with MYSQL (through workbench, queryviewer, or console) in order to see where and what the error is. Also, it's not recommended to skip error checking and try to combine so many lines/steps into 2 lines. Imagine the first query does not return any results for example... Debugging: $query1 = "SELECT * FROM job_101 WHERE job_101.username='$_SESSION_User'"; echo $query1."<br/>"; $_SESSION_Job101=mysql_fetch_array(mysql_q

Categories : PHP

Unable to change value of string from @property
You need to use the @ symbol when using the NSString literal syntax. Like this: curDate = @"02-07-2012"; Read all about the usage of the @ symbol in Objective-C here.

Categories : Objective C

unable to change rating in android
change your xml to: <RatingBar android:id="@+id/ratingBar1" style="?android:attr/ratingBarStyleSmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:numStars="5" android:rating="5" /> but anyhow, small rating bar makes it hard to interact with and to rate. have a look at this

Categories : Android

Unable to change draggable mode
You are missing quotes around grid: Change your initialization to: $('#box').draggable('option','grid', [50,50]); Fiddle With something like this, the console can be your best friend. It may have led you directly to the problem: Uncaught ReferenceError: grid is not defined

Categories : Jquery

Unable to change Product Name in Xcode
When you double click and rename, it would have shown an alert, read carefully and check that all options are selected.

Categories : Objective C

chmod unable to change permissions
Looks like you've discovered that the Macintosh doesn't strictly agree with the UNIX permission bits. Ultimately, there are ACL bits that MacOS sets and that the Macintosh Finder obeys. To solve your problem quickly, in your Terminal command line, type in "open ." (or the path to your "startup" folder) and that will open up the folder in your Macintosh Finder. Then do a "Get Info" on the file: You can change your permissions here.

Categories : Osx



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.