while-loop

while loop using NSTimer

久未见 提交于 2019-12-11 08:14:40
问题 I want to create a NSTimer that runs for lets say 10 minutes. I then want to write a while loop aftewards delaying 10 minutes of time before the line afterwards is executed. For example. NSTimer * countDown = [NSTimer scheduledTimerWithTimeInterval:10.0 target:self selector:@selector userInfo:nil repeats:NO]; while (countDown == stil running (hasnt reached 10 minute mark) ){ // kill 10 minutes of time }//when 10 minutes is up execute next line of code 回答1: First The timeInterval parameter of

Use an alternative of “if” statement for checkBoxes

痴心易碎 提交于 2019-12-11 08:05:46
问题 I try to replace each "if" by a "for" or "while": if (CheckObject1.Checked) XRPC.SetMemory(8184, value); if (CheckObject2.Checked) XRPC.SetMemory(7848, value); [...] if (CheckObject20.Checked) XRPC.SetMemory(1800, value); I already tried this but the problem is that I don't know how to increment the number at the end of checkBox: int current = 8184; int X = 1; while (current > 1800) { if (CheckObjectX.Checked) // regex? XRPC.SetMemory(current, value); X += 1; current -= 336; } I don't know if

Modify a Tensorflow Variable inside a loop

六月ゝ 毕业季﹏ 提交于 2019-12-11 07:57:40
问题 I would like to modify certain indexes of a Variable inside a while loop. Basically convert the python code below to Tensorflow: import numpy tf_variable=numpy.zeros(10,numpy.int32) for i in range (10): tf_variable[i]=i tf_variable Tensorflow code would look like following: except it gives error import tensorflow as tf var=tf.get_variable('var',initializer=tf.zeros([10],tf.int32),trainable=False) itr=tf.constant(0) sess=tf.Session() sess.run(tf.global_variables_initializer()) #initializing

what's wrong with this program

独自空忆成欢 提交于 2019-12-11 07:52:42
问题 I've a code snippet: class WhileTest { public static void main(String s[]) { int x=12; while(x<13) { x--; } System.out.println(x); } } The output of the above program is: 2147483647 Why so? Code on ideone 回答1: x is decremented and then underflows reaching Integer.MAX_VALUE 回答2: Note that x = 12, and you keep subtracting. This results in x always being less than 13. That is until Integer Overflow occurs (when x gets to the lowest possible int (Integer.MIN_VALUE)), and the number wraps around

Problem displaying query results

限于喜欢 提交于 2019-12-11 07:45:30
问题 I have a MySQL table set up using phpMyAdmin which you can view in the images below: And here is the populated table: The problem I have is when I issue the following query, no results are returned. I am struggling to work out why. <?php $db_host = 'localhost'; $db_user = 'root'; $db_pass = 'root'; $db_database = 'bbg_db_2'; $dbc = mysql_connect($db_host,$db_user,$db_pass); $sdb = mysql_select_db($db_database); $query = "SELECT category_name, category_desc FROM categories"; $result = mysql

Nested loop in mysql stored procedure

梦想的初衷 提交于 2019-12-11 07:39:19
问题 I am having a simple nested while loop in stored procedure , but it's giving an error. The loop does not nothing great, just for learning purpose i created two loops. delimiter $$ create procedure getSum(in input int , out output int) begin set output = 0; while input >= 1 do declare tmp int default 1; while tmp <= 5 do set output = output + input ; set tmp = tmp + 1; end while ; set input = input - 1 ; end while; end $$ delimiter ; Below is the error #1064 - You have an error in your SQL

Passing a variable from within a while loop to a jquery

我的未来我决定 提交于 2019-12-11 07:17:43
问题 I have a web page that lists a number of companies from a MYSQL database, the listing just shows the name of the company. When user clicks on the company name a jquery accordion slider shows the rest of the information about that company. When company name is clicked it also sends a request to a php script to log that a person has viewed that company's details. My Problem I want to send the ID for each record to the php script. I have achieved this by including the accordion jquery code

Java logic error in returning array position using while/if statements

喜你入骨 提交于 2019-12-11 06:53:14
问题 I'm new to Java and would appreciate some help in understanding why I'm getting a logic error. The program searches for "item" in the array "database". The point of the code is to illustrate the use of While and If statements. The output reads "Item found at position: 1" when it should read "Item found at position: 3" The code: class Item { static int [] database = {17,18,19,20,21}; public static int findItem(int item) { int i = 0; while ( i < database.length && database[i] != item ) { ++i;

Create pagination using while loop

只谈情不闲聊 提交于 2019-12-11 06:44:58
问题 i want to create pagination using while loop. I already show data limit to 10. But i have no idea how to show pagination number in time calculation below. Any solutions? Thank you. <table border=0 width=800 cellspacing=1 cellpadding=2> <tr height=22> <td align=center bgColor=red width=5%>No.</td> <td align=center bgColor=red width=15%>Date</td> <td align=center bgColor=red width=20%>Time</td> <td align=center bgColor=red width=15%>Status</td> </tr> <?php $start_hour = "05"; $start_min = "00";

while loop loops infinitely when wrong input is entered [duplicate]

我的梦境 提交于 2019-12-11 06:39:45
问题 This question already has answers here : Filtering out invalid user inputs (5 answers) Closed 6 years ago . Why does the following loop infinitely when a wrong input is entered? How do I correct this? int operation; while (true) { cout << "What operation would you like to perform? Enter the number corresponding to the operation you would like to perform. "; cin >> operation; if (operation >= 1 && operation <= 5) break; cout << "Please enter a number from 1 to 5, inclusive.\n"; } 回答1: After an