Tagged Questions
0
votes
1answer
9 views
Java: change variable from outside while looping through a while queque
I am a Java Beginner and have a little question.
I have got 2 Classes:
the first one is a java formular, the important code is:
@Override
public void keyPressed(KeyEvent event) {
int key = ...
1
vote
0answers
18 views
Iterating through a list of variable to build tmp
I have a large set of numbers used as a variable in comparing two queries. The queries are rather time consuming to run so I would like to be able to do this automatically to sort out all variables ...
0
votes
2answers
35 views
jQuery variable loop with ajax
I have multiple ajax buttons in a page that I would like each one to send a GET data to a php file. Data are stored in HTML attributes. Here's what I have:
EDIT: full codes inserted (document ready)
...
1
vote
1answer
23 views
Executing multiple procedures in SQL Server without having to redeclare variable
I have a series of stored procedures all using the same variable. I would like each stored procedure to execute completely before moving onto the next one. I added a GO statement at the end of each ...
2
votes
1answer
23 views
Global variable is reset if loop send output to pipe
According the bash(1) man pages, when I run the following:
set -e
x=2
echo Start $x
while [ $((x--)) -gt 0 ]; do echo Loop $x; done | cat
echo End $x
The output will be:
Start 2
Loop 1
Loop 0
End ...
0
votes
1answer
19 views
Recalling variables in a command prompt loop
I am setting a number of variables using the for /f command.
setlocal ENABLEDELAYEDEXPANSION
set vidx=0
for /F "tokens=*" %%A in (target_list.txt) do (
SET /A vidx=!vidx! + 1
SET ...
0
votes
2answers
45 views
Creating factor variables from levels of other factor variables with if statement
I am a new R user, so apologies if this has been answered before and I did not recognise the similarity of the question.
I am really puzzled with the following task.
I need to produce some new factor ...
0
votes
4answers
74 views
Loop through data frame and variable names
I am looking for a way to automate some diagrams in R using a FOR loop:
dflist <- c("dataframe1", "dataframe2", "dataframe3", "dataframe4")
for (i in dflist) {
plot(i$var1, i$var2)
}
All ...
0
votes
3answers
36 views
Creating lag variables for matched factors
I have a question about creating lag variables depending on a time factor.
Basically I am working with a baseball dataset where there are lots of names for each player between 2002-2012. Obviously I ...
1
vote
1answer
19 views
Excel VBA: Using a variable when defining a list as a String
Pretty new to VBA but I'm learning quickly.
I'm finally getting used to using loops to perform repetitive tasks, and in this case, I want each pass through the loop to define a different variable. ...
1
vote
1answer
43 views
how to use a variable in grepl function within a loop-R
I am new to R and, have some problems with looping and grepl functions
I have a data from like:
str(peptidesFilter)
'data.frame': 78389 obs. of 130 variables:
$ Sequence : ...
-1
votes
2answers
63 views
How to change a variable every iteration of a loop (Java)
How can I have my variables change after every loop. I need the stated arraylist variables to go where the code is marked "HERE".
//variables i need to cycle through
static ArrayList<Integer> ...
1
vote
2answers
28 views
trying to figure out how to call two variables in an array in powershell
just starting to learn loops and arrays. i understand how to call a single variable in an array ie:
$animals = gc "c:\temp\animals.txt"
foreach ($animal in $animals)
{write-host "The"$animal "sleeps ...
0
votes
1answer
53 views
Matlab: Series of Variables in a Loop
This is a solution from another stackoverflow participant who helped me out.
Data is coming from a csv file:
States Damage Blizzards
Indiana 1 3
Alabama 2 3
Ohio 3 ...
1
vote
1answer
35 views
How can I efficiently define a variable based on multiple user choices?
I am writing a program for a companies website that will allow them to do quotes on the phone, a process they have been doing by hand for some time. One of the things they sell is a ridge cap for a ...
0
votes
3answers
37 views
set php variable as x,y location of image in html
I am trying to set the x and y of an image in html to the value of a php variables so that the coordinate is in a loop so that the image is drawn 5 times in a row. If someone could figure out how to ...
1
vote
2answers
93 views
R loop: name objectives by variable
I need to read daily netcdf files every month and give each a name ended with the date
library(raster)
year<-2004
startmonth<-1
for(monthd in 31){
days<-formatC(monthd, width=2, ...
0
votes
1answer
53 views
Variable change in loop
So this is more of a theoretical question but here goes. Say I have the following C code:
for(parameter) {
//do something
if(condition) {
variable = Value;
}
}
Say the loop ...
0
votes
1answer
17 views
How to pass default $counter into all the different for loop in PHP?
I have a design like:
-------------------------------
| | |
| 2 | |
| | |
------------ 1 |
| | ...
0
votes
2answers
42 views
Get variable values used inside a loop for outside of the loop
I need to get a part of some lines(Myfile) out of the 'for' loop either into two separate variables or into an array.My goal is to use each other for constituting path of the following lines ...
1
vote
3answers
43 views
incrementing a counter variable inside a FORLOOP
why is the variable "number" not increasing when the FOR loop goes over it again?
setLocal EnableDelayedExpansion
for /f "tokens=* delims= " %%a in (input.txt) do (
set /a N+=1
set /a ...
0
votes
3answers
42 views
Variable variables with $_POST
I have a long list of variables with a number at the end. For example address1 and I have all the way up top address14. I want to post these from a form but rather than type out $address1 = ...
-5
votes
1answer
45 views
Nested for loop in java. Am I allowed to declare a variable in the outer and increment it in the inner?
I want to use nested for loops to bring the elements of a 2d array into a 1d array. Can i do it with an index variable declared in the outer loop and incremented in the inner one like this?
for(int ...
0
votes
2answers
30 views
Shell Script Variable Manipulation
I've got this script:
for f in "$@"
do
q=${f#*Media/Music/}
echo q
done
All I want to do is set q to f after Media/Music/.
But it just echoes nothing.
If I do echo "${f#*Media/Music/}" ...
0
votes
0answers
15 views
MatLab: call consecutive variables for loop
I have variables in the workspace with the following names: A2010,A2011, A2012.....
Need to to the following for each variable:
AA2010=A2010';
t = AA2010>=2000;
z = [find([true,diff(t)~=0]) ...
1
vote
4answers
131 views
How to rename variables in a loop in Python [duplicate]
I want to run a program in Python which loops several times, creating a NEW array each time - i.e. no data is overwritten - with the array named with a reference to the loop number, so that I can call ...
0
votes
1answer
44 views
Splitting up a list of variables in SASS
In SASS is there a way to split up a list of variables / classes with hyphens?
It's a fuzzy question title so it's probably best I show what I'm trying to achieve.
In the below example I'm trying to ...
1
vote
0answers
9 views
METAPOST: using loop variables in labels
Dear stackoverflowers,
recently, while playing around with the METAPOST enviroment, I encountered a problem. While drawing something using the loop 'for' macro I needed the value of the loop variable ...
1
vote
2answers
58 views
Javascript array variable gets lost in loop [duplicate]
So I'm trying to put in additional buttons into my tinyMCE wysiwyg editor on wordpress. They're showing up and are functioning (sort of). When clicked they're just outputting the last variable in the ...
-1
votes
2answers
54 views
Xcode: How do I put this into a loop? [closed]
I am fairly new to xcode and trying to make my code more efficient. I have the code below and I want to put the repeated lines at the end into a loop (there are many more items in the array). I am ...
1
vote
2answers
88 views
read each line in a file, subsitute variables and send output to file bash
i have a file containing certain variables. i'd like to read each line, substitute the variables and echo the output. the source file i'd like to read is something like:
VAR1 is $A
VAR2 is $B
VAR3 is ...
1
vote
1answer
49 views
UNIX List files of in domain of file sizes
I am looking for a way to get all the files in a directory (which is a variable) and then check to see if those files are in between two values for file size.
I have three arguments. A directory to ...
0
votes
2answers
73 views
PHP - Variable inside a loop and another one outside
as the title said, i've this block of code and i want to know if i can write a variable that takes the name of another one similar to it but outside the loop.
is that makes a problem ?!
<?php
...
2
votes
1answer
26 views
How to handle variables in nested loops?
My script loops through posts on my WordPress site.
I'm also counting the number of unpublished posts and storing it in my $i variable.
However, as this is looping through multiple results, I need ...
0
votes
1answer
89 views
Why does static variable not allow loop() to run?
I am writing code for an lamp that mimics the sun (ie rises and sets according to the real sun).
I am trying to use a static variable in the loop in order to keep count of the days since 1/1/12 (the ...
2
votes
4answers
90 views
implementing a loop using final variables
Is there a way to implement a loop using final variables?
I mean a loop that would run for a specified number of iterations when you are not allowed to change anything after initialization!
0
votes
2answers
130 views
C++ - Declaring reference variables inside loops?
As I know, declaration of variables of POD types or primitive types inside loops is OK (no overhead).
How about reference variables?
Does it matter to performance, to declare reference variables ...
-1
votes
4answers
150 views
Program that detects which letter is the most common
I am a beginner in C, I am trying to make a program which detects which letter is the most common of max 10 letters.
Here is what I've got so far:
char one = 'a'; //0110 0001
char check[10];
...
1
vote
2answers
192 views
Loop on tables with PL/pgSQL in Postgres 9
I want to loop on all my tables to count rows of each of them. The following query get me an error :
DO $$
DECLARE
tables CURSOR FOR SELECT tablename FROM pg_tables WHERE tablename NOT LIKE ...
1
vote
2answers
121 views
Passing variable changes between threads in Python functions [Beginner]
So I have this code:
import time
import threading
bar = False
def foo():
while True:
if bar == True:
print "Success!"
else:
print "Not yet!"
...
0
votes
1answer
78 views
Variable's name in another variable mysql
The situation is that I have a mysql stored procedure that has some variables and I want to use their value based on a SELECT that I do to get the list of variable I really need in a loop:
...
0
votes
3answers
63 views
how do I prevent my variables going on forever?
Dr.Java won't run my program because my variables are going on forever and I'm not sure how to prevent that from happening. If you could tell me how to fix that, it'd be great. I'm a beginner so this ...
0
votes
1answer
40 views
array to variables
I'm programming in PHP and I have a huge array which contains a lot of ID's. I need all these ID's to be variables so I can use these in another function. I have done a lot of research on loops in PHP ...
0
votes
3answers
120 views
bash command line append to variable will prepend instead
in shell scripts I usually append a string to variable with "${variable} end". However, I have a file "file.txt" in which I want all lines to be appended by "end". So command line I do, for instance, ...
1
vote
1answer
116 views
bash: for loop, two variables linked
I've the following problem; two directories that containing:
dir1: a list of files like the following:
file1.fq file2.fq file3.fq
and so on..
dir2: a lis of files like the following:
...
0
votes
5answers
92 views
php - Putting a for loop inside a variable
I am trying to echo a for loop inside a html mail message, the loop is
for($i=0; $i<$arrlength; $i++)
{
echo $mailroom[$i] ;
if ($i<($arrlength-1) )
{
echo " & ";
}
}
It is printing ...
1
vote
2answers
1k views
How do I loop through a MS Access recordset with VBA and assign variables to the results?
My VBA is quite rusty and I seem to be drawing a blank. I am using MS Access 2010 if it matters.
I have the results of a query that return two fields (Field1 is text and Field2 is double) and five ...
0
votes
1answer
53 views
how to prefix a var between spaces (in bash), then return concatenated strings to variable array?
for instance
var=${foo}
somecommand=${fofo -b -a -r}
for i in "${somecommand}" ; do
echo $i
done
say this this returns a full line like
/bar /bar /bar
how would I prefix ...
0
votes
2answers
203 views
Bash - run command using lines from text file
I am a bit new to bash scripting and have not been able to find an answer for what I am about to ask, that is if it is possible.
I have a text file which is created by search a directory using grep ...
0
votes
0answers
14 views
copy from a list of and run the same process for each variable in the list
i am running a code to produce the same invoice for difference customers using the customerID (IDCUST). i have the code to process the invoice, how do i run it for each customer at once.
...