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

in.nextInt() Do While/Boolean Loop Issue

I just started using Java and am learning Do/While loops and Booleans; However, an error keeps popping up with the nexInt. I have no idea what I am doing :). Here is the assignment this program is supposed to complete: "Set up a password variable…
0
votes
1 answer

VBScript Error 9 in AtEndOfStream Loop

I am using a script like this to loop through some data in a text file: Do Until objFile.AtEndOfStream 'Check if it is not a blank line; otherwise skip it If Len(Trim(objFile.ReadLine)) > 0 Then 'Some code end if Loop I print…
MillerMedia
  • 3,651
  • 17
  • 71
  • 150
0
votes
5 answers

how to produce -400,-200,-400 in sequential order

I am trying to write a for loop in the second version which produce the same result in the original code but i am not sure how to get -400,-200,-400 in sequential order. original code: p->m_p[0] = randFloat(-400.0f, 400.0); p->m_p[1] =…
0
votes
1 answer

Keep Inputting values until array is full?

I'm creating a class that keeps the scores of quizzes taken by students. Here's the specs: The constructor is to a. Create an instance of an int-type array with the length of input parameter. Each element in the array is initialized as -1. b. The…
Hazel
  • 11
  • 2
0
votes
0 answers

How can I reset a if-command? Or jump back to the point before the if-command was executed?

So yesterday I asked a question about some GUI-ing. I completly threw that over, since I found it a little to complicated for me to actually deal with it. Now I am reworking the thing in the console. And I got myself stuck again. My problem this…
Erik Ro
  • 9
  • 1
0
votes
2 answers

sas create variable with do loop

I have the following code : data DEFBIS.Taux_fec_2006_2010; set DEFBIS.Taux_fec_2006_2010; Taux_15 = 1000 * N_15 / (5 * P_15); Taux_16 = 1000 * N_16 / (5 * P_16); ... Taux_49 = 1000 * N_49 / (5 * P_49); run; How can I condense this code…
user2568648
  • 3,001
  • 8
  • 35
  • 52
0
votes
2 answers

Change of a macro variable in a DO loop

Im using the following loop to generate the sums of some columns using a class statement: %macro do_mean; %do i = 50 %to 100; %let string1 = %eval(100-&i); **%if string1 = 5 %then %let string1 = "05";** %if &i = 95 or &i = 90 or &i = 80 or &i =…
burton030
  • 405
  • 4
  • 8
  • 23
0
votes
1 answer

SAS Loop for renaming variables

I want to replace values of some variables and rename them. Basically, I have many variables called f2 f3 f4 and so on up to f1065. The logic is as folllows: I need to replace values of variables f14 f18 and so on by 4 up to f54 by values of…
user3812923
  • 39
  • 1
  • 4
0
votes
1 answer

Matching on multiple variables; SAS macro do loop when using _n_ as a variable

I would like to split my observations in a "parent" dataset into their own unique "child" datasets. I need to do this for several parent datasets, so I am trying to create a macro with a do loop inside to generate these datasets. But my code is…
mrlcpa
  • 83
  • 2
  • 11
0
votes
1 answer

How to loop over a parameter list and submit jobs?

I have a job that has an input and I want to loop over a list of parameters while submitting the job. Here is the part of my script: #!/bin/bash errors=$HOME/ERRORS/convergence/GvsE/B_2/error.log count=`qstat | wc -l` gi=( "0" "0.25" "0.5" "1" "2"…
0
votes
1 answer

Password reader String Array

So my program is designed to great the user and ask for a password. once the user enters a password it is compared to my precoded password "ans[]" and if the password matches what the user enters then it prints a welcome greeting. #include…
Zanderg
  • 159
  • 2
  • 5
  • 11
0
votes
2 answers

How do I execute code until a button is pressed?

I am creating a Rock-Paper-Scissors game. I need the code to loop until the player chooses to quit. How can I accomplish this. Imports System.Random Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As…
user3389547
  • 33
  • 1
  • 3
0
votes
1 answer

Stack Data Loop - SAS Macro

I have 51 files (I pulled unemployment rates for all 50 states plus DC from the BLS), and I need to stack them on top of each other. I am working on a macro that will import the files and then stack them, but I am stuck on how I can write a loop to…
0
votes
1 answer

how to excute sas macro iteratively in another macro?

i would like to get result of brand_channel macro. macro is not working on i=2,3,4 in %do-loop statement. How can I execute doing_scoring macro iteratively? thanks! %doing_scoring; ... ... ... %mend doing_scoring; %macro brand_channel; proc sql…
gosari
  • 1
0
votes
1 answer

Batch Program Issue if-then Math

So there is some problem in this code, its probably just some punctuation error that I haven't noticed yet but for some reason I cant find it. I read that this is how to do a loop with Do then the number of times, in this case '%dmg%', tell me if…
Andenrx
  • 606
  • 1
  • 5
  • 8