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
3
votes
4 answers

Why does my loop not allow my labels color to change?

Without the do loop, my code runs fine. As soon as I place it within a do or while loop the code fails to update the color status. Any idea? From what I have gathered from the internet, my loops are written correctly. using System; using…
3
votes
2 answers

How to skip a few iterations in a do loop in Fortran

For example, I want to loop from 1 to 500 at an increment of 2. However, for every 8 loops I want to skip the next 18 loops (make the do-variable increase by 18). How do I do that? My code is: event = 0 do i = 1,500,2 event = event + 1 if…
FalloutRanger
  • 127
  • 2
  • 8
3
votes
3 answers

How do I stop multiple line output from command substitution from being concatenated in BASH script?

I have text files in multiple subdirectories some/path/one/file some/path/two/file some/path/three/file some/path/foo/file ... I need to be able to grep file for a match, but retain the individual line returns so that I can operate on each match…
user2773624
  • 97
  • 1
  • 2
  • 4
2
votes
3 answers

How can I loop some code so that it repeats every time confirm() returns true?

I've tried using do-while loops but it doesn't seem to be working properly: let rep; //this variable tells the loop whether to run or not let nOfTimesTheLoopRuns = 0; do { nOfTimesTheLoopRuns++; console.log(`This loop has run…
Laionlel
  • 23
  • 2
2
votes
0 answers

Implied DO-loop compilation performance

The following implied Do-loop produces a bad performance at compile time haarWPhi2D = reshape([((((((2**(-j/2))*haarWaveletPhi((2**j)*(m*dx)-k))* & ((2**(-j/2))*haarWaveletPhi((2**j)*(n*dt)-l)), & m = -grid_size, grid_size), k = -grid_size,…
2
votes
1 answer

Exercise in C with loop statements: Write code to reverse numbers with do-while statement

I have a task (currently studying the loop statement so I'm in the beginner phase)that asks to make a program to reverse an integer number so it must have the do statement . The output should be (example): Enter a number: 4568 The reversal is:…
necxor
  • 35
  • 5
2
votes
3 answers

array processing with different indices and missing values in SAS

have is a sas data set with 4 variables: an id and variables storing info on all the activities a respondent shares with 3 different members of a team they're on. There are 4 different activity types, identified by the numbers populating in the…
J.Q
  • 971
  • 1
  • 14
  • 29
2
votes
2 answers

VBA Web Scraping Code Loop Fails After 3rd Iteration

I'm trying to pull data from multiple webpages (different stock pages from the same site). I can get the data pulled for the first 3 times the loop is executed but on the 4th iteration it brings up error 91: Object Variable or With block Variable…
breadhead1
  • 31
  • 2
2
votes
2 answers

Program repeating switch-case because of inability to get user input again during a loop

I'm almost done with a Java project for an intro class where a user has to perform conversions on a value of gasoline. The program runs fine when I put it through command prompt, up until one point where you select the conversion (from the choices…
Rachel
  • 73
  • 6
2
votes
1 answer

create index in SAS using do loop

Say I have a set of data in this format: ID Product account open date 1 A 20100101 1 B 20100103 2 C 20100104 2 A 20100205 2 D 20100605 3 A 20100101 And I want to create a column to capture the sequence of the…
cyb
  • 23
  • 2
2
votes
1 answer

Try Again Do-While Loop

It is a very simple program. The computer and user chooses a number between 0-3. I want the program to loop back if the user does not guess the same number as the computer. String input; // input is a string variable int cpucrazy; int…
luckyruby1
  • 51
  • 1
  • 8
2
votes
1 answer

Fortran loop not working

Fortran returns an error message saying floating point overflow when i run this program single implicit none integer :: n,k real, dimension(255) :: x n = 255 x(1) = 1/3.0 x(2) = 1/12.0 do k = 3,n x(k) = 2.25*x(k-1) - 0.5*x(k-2) end do print…
Roger
  • 21
  • 1
2
votes
2 answers

Trying to understand itoa function

I tried to re-write the itoa() function from K&R exercises, but I failed to define it. I see the answer of the function in the library , but I can't understand what is inside the do block. Please explain it to me. Thanks! /* itoa: convert n to…
2
votes
1 answer

SAS - Do looping from condition1 to condition2

I am looking to have a programme which cleans up some messy data I have, I am looking to do this for both the assets and liabilities side of the project i'm working on. My question is there a way to use a do loop to use the cleaning up data to first…
78282219
  • 593
  • 5
  • 21
2
votes
1 answer

Using Word VBA, How to change the condition of a loop without having to replicate the whole loop?

I want to call a routine with arguments to be used as the condition of a loop. The code that follows doesn't works, it gives the ERROR 13 (incompatible types). How do I fix this? Many thanks! Sub foo() Call bar("a>10") End Sub Sub…
sergio trajano
  • 189
  • 1
  • 1
  • 14
1
2
3
25 26