Questions tagged [do-loops]

a 'do' loop is a specific type of iteration used to run code repeatedly based on the evaluation of a boolean statement or variable.

do (while) loops in Java: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/while.html

do loops in Fortran: https://en.wikibooks.org/wiki/Fortran/Fortran_control#Loops

do loops in Scheme: https://schemers.org/Documents/Standards/R5RS/HTML/

389 questions
0
votes
1 answer

Script terminates prematurely after do loop. Last "echo" is not executed.

I am looking to execute the following script below. The issue I am encountering is it will not execute anything after the do loop. It doesn't matter what I happen to have after the loop, it never executes, so I am def missing something somewhere.…
WxJack
  • 21
  • 6
0
votes
2 answers

Excel "Do While" Loop Not functioning correctly after first iteration

I have a Sub that does some light formatting, and then I need it to evaluate and count whether a column contains a "1" or nothing, and if that column has a header that isNumeric or not. First iteration of the Do...Until loops functions exactly as…
axstros
  • 3
  • 2
0
votes
3 answers

VBA Do Loop and Input Box content not working

I'm new with VBA loops. What I'm trying to do is a do loop and input box procedure that asks for a product code until a valid one is input. The code should start with the letter P, and should be followed by four digits. For an invalid code input, it…
Rosario
  • 47
  • 4
  • 10
0
votes
1 answer

Custom Import VBA issue

I use a custom made import function (skeleton below) to gather data from "Linked" text files (containing header/records/footer). The first field of the header will always contains 123, but I need to skip those records where the second field in the…
Wowdude
  • 139
  • 1
  • 5
  • 16
0
votes
1 answer

Making an (iterative?) Do loop in SAS

I know this is simple but I can't seem to figure it out. I have a dataset that has 50 students, and one of the columns is called test score which has a test score for each of the students. I need to go through and find the difference between all of…
hk47
  • 127
  • 3
  • 14
0
votes
1 answer

Javascript: while loop neverending

I've been trying to fix this loop, but apparently it doesn't recognize when the input is right. Am I using the right kind of loop here? var userChoice = prompt("Do you choose rock, paper or scissors?") if (userChoice !== "rock", "paper",…
tklein
  • 77
  • 2
  • 8
0
votes
3 answers

How to continue from the starting of code when an exception is thrown?

I’m running a code that throws an exception,I want run the exception code continuously whenever the exception is thrown it has go to starting and should start the program from starting. Here is my exception method and main
Dilip Bobby
  • 323
  • 5
  • 15
0
votes
1 answer

SAS: Construct Do Until by Copying Last Row

I have yearly data that ends at 2013, but I'd like to use that year and copy it for 2014, 2015, and ultimately 2016 (whatever the current year of data we have). Using the test data below: DATA TEST; INPUT YEAR Q1 Q2 Q3 Q4; DATALINES; 2012…
kstats9pt3
  • 799
  • 2
  • 8
  • 28
0
votes
1 answer

Recursive N-nested loop

Consider that you have a square matrix M(N,N) and you want to sum all pairs such that: M(i,j)*M(i+1,j)+M(i,j)*M(i,j+1) to do this, the easiest way is to compute: INTEGER i,j,N, SUMT INTEGER M(100,100), c(101) N=100 SUMT = 0 do j=1,N c(j) =…
Learning from masters
  • 2,032
  • 3
  • 29
  • 42
0
votes
4 answers

Java loop run only for the max tries

I have created an if statement while it's true to keep on asking question until you get it right. However that is not an option in my case. I have implemented a counter with the max tries, if the loop runs 3 times and you still got it wrong then…
Dmitriy
  • 97
  • 3
  • 15
0
votes
0 answers

Rolling Arrays as a possible solution to a rolling window in SAS

I am trying to calculate the dosage of a particular drug for a population to see if any member in this population is over a certain threshold for any 90 consecutive days. So to do this I am thinking that I am going to need to make a arraty that…
0
votes
1 answer

Do loop won't exit after conditions are met?

I've been trying to make a loop that repeats itself until an does not element exists on the page. However, when the condition is met, the loop does not exit. Any suggestions? Dim userExt userExt = 1 Do until Not…
Dor Moshe
  • 13
  • 5
0
votes
1 answer

Parsing through SAS array, macro variables

I want to create an array which stores the names of variables. Then index into the array and pass to a function. So far I have the following: %let variables = cat dog lion sheep; data _null_; array a_vars[*] &variables; do i = 1 to…
Josh
  • 3,231
  • 8
  • 37
  • 58
0
votes
2 answers

Do... While loop counter implementation not working

I created a program in C# (Console Application), which prompts the user to enter the answer to "2+2=?", if its right a message pops up "Well done", if not then "Please try again". What I am trying to do is make the program tell the user how many…
user5379214
0
votes
2 answers

Java game of pig score not counting?

I have the game of pig in java running, however, it seems that player one score keeps going past 100 even though i have multiple things in place to make sure it doesn't happen. player 2 won't go over 100, but player 1 will. What am i doing wrong…
Doug Barta
  • 161
  • 2
  • 15