while-loop Questions
17
Solved
You can get the same output with for and while loops:
While:
$i = 0;
while ($i <= 10){
print $i."\n";
$i++;
};
For:
for ($i = 0; $i <= 10; $i++){
print $i."\n";
}
But which one is f...
Hedgerow asked 2/9, 2010 at 16:32
5
Solved
I'm using Advanced Custom Fields for Wordpress and trying to loop a repeater inside a group. All I get is "Notice: Array to string conversion in..."
What's wrong & how do I fix it?
<?php i...
Aberration asked 28/8, 2018 at 12:0
6
Solved
I am not sure what the problem is but I keep receiving this error when I try to use a while statement in my code.
Invalid token 'while' in class,
struct, or interface member
declaration
I wa...
Camara asked 29/12, 2008 at 2:38
3
Solved
The while loop
Test the condition and if it is true, then execute the code
The do..while loop
Execute first time. Then test and execute.
So the difference between while and do..while is , programma...
Ci asked 11/6, 2017 at 6:47
3
Solved
I have a while let loop which goes over an iterator of Result and uses pattern matching; it goes over the iterator until it either hits an Err or the Ok's value is an empty string:
while let Some(...
Voluptuary asked 26/10, 2016 at 18:4
1
I have an API that returns times in a day and if those times are all taken then it won't return any. I want to move to the next day and try and check for times there but my test gets stuck and will...
Emmieemmit asked 3/12, 2020 at 23:47
6
Solved
I have the following shell script. The purpose is to loop thru each line of the target file (whose path is the input parameter to the script) and do work against each line. Now, it seems only work ...
Factotum asked 10/12, 2012 at 11:38
3
I have a bit of dilemma, In PHP both foreach loop and while loop seem to do exactly the same thing in this situation:
foreach ($execute->result as $item) {
echo $item['user_pass'] . '<br /&g...
Metempirics asked 10/10, 2014 at 13:44
20
Solved
I am reading serial data and writing to a csv file using a while loop. I want the user to be able to kill the while loop once they feel they have collected enough data.
while True:
#do a bunch of...
Handiness asked 1/11, 2012 at 16:4
5
Solved
I have a homework to implement a simple testing application, below is my current code:
import java.util.*;
public class Test{
private static int typing;
public static void main(String argv[]){
...
Vitascope asked 2/4, 2014 at 21:24
7
Solved
I have a script and want to ask the user for some information, but the script cannot continue until the user fills in this information. The following is my attempt at putting a command into a loop ...
Gagarin asked 11/3, 2011 at 14:41
3
Solved
I have the following:
$counter = 1;
while ($row = mysql_fetch_assoc($result)) {
$counter2 = $counter++;
echo $counter2 . $row['foo'];
}
Is there an easier way to get 1,2,3 etc for each result o...
Shopper asked 22/5, 2011 at 10:35
4
Solved
initiate () {
read -p "Location(s) to look for .bsp files in? " loc
find $loc -name "*.bsp" | while read
do
if [ -f "$loc.bz2" ]
then
continue
else
filcount=$[$filcount+1]
bzip $loc
fi
if [...
Estrade asked 5/9, 2011 at 23:13
6
Solved
What is wrong with using feof() to control a read loop? For example:
#include <stdio.h>
#include <stdlib.h>
int
main(int argc, char **argv)
{
char *path = "stdin";
FILE *fp...
Postliminy asked 25/3, 2011 at 11:42
22
Solved
I need to emulate a do-while loop in a Python program. Unfortunately, the following straightforward code does not work:
list_of_ints = [ 1, 2, 3 ]
iterator = list_of_ints.__iter__()
element = None...
Wellington asked 13/4, 2009 at 6:18
3
Solved
I have a function that interfaces with a telephony program and calls people. I want to know, is there a method that I can use to call folks for a certain amount of time?
I'd like to run a loop like...
Wilkison asked 19/2, 2013 at 21:58
5
Solved
Bash allows to use: cat <(echo "$FILECONTENT")
Bash also allow to use: while read i; do echo $i; done </etc/passwd
to combine previous two this can be used: echo $FILECONTENT | while read i...
Transnational asked 24/10, 2013 at 15:39
9
I'm tackling a project that requires me to use JavaScript with an API method call. I'm a Java programmer who has never done web development before so I'm having some trouble with it.
This API meth...
Garges asked 28/3, 2017 at 8:43
11
Solved
In this code sample, is there any way to continue on the outer loop from the catch block?
while
{
// outer loop
while
{
// inner loop
try
{
throw;
}
catch
{
// how do I continue on th...
Geometrize asked 15/7, 2009 at 19:20
15
Solved
I am trying to plot some data from a camera in real time using OpenCV. However, the real-time plotting (using matplotlib) doesn't seem to be working.
I've isolated the problem into this simple exa...
Precedency asked 8/8, 2012 at 23:36
15
Solved
I am having trouble coming up with the right combination of semicolons and/or braces. I'd like to do this, but as a one-liner from the command line:
while [ 1 ]
do
foo
sleep 2
done
Delanos asked 17/8, 2009 at 16:31
5
I've been having trouble using java's Scanner class. I can get it to read my input just fine, but the problem is when I want to output something. Given multiple lines of input, I want to print just...
Wamsley asked 22/3, 2012 at 5:32
7
Solved
If a value for one of the keys in my dictionary does satisfies a condition, I want to break out of the loop and set a property to True.
what I'm doing so far is:
fooBar = False
for key, value in ...
Marzipan asked 22/11, 2017 at 20:57
7
This Javascript function seems to use the while loop in an asynchronous way.
Is it the correct way to use while loops with asynchronous conditions?
var Boo;
var Foo = await getBar(i)
while(Foo...
Twain asked 23/8, 2016 at 21:13
5
I am a beginner in python programming. I wrote the following program but it doesn't execute as I want it to. Here is the code:
b=0
x=0
while b<=10:
print 'here is the outer loop\n',b,
while x...
Ringler asked 14/9, 2009 at 12:43
1 Next >
© 2022 - 2024 — McMap. All rights reserved.