while-loop

Perl, A hash of arrays: adding and removing keys, adding to an array, all in a while loop

淺唱寂寞╮ 提交于 2019-12-06 08:37:53
问题 I have a hash which should contain certain keys which are linked to their own arrays. To be more specific, the hash keys are quality values and the arrays are sequence names. If there already is an array for that quality, I'd want to add the sequence name to the array that is linked to the quality in question. If there isn't one, I want to create one and add the sequence name to it. All this is done in a while loop, going through all the sequences one by one. I've tried to do things like in

JFrame freezes during while loop [duplicate]

佐手、 提交于 2019-12-06 07:13:55
This question already has answers here : Running a JFrame with a JProgressBar (2 answers) Closed 6 years ago . I am working on a Java program, which reads text files does some probability calculations. Reading files and all related calculations are done in a while loop. I had created a GUI using JFrame, where i had added a Progress bar (using JProgressBar) to show the progress since the program takes a while to process the files. The code looks like - while( there are more files to read ) { Read this file ; Do calculations ; Update progress bar ; } Now, the problem is once the while loop

Use a for-loop or a for-each loop? [closed]

给你一囗甜甜゛ 提交于 2019-12-06 06:39:30
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 6 years ago . Should we prefer the for-each loop instead of the traditional for-loops? Is the while-loop advantageous? List<String> names = Arrays.asList("John", "Jeff", "Mary", "Elise"); //for-each loop for(String name: names){ log(name); } //traditional for-loop for(int index=0; index <

The code is supposed to transform every letter of every word to uppercase. But running the code results in a bus error. What causes the bus error?

只愿长相守 提交于 2019-12-06 06:25:20
The code is supposed to transform every letter of every word to uppercase. But running the code results in a bus error. What causes the bus error? #include <stdio.h> char *ft_strupcase(char *str) { int index; index = 0; while (str[index] != '\0') { if (str[index] >= 97 && str[index] <= 122) str[index] = 65 + str[index] - 97; index++; } return (str); } int main() { char *name = "sEbas"; printf("%s\n", ft_strupcase(name)); return (0); } Input: sEbas Output: SEBAS The string "sEbas" is a const char[] , so you shouldn't use it to initialize char* name . If you compile this code on Visual Studio

How to add case statement to add break after every record?

依然范特西╮ 提交于 2019-12-06 06:06:20
There should be a break after every row LIKE 'A%' when find next records of LIKE 'B%' . $stmt = $con->prepare("SELECT * FROM fistevent WHERE Event_Id=? AND TicketType=? AND row_name REGEXP '^[A-Z]' ORDER BY row_name ASC"); $stmt->bind_param("ss", $_POST['EventId'],$_POST['TicketType']); $stmt->execute(); $result = $stmt->get_result(); $numRows = $result->num_rows; if($numRows > 0) { echo ' <div class="register">'; while($r = $result->fetch_assoc()) { $EvntId = $r['Event_Id']; $RowName = $r['row_name']; echo '<ul id="sub" class="sub">'; if($r['seats'] == null){ echo '<li class="BlankSeat" ></li

How to do a “while”-like loop in XSLT?

允我心安 提交于 2019-12-06 05:53:47
I'm a novice in XSLT and I'm struggling a lot with this issue: I need to do a while-like loop in XSLT. I don't think the for-each will be enough to solve this problem. I have a variable that is the result of a SELECT statement. It can return 0 or an integer. If the value is 0, it needs to do the SELECT again sending another parameter to see if the value is different. I can only think in using a while-like loop, but maybe it has another way of achieving this? Like using a template and calling itself in the end? Is it possible? Something like that: <!-- initiate TEMPLATE --> <!-- WHILE $VALUE =

how to continuously switch textswitcher between two values every 2 seconds

牧云@^-^@ 提交于 2019-12-06 05:48:40
问题 I've looked at the code here as well as the code here but I still can't seem to get my code to work right. With the 2nd link, I can get a "timer" that counts up on the page, but with the first, my UI locks up. What I'm trying to do is have a seperate thread that continually flips the text in a textswitcher every 3 seconds as long as the app is open. I need it to switch between two values, and have tried something like the following: private Runnable mUpdateTimeTask = new Runnable() { public

How to make my own while Loop just like Wordpress Loop?

可紊 提交于 2019-12-06 05:41:06
im new here and new in PHP too.. Just wondering how to make my own flexible loop just like in Wordpress... Note im not talking about wordpress.. I want to implement it on myown PHP application... let's look back in WP, there is a code something like this: while (have_post() : thepost())// .. bla bla... echo the_title(); echo the_content(); endwhile; // this is just an ilustration Could you figure out how have_post() or the_post() interact with database, so that they can be loop.. thanks.. WordPress uses global variables that these functions modify when iterating through the loop. e.g.: var

php - for loop inside a while loop, correct syntax?

本秂侑毒 提交于 2019-12-06 05:17:26
I have this loop while (count($arr) < 7) { $string = 'xx'; for ($i=0; strlen($string) < 4; $i++) { $string = $string.'1'; } echo "<br>array length is less than 7, word $string is created."; $arr[] = $string; } Every time I run this part of the code, my xampp local server would time out and gives the server not found error. I have found that if I delete the inner for loop, it would run fine. Is there anything wrong with putting the for loop inside the while loop? Also, my conditional statement strlen($string) < 4 in the for loop does not have any reference to the $i variable, but I don't see

Parallel while Loops in Python

醉酒当歌 提交于 2019-12-06 04:51:16
I'm pretty new to Python, and programming in general and I'm creating a virtual pet style game for my little sister. Is it possible to run 2 while loops parallel to each other in python? eg: while 1: input_event_1 = gui.buttonbox( msg = 'Hello, what would you like to do with your Potato Head?', title = 'Main Screen', choices = ('Check Stats', 'Feed', 'Exercise', 'Teach', 'Play', 'Go to Doctor', 'Sleep', 'Change Favourite Thing', 'Get New Toy', 'Quit')) if input_event_1 == 'Check Stats': myPotatoHead.check_p_h_stats() elif input_event_1 == 'Feed': myPotatoHead.feed_potato_head() elif input