while-loop

SQL 'while' to read a table data to a variable

霸气de小男生 提交于 2019-12-11 20:32:43
问题 How could I write a while loop to populate data from a table to a variable to be used in a seperate query ? EX: select ITEM from Table1 ITEM A0001 B0001 C0003 D0005 E0032 If I can get all that results here under column ITEM to @var1 and then use it in a seperate query like: select * from Table2 where @var1 = Item_table2 <-- a random column in table2 This query should match @var1 from A0001 to E0032 to the Item_table2 column in Table2 . 回答1: You don't need a loop. select * from Table2 where

How to add an incremental count (version) to a string (file) in Excel/VBA?

橙三吉。 提交于 2019-12-11 20:27:45
问题 I have tried a lot of different things, and it seems like I cannot get it to work. So basically, this is a small piece of my complete code. I am using Microsoft Scripting Runtime to save the file, using the FileExists() to check if the file actually exist before saving. This is working fine if I remove the IF-statement/Loop. However, now it feels like FileExists won´t find the string, MyFilePath , when I run it with the IF/Loop. (getdirsubparentpath is a function) Dim week, UserName As String

While loop waiting for input python

岁酱吖の 提交于 2019-12-11 20:24:11
问题 I have a question about while loops in python. I want to make a program that performs a while loop in a certain time.I want to add the extra feature that while the program us running,a certain variable can be changed by pressing a random key. from time import sleep import time i=0 a=0 while i<10: i=i+1 i=i+a a=a+1 time.sleep(1) print i I want to do it that the variable a can be reset to 0 by pressing any key.The loop should continue unchanged if no button is pressed.What command should i add?

Jmeter While loop

家住魔仙堡 提交于 2019-12-11 19:55:09
问题 I'd like to perform a while loop using jmeter. Within the loop I'm using xpath extract to pull information from the server response, and storing it in a variable. I'd like to quit the loop if that variable has any data in it (if the request has been successful) - otherwise I'd like to fail if it doesn't respond correctly in x number of attempts. Is this something that JMeter can do? 回答1: I found a solution for this If you know the response that you are trying to extract from Xpath extractor,

Python While Loop - Variable Not Updating?

扶醉桌前 提交于 2019-12-11 19:39:02
问题 This code simply looks for a string in another string and returns the last postion of the occurance in the search string or -1 if its is not found. I don't understand why my variable next_y is not updating considering that pos is an input into computation of next_y . My thought that is that if I update pos then next_y should also update. Instead pos gets updated and remains in the loop forever. def find_last(x,y): if x.find(y) == -1: return -1 pos = x.find(y) next_y = x.find(y, pos + 1) while

Loop MySql INSERT query. While or Foreach?

给你一囗甜甜゛ 提交于 2019-12-11 19:26:11
问题 I'm struggling whit this... Basically, I have a script that will run every day (cron job). This script has to retrieve data from a table and it will post the data in another table (same database). Here is my example script: <?php $c = mysql_connect("localhost", "user", "password"); $db = mysql_select_db("mydb", $c); $query_sel = "SELECT id, rating, rating_count FROM mytableone"; $result_sel = mysql_query($query_sel) or die(mysql_error()); $ids = array(); while($id = mysql_fetch_array($result

Show only five first lines from text file

陌路散爱 提交于 2019-12-11 19:19:01
问题 I have this code (from SteAp): <?php $file = fopen("news/news_2013.txt", "r"); $i = 0; while (!feof($file)) { $posts[] = fgets($file); } fclose($file); foreach ($posts as $rawPost ){ $datePart = substr( $rawPost, 0, 19 ); $newsPart = substr( $rawPost, 20, 10000 ); echo $datePart . ': ' . $newsPart . '<br />'; } ?> I use it here: http://flamencopeko.net/news. Works perfect. I'm trying to make a version for the main page that shows only the five newst lines. Like this: http://flamencopeko.net

while loop does not terminate - float arithmetic [duplicate]

拥有回忆 提交于 2019-12-11 19:01:00
问题 This question already has answers here : Comparing currency values as floats does not work (4 answers) Closed 5 years ago . I am working on C program with float values, below is my code. #include<stdio.h> #include<stdlib.h> #include<float.h> int main() { int counter = 0; float quarter = 0.25; float dime = 0.10; float nickel = 0.05; float penny = 0.01; float change = 0.00; printf("hi, how much do i owe u?\t"); scanf("%f", &change); while(change > 0.0) { if(change >= quarter) { change -=

Try-Catch inside While Loop

怎甘沉沦 提交于 2019-12-11 18:52:55
问题 The code below asks the user how many racers he/she would like. while (true) { // loops forever until break try { // checks code for exceptions System.out.println("How many racers should" + " participate in the race?"); amountRacers = in.nextInt(); break; // if no exceptions breaks out of loop } catch (InputMismatchException e) { // if an exception appears prints message below System.err.println("Please enter a number! " + e.getMessage()); continue; // continues to loop if exception is found

While loading PHP script, display animated GIF

给你一囗甜甜゛ 提交于 2019-12-11 18:29:56
问题 I have tried to get several examples that I have found on here and the internet with out success. Goal: To display a animated gif while php scripts run. Background: This page is loaded via iframe. The php script I have tests 3 vpn connections and then displays a check (good) or an X (bad). The php portion works, but since there is a delay while testing I want to display the animated gif progress bar. Running Apache on CentOS 5.7 Currently this is done in a single file named: status.php I