Search Results

Search found 1698 results on 68 pages for 'loops'.

Page 17/68 | < Previous Page | 13 14 15 16 17 18 19 20 21 22 23 24  | Next Page >

  • Watir question regarding table rows and loop

    - by AJ
    Hi, I would like to go through a table and look for a word, if that word appears, i would like to click on a radio button in the same row, but not the same column, then stop the loop. I have something like this at the moment but i dont know where to go on from here. @ie.div(:class, 'tableclass').table(:index, 1).each do | row | row.each do | cell | if (cell.text() == 'text') ##Set radio button break end end end I tried selecting a radio by name and index, but i do not know how to get the row number that it is currently at. Thanks.

    Read the article

  • How to make cycle over cycles in Java?

    - by Roman
    I would like to make a cycle over the following elements: [1,2,11,12,21,22,111,112,121,122,....,222222] or for example [1,2,3,11,12,13,21,22,23,31,32,33,111,112,113,... 333333333] How can I make it in Java? In my particular case I use 4 digits (1,2,3,4) and the length of the last number can be from 1 to 10. I managed to do it in Python and PHP. In the first case I used list over lists. I started from [[1],[2],] then for every element of the list I added 1 and 2, so I got [[1,1],[1,2],[2,1],[2,2]] and so on: nchips = sum(chips) traj = [[]] last = [[]] while len(last[0]) < nchips: newlast = [] for tr in last: for d in [1,2,3,4]: newlast.append(tr + [d]) last = newlast traj += last When I did it in PHP I used number with base 3. But it was a tricky and non elegant solution. for ($i=-1; $i<=$n; $i+=1) { if ($i>-1) { $n5 = base_convert($i,10,5); $n5_str = strval($n5); $tr = array(); $found = 0; for ($j=0; $j<strlen($n5_str); $j+=1) { $k = $n5_str[$j]; if ($k==0) { $found = 1; break; } array_push($tr,$k); } if ($found==1) continue; } else { $tr = array(); } } Can it be done easily in Java?

    Read the article

  • What is the right way to stop an infinite while-loop with a Term::ReadLine-readline?

    - by sid_com
    What is the right way to stop an endless while-loop with a Term::ReadLine::readline? This way I can not read in a single 0 #!/usr/bin/env perl use warnings; use strict; use 5.010; use Term::ReadLine; my $term = Term::ReadLine->new( 'Text' ); my $content; while ( 1 ) { my $con = $term->readline( 'input: ' ); last if not $con; $content .= "$con\n"; } say $content; and with last if not defined $con; the loop does never end.

    Read the article

  • For...Next Loop Multiplication Table to Start on 0

    - by nikl91
    I have my For...Next loop with a multiplication table working just fine, but I want the top left box to start at 0 and move on from there. Giving me some trouble. dim mult mult = "" For row = 1 to 50 mult = mult & "" For col= 1 to 20 mult = mult & "" & row * col & "" Next mult = mult & "" Next mult = mult & "" response.write mult This is what I have so far. Any suggestions?

    Read the article

  • For...Next Loop Multiplication Table to Start on 0

    - by nikl91
    I have my For...Next loop with a multiplication table working just fine, but I want the top left box to start at 0 and move on from there. Giving me some trouble. dim mult mult = "<table width = ""100%"" border= ""1"" >" For row = 1 to 50 mult = mult & "<tr align = ""center"" >" For col= 1 to 20 mult = mult & "<td>" & row * col & "</td>" Next mult = mult & "</tr>" Next mult = mult & "</table>" response.write mult This is what I have so far. Any suggestions?

    Read the article

  • What are the benefits of `while(condition) { //work }` and `do { //work } while(condition)`?

    - by Shaharyar
    I found myself confronted with an interview question where the goal was to write a sorting algorithm that sorts an array of unsorted int values: int[] unsortedArray = { 9, 6, 3, 1, 5, 8, 4, 2, 7, 0 }; Now I googled and found out that there are so many sorting algorithms out there! Finally I could motivate myself to dig into Bubble Sort because it seemed pretty simple to start with. I read the sample code and came to a solution looking like this: static int[] BubbleSort(ref int[] array) { long lastItemLocation = array.Length - 1; int temp; bool swapped; do { swapped = false; for (int itemLocationCounter = 0; itemLocationCounter < lastItemLocation; itemLocationCounter++) { if (array[itemLocationCounter] > array[itemLocationCounter + 1]) { temp = array[itemLocationCounter]; array[itemLocationCounter] = array[itemLocationCounter + 1]; array[itemLocationCounter + 1] = temp; swapped = true; } } } while (swapped); return array; } I clearly see that this is a situation where the do { //work } while(cond) statement is a great help to be and prevents the use of another helper variable. But is this the only case that this is more useful or do you know any other application where this condition has been used?

    Read the article

  • Two collections and a for loop. (Urgent help needed) Checking an object variable against an inputted

    - by Elliott
    Hi there, I'm relatively new to java, I'm certain the error is trivial. But can't for the life of me spot it. I have an end of term exam on monday and currently trying to get to grips with past papers! Anyway heregoes, in another method (ALGO_1) I search over elements of and check the value H_NAME equals a value entered in the main. When I attempt to run the code I get a null pointer exception, also upon trying to print (with System.out.println etc) the H_NAME value after each for loop in the snippet I also get a null statement returned to me. I am fairly certain that the collection is simply not storing the data gathered up by the Scanner. But then again when I check the collection size with size() it is about the right size. Either way I'm pretty lost and would appreciate the help. Main questions I guess to ask are: from the readBackground method is the data.add in the wrong place? is the snippet simply structured wrongly? oh and another point when I use System.out.println to check the Background object values name, starttime, increment etc they print out fine. Thanks in advance.(PS im guessing the formatting is terrible, apologies.) snippet of code: for(Hydro hd: hydros){ System.out.println(hd.H_NAME); for(Background back : backgs){ System.out.println(back.H_NAME); if(back.H_NAME.equals(hydroName)){ //get error here public static Collection<Background> readBackground(String url) throws IOException { URL u = new URL(url); InputStream is = u.openStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader b = new BufferedReader(isr); String line =""; Vector<Background> data = new Vector<Background>(); while((line = b.readLine())!= null){ Scanner s = new Scanner(line); String name = s.next(); double starttime = Double.parseDouble(s.next()); double increment = Double.parseDouble(s.next()); double sum = 0; double p = 0; double nterms = 0; while((s.hasNextDouble())){ p = Double.parseDouble(s.next()); nterms++; sum += p; } double pbmean = sum/nterms; Background SAMP = new Background(name, starttime, increment, pbmean); data.add(SAMP); } return data; } Edit/Delete Message

    Read the article

  • Whats wrong with this method?

    - by David
    Here's the method: public static String CPUcolor () { System.out.println ("What color am I?") ; String s = getIns() ; System.out.println ("are you sure I'm "+s+"? (Y/N)") ; String a = getIns() ; while (!((a.equals ("y")) || (a.equals ("Y")) || (a.equals ("n")) || (a.equals ("N")))) { System.out.println ("try again") ; a = getIns () ; } if (a.equals ("n") || a.equals("N")) {CPUcolor() ;} System.out.println ("I am "+s) ; return s ; } here is a possible output of this method (y's and n's are user inputs): What color am I? red are you sure I'm red? (Y/N) N What color am I? blue are you sure I'm blue? (Y/N) N What color am I? Yellow are you sure I'm Yellow? (Y/N) y I am Yellow I am blue I am red Why is it that the line's "I am blue" and "I am Blue" printed? Why are they printed in reverse order with red, the first entered, printed last?

    Read the article

  • Android - Looping Activity to Repeat MediaPlayer

    - by Austin Anderson
    I'm trying to create a soundboard for longer audio files and can't figure out how to stop an audio file and start it again without closing the activity. Let's say each audio file is one minute long. If I play the first audio file for 20 seconds and start the next audio file, the first stops playing and the second starts playing. However, if I click the first audio file again, the second stops playing and the first does not. I need help. This is driving me insane. bAudio1 = (ImageButton) findViewById(R.id.bAudio1); bAudio2 = (ImageButton) findViewById(R.id.bAudio2); mpAudio1 = MediaPlayer.create(this, R.raw.audio1); mpAudio2 = MediaPlayer.create(this, R.raw.audio2); bAudio1.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if(mpAudio1.isPlaying()) { mpAudio1.stop(); } else { if(mpAudio2.isPlaying()) { mpAudio2.stop(); } mpAudio1.start(); } } }); bAudio2.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if(mpAudio2.isPlaying()) { mpAudio2.stop(); } else { if(mpAudio1.isPlaying()) { mpAudio1.stop(); } mpAudio2.start(); } } }); Thanks.

    Read the article

  • Simplifying loop in Objective-C

    - by Joe Habadas
    I have this enormous loop in my code (not by choice), because I can't seem to make it work any other way. If there's some way make this simple as opposed to me repeating it +20 times that would be great, thanks. for (NSUInteger i = 0; i < 20; i++) { if (a[0] == 0xFF || b[i] == a[0]) { c[0] = b[i]; if (d[0] == 0xFF) { d[0] = c[0]; } ... below repeats +18 more times with [i+2,3,4,etc] ... if (a[1] == 0xFF || b[i + 1] == a[1]) { c[1] = b[i + 1]; if (d[1] == 0xFF) { d[1] = c[1]; } ... when it reaches the last one it calls a method ... [self doSomething]; continue; i += 19; ... then } repeats +19 times (to close things)... } } } I've tried almost every possible combo of things that I know of attempting to make this smaller and efficient. Take a look at my flow chart — pretty huh? i'm not a madman, honest.

    Read the article

  • Loop to check all 14 days in the pay period

    - by Rachel Ann Arndt
    Name: Calc_Anniversary Input: Pay_Date, Hire_Date, Termination_Date Output: "Y" if is the anniversary of the employee's Hire_Date, "N" if it is not, and "T" if he has been terminated before his anniversary. Description: Create local variables to hold the month and day of the employee's Date_of_Hire, Termination_Date, and of the processing date using the TO_CHAR function. First check to see if he was terminated before his anniversary. The anniversary could be on any day during the pay period, so there will be a loop to check all 14 days in the pay period to see if one was his anniversary. CREATE OR replace FUNCTION Calc_anniversary( incoming_anniversary_date IN VARCHAR2) RETURN BOOLEAN IS hiredate VARCHAR2(20); terminationdate VARCHAR(20); employeeid VARCHAR2(38); paydate NUMBER := 0; BEGIN SELECT Count(arndt_raw_time_sheet_data.pay_date) INTO paydate FROM arndt_raw_time_sheet_data WHERE paydate = incoming_anniversary_date; WHILE paydate <= 14 LOOP SELECT To_char(employee_id, '999'), To_char(hire_date, 'DD-MON'), To_char(termination_date, 'DD-MON') INTO employeeid, hiredate, terminationdate FROM employees, time_sheet WHERE employees.employee_id = time_sheet.employee_id AND paydate = pay_date; IF terminationdate > hiredate THEN RETURN 'T'; ELSE IF To_char(SYSDATE, 'DD-MON') = To_char(hiredate, 'DD-MON')THEN RETURN 'Y'; ELSE RETURN 'N'; END IF; END IF; paydate := paydate + 1; END LOOP; END; Tables I am using CREATE TABLE Employees ( EMPLOYEE_ID INTEGER, FIRST_NAME VARCHAR2(15), LAST_NAME VARCHAR2(25), ADDRESS_LINE_ONE VARCHAR2(35), ADDRESS_LINE_TWO VARCHAR2(35), CITY VARCHAR2(28), STATE CHAR(2), ZIP_CODE CHAR(10), COUNTY VARCHAR2(10), EMAIL VARCHAR2(16), PHONE_NUMBER VARCHAR2(12), SOCIAL_SECURITY_NUMBER VARCHAR2(11), HIRE_DATE DATE, TERMINATION_DATE DATE, DATE_OF_BIRTH DATE, SPOUSE_ID INTEGER, MARITAL_STATUS CHAR(1), ALLOWANCES INTEGER, PERSONAL_TIME_OFF FLOAT, CONSTRAINT pk_employee_id PRIMARY KEY (EMPLOYEE_ID), CONSTRAINT fk_spouse_id FOREIGN KEY (SPOUSE_ID) REFERENCES EMPLOYEES (EMPLOYEE_ID)) / CREATE TABLE Arndt_Raw_Time_Sheet_data ( EMPLOYEE_ID INTEGER, PAY_DATE DATE, HOURS_WORKED FLOAT, SALES_AMOUNT FLOAT, CONSTRAINT pk_employee_id_pay_date_time PRIMARY KEY (EMPLOYEE_ID, PAY_DATE), CONSTRAINT fk_employee_id_time FOREIGN KEY (EMPLOYEE_ID) REFERENCES EMPLOYEES (EMployee_ID)); error FUNCTION Calc_Anniversary compiled Warning: execution completed with warning

    Read the article

  • How do I make a new div with a specific Id + n?

    - by Noor
    I've got a button and when it's pushed this code launches: var nrDivs = "1" var neuDiv = document.createElement("div"); neuDiv.setAttribute("Id","theDiv" + nrDivs); neuDiv.innerHTML = "Text"; $('#allDivs').append(neuDiv); newfeed.draw(neuDiv); I know that right now the script creates a new div with the ID: theDiv1. What I'm trying to do is when I click the button a second time, it creates a div with the ID: theDiv2. Each time the user presses the button there should be a new div drawn and I'm trying to target that new div and insert dynamic text. Thanks, Noor

    Read the article

  • Displaying Nested Array Content with Time Delay in Flex

    - by MooCow
    I have a JSON array that look like this: (array here) I'm trying to use Flex to display each Project and its Milestone elements similar to a nested for-loop for 15 seconds per Milestone element before advancing to the next Project. I was shown a technique that works well for something without another array buried into it. var key:int = 0; var timer:timer = new timer (10000, project.length); timer.addEventListener (TimerEvent.TIMER, function showStuff(event:EVENT):void { trace project[key].projectName; key++; }); timer.start(); But that only replicate a single FOR-LOOP and not a nested FOR-LOOP. Any suggestions?

    Read the article

  • Trying to create an image list based on what is defined as the order, and loosing

    - by user1691463
    I have a custom created module for Joomla 2.5 and within the params of the module, and have a loop that is not outputting as expected. I have the following parameters (fields) int he module: Order Thumb image Image Title Full-size image Now there are 10 sets of these group of 4 params. What I am trying to do is loop through each of the object sets, 10 of them, and on each iteration, build an HTML image list structure. The if statement is building the HTML structure for the sets that have an order value that is greater than 0, and the else is creating the html for those sets that do not have a value greater that 0. The goal is to create two variables and then concatenate the the strings together; the leading set are the sets that have an order defined. This is not happening and every thrid loop seems like it is missing. Here is the order as it is set in the 10 sets Set 1 = 0 Set 2 = 4 Set 3 = 1 Set 4 = 0 Set 5 = 5 Set 6 = 0 Set 7 = 0 Set 8 = 6 Set 9 = 3 Set 10 = 9 However, the outcomes is: 9 5 1 4 6 7 10 Instead of the expected: 3 9 2 5 8 1 (below here are those sets that were not greater than 0 in order of appearance) 4 6 7 whats wrong here that I can not see <?php for ($i = 1; $i <= 10; $i++) { $order = $params->get('order'.$i);#get order for main loop of 10 $active = ""; if ($order > 0) {#Check if greater than 0 for ($n = 1; $n <= 10; $n++) {#loop through all order fields looking and build html lowest to highest; $ordercheck =$params->get('order'.$n); if ($ordercheck == $i) { $img = $params->get('image'.$n); $fimage = $params->get('image'.$n.'fullimage'); $title = $params->get('image'.$n.'alttext'); $active = ""; $active = $active . '<li>'; $active = $active . '<a href="'.$fimage.'" rel="prettyPhoto[gallery1]" title="'.$title.'">'; $active = $active . '<img src="'.$img.'" alt="'.$title.'" />'; $active = $active . '</a>'; $active = $active . '</li>'; $leading = $leading . $active; } } } else { #if the itteration $order was not greater than 0, build in order of accourance $img = $params->get('image'.$i); $fimage = $params->get('image'.$i.'fullimage'); $title = $params->get('image'.$i.'alttext'); $active = $active . '<li>'; $active = $active . '<a href="'.$fimage.'" rel="prettyPhoto[gallery1]" title="'.$title.'">'; $active = $active . '<img src="'.$img.'" alt="'.$title.'" />'; $active = $active . '</a></li>'; $unordered = $unordered . $active; } $imagesList = $leading . $unordered; } ?>

    Read the article

  • java shift elements in array

    - by Lightk3ira
    Hey I am trying to shift elements forward sending the last element in the array to data[0]. I did the opposite direction but I can't seem to find my mistake in going in this direction. Pos is users inputed shift times amount temp is the temporary holder. data is the array if(pos 0) { do { temp = data[data.length -1]; for(int i =0; i < data.length; i++) { if(i == data.length-1) { data[0] = temp; } else { data[i+1] = data[i]; } } pos--; }while(pos > 0); } Thanks.

    Read the article

  • Is there a better loop I could write to reduce database queries?

    - by dmanexe
    Below is some code I've written that is effective, but makes too many database queries. Is there a way I could optimize and reduce the number of queries but have conditional statements still be as effective as below? I pasted the code repeated a few times just for good measure. echo "<h3>Pool Packages</h3>"; echo "<ul>"; foreach ($items as $item): $this->db->where('id', $item['id']); $query = $this->db->get('items')->row(); if ($item['quantity'] > 1 && $item['quantity'] == TRUE && $query->category == "Pool Packages") { $newprice = $item['quantity'] * $query->price; $totals[] = $newprice; } else { $newprice = $query->price; $totals[] = $newprice; } if ($query->category == "Pool Packages") { echo "<li>" . $query->name . " (QTY: " . $item['quantity'] . " x = " . str_ireplace(" ", "", money_format('%(#10n', $newprice)) . ")</li>"; } else { } endforeach; echo "</ul>"; echo "<h3>Water Features</h3>"; echo "<ul>"; foreach ($items as $item): $this->db->where('id', $item['id']); $query = $this->db->get('items')->row(); if ($item['quantity'] > 1 && $item['quantity'] == TRUE && $query->category == "Water Features") { $newprice = $item['quantity'] * $query->price; $totals[] = $newprice; } else { $newprice = $query->price; $totals[] = $newprice; } if ($query->category == "Water Features") { echo "<li>" . $query->name . " (QTY: " . $item['quantity'] . " x = " . str_ireplace(" ", "", money_format('%(#10n', $newprice)) . ")</li>"; } else { } endforeach; echo "</ul>"; echo "<h3>Waterfall Rock Work</h3>"; echo "<ul>"; foreach ($items as $item): $this->db->where('id', $item['id']); $query = $this->db->get('items')->row(); if ($item['quantity'] > 1 && $item['quantity'] == TRUE) { $newprice = $item['quantity'] * $query->price; $totals[] = $newprice; } else { $newprice = $query->price; $totals[] = $newprice; } if ($query->category == "Waterfall Rock Work") { echo "<li>" . $query->name . " (QTY: " . $item['quantity'] . " x = " . str_ireplace(" ", "", money_format('%(#10n', $newprice)) . ")</li>"; } else { } endforeach; echo "</ul>"; echo "<h3>Sheer Descents</h3>"; echo "<ul>"; foreach ($items as $item): $this->db->where('id', $item['id']); $query = $this->db->get('items')->row(); if ($item['quantity'] > 1 && $item['quantity'] == TRUE && $query->category == "Sheer Descents") { $newprice = $item['quantity'] * $query->price; $totals[] = $newprice; } else { $newprice = $query->price; $totals[] = $newprice; } if ($query->category == "Sheer Descents") { echo "<li>" . $query->name . " (QTY: " . $item['quantity'] . " x = " . str_ireplace(" ", "", money_format('%(#10n', $newprice)) . ")</li>"; } else { } endforeach; echo "</ul>"; echo "<h3>Booster Pump</h3>"; echo "<ul>"; foreach ($items as $item): $this->db->where('id', $item['id']); $query = $this->db->get('items')->row(); if ($item['quantity'] > 1 && $item['quantity'] == TRUE && $query->category == "Booster Pump") { $newprice = $item['quantity'] * $query->price; $totals[] = $newprice; } else { $newprice = $query->price; $totals[] = $newprice; } if ($query->category == "Booster Pump") { echo "<li>" . $query->name . " (QTY: " . $item['quantity'] . " x = " . str_ireplace(" ", "", money_format('%(#10n', $newprice)) . ")</li>"; } else { } endforeach; echo "</ul>"; echo "<h3>Pool Concrete Decking</h3>"; echo "<ul>"; foreach ($items as $item): $this->db->where('id', $item['id']); $query = $this->db->get('items')->row(); if ($item['quantity'] > 1 && $item['quantity'] == TRUE && $query->category == "Pool Concrete Decking") { $newprice = $item['quantity'] * $query->price; $totals[] = $newprice; } else { $newprice = $query->price; $totals[] = $newprice; } if ($query->category == "Pool Concrete Decking") { echo "<li>" . $query->name . " (QTY: " . $item['quantity'] . " x = " . str_ireplace(" ", "", money_format('%(#10n', $newprice)) . ")</li>"; } else { } endforeach; echo "</ul>"; echo "<h3>Solar Heating</h3>"; echo "<ul>"; foreach ($items as $item): $this->db->where('id', $item['id']); $query = $this->db->get('items')->row(); if ($item['quantity'] > 1 && $item['quantity'] == TRUE && $query->category == "Solar Heating") { $newprice = $item['quantity'] * $query->price; $totals[] = $newprice; } else { $newprice = $query->price; $totals[] = $newprice; } if ($query->category == "Solar Heating") { echo "<li>" . $query->name . " (QTY: " . $item['quantity'] . " x = " . str_ireplace(" ", "", money_format('%(#10n', $newprice)) . ")</li>"; } else { } endforeach; echo "</ul>"; echo "<h3>Raised Bond Beam</h3>"; echo "<ul>"; foreach ($items as $item): $this->db->where('id', $item['id']); $query = $this->db->get('items')->row(); if ($item['quantity'] > 1 && $item['quantity'] == TRUE && $query->category == "Raised Bond Beam") { $newprice = $item['quantity'] * $query->price; $totals[] = $newprice; } else { $newprice = $query->price; $totals[] = $newprice; } if ($query->category == "Raised Bond Beam") { echo "<li>" . $query->name . " (QTY: " . $item['quantity'] . " x = " . str_ireplace(" ", "", money_format('%(#10n', $newprice)) . ")</li>"; } else { echo "<li>None</li>"; } endforeach; echo "</ul>"; It goes on beyond this to several more categories, but I don't know how to handle looping through this best. Thanks!

    Read the article

  • a nicer way to create structs in a loop

    - by sandra
    Hi guys, I haven't coded in C++ in ages. And recently, I'm trying to work on something involving structs. Like this typedef struct{ int x; int y; } Point; Then in a loop, I'm trying to create new structs and put pointers to them them in a list. Point* p; int i, j; while (condition){ // compute values for i and j with some function... p = new Point; p* = {i, j}; //initialize my struct. list.append(p); //append this pointer to my list. } Now, my question is it possible to simplify this? I mean, the pointer variable *p outside of the loop and calling p = new Point inside the loop. Isn't there a better/nicer syntax for this?

    Read the article

  • Replace Infinite loop in Flex

    - by H P
    Hello, I want to access a webservice:getMonitorData() , on creationcomplete and returns an array, in an infinite loop so that the getIndex0.text is updated each time. Flex is not able to handle an infinite loop and gives a timeout error 1502. If I run the for loop until i<2000 or so it works fine. How can replace the loop so that my webservice is accessed continiously and the result is shown in getIndex0.text. This is how my application looks like: <?xml version="1.0" encoding="utf-8"?> <s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" width="400" height="300" xmlns:plcservicebean="server.services.plcservicebean.*" creationComplete="clientMonitor1()"> <fx:Script> <![CDATA[ import mx.collections.ArrayCollection; import mx.controls.Alert; import mx.rpc.CallResponder; import mx.rpc.events.FaultEvent; import mx.rpc.events.ResultEvent; [Bindable] public var dbl0:Number; //-----------Infinite Loop, Works fine if condition = i<2000------------------------ public function clientMonitor1():void{ for(var i:int = 0; ; i++){ clientMonitor(); } } public function clientMonitor():void{ var callResp:CallResponder = new CallResponder(); callResp.addEventListener(ResultEvent.RESULT, monitorResult); callResp.addEventListener(FaultEvent.FAULT, monitorFault); callResp.token = plcServiceBean.getMonitorData(); } public function monitorResult(event:ResultEvent):void{ var arr:ArrayCollection = event.result as ArrayCollection; dbl0 = arr[0].value as Number; } protected function monitorFault(event:FaultEvent):void{ Alert.show(event.fault.faultString, "Error while monitoring Data "); } ]]> </fx:Script> <fx:Declarations> <plcservicebean:PlcServiceBean id = "plcServiceBean" showBusyCursor="true" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" /> </fx:Declarations> <mx:Form x="52" y="97" label="Double"> <mx:FormItem label = "getMonitorValue"> <s:TextInput id = "getIndex0" text = "{dbl0}"/> </mx:FormItem> </mx:Form> </s:Group>

    Read the article

  • How to print an isosceles triangle

    - by Steve
    Hello, I'm trying to learn programming by myself, I'm working from a book that has the following problem which I can't solve: Allow the user to input two values: a character to be used for printing an isosceles triangle and the size of the peak for the triangle. For example, if the user inputs # for the character and 6 for the peak, you should produce the following display: # ## ### #### ##### ###### ##### #### ### ## # This is the code I've got so far: char character; int peak; InputValues(out character, out peak); for (int row = 1; row < peak * 2; row++) { for (int col = 1; col <= row; col++) { Console.Write(character); } Console.WriteLine(); } Console.Read() // hold console open Thanks in advance.

    Read the article

  • How can we make a single dimension array to multidimensional Hierarchical ?

    - by Chetan sharma
    I have an single array of Hierarchical categories. Index of the array is the category_id like:: [8846] => Array ( [category_id] => 8846 [title] => Tsting two [description] => Tsting two [subtype] => categories [type] => object [level] => 2 [parent_category] => 8841 [tags] => new [name] => Tsting two ) each value has its parent_category value, I have around 500 elements in the array, what is the best way to make it. Process i followed: krsort categories array, so that all the child categories are at the beginning, then function makeHierarchical() { foreach($this->categories as $guid => $category) { if($category['level'] != 1) $this->multilevel_categories[$category['parent_category']][$guid] = $category; } } but this is not working, it does it only for first level. Can someone point out me the error.

    Read the article

  • i integer does not +1 the 1st time

    - by Hwang
    I have a gallery where it will load an image after a previous image is loaded, so every time 'i' will +1 so that it could move to the next image. This code works fine on my other files, but I dunno why it doesn't work for the current file. Normally if I trace 'i' the correct will be 0,1,2,3,4,5,6... etc adding on till the limit, but this files its 'i' repeat the 1st number twice, only it continues to add 0,0,1,2,3,4,5,6...etc The code is completely the same with the other file I'm using, but I don't know why it just doesn't work here. The code does not seems to have any problem. Anyway i can work around this situation? private var i:uint=0; private function loadItem():void { if (i<myXMLList.length()) { loadedPic=myXMLList[i].thumbnails; galleryLoader = new Loader(); galleryLoader.load(new URLRequest(loadedPic)); galleryLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,picLoaded); } else { adjustImage(); } } private function picLoaded(event:Event):void { var bmp=new Bitmap(event.target.content.bitmapData); bmp.smoothing=true; bmpArray.push(bmp); imagesArray[i].addChild(bmp); i++; loadItem(); }

    Read the article

  • Program is not displaying output correctly

    - by Dave Lee
    My program is suppose to display information from a text file. The text file is here http://pastebin.com/qB6nX2x4 I cant find the problem in my program. I think it has to deal with the looping but im not sure. My program runs correctly but only displays the first line of text. Any help would be appreciated. #include <iostream> #include <string> #include <cstdlib> #include <fstream> using namespace std; int buildArrays(int A[],int B[],int C[]) { int i=0,num; ifstream inFile; inFile.open("candycrush.txt"); if(inFile.fail()) { cout<<"The candycrush.txt input file did not open"<<endl; exit(-1); } while(inFile) { inFile>>num; A[i]=num; inFile>>num; B[i]=num; inFile>>num; C[i]=num; i++; } inFile.close(); return i; } void printArrays( string reportTitle, int levelsArray[], int scoresArray[], int starsArray[], int numberOfLevels ) { cout<<endl; cout<<reportTitle<<endl; cout<<"Levels\tScores\tStars"<<endl; cout<<"---------------------"<<endl; for(int i=0;i<numberOfLevels;i++) { cout<<levelsArray[i]<<"\t"<<scoresArray[i]<<"\t"; for(int j=0;j<starsArray[j];j++) { cout<<"*"; } cout<<endl; } } void sortArrays( int levelsArray[], int scoresArray[], int starsArray[], int numberOfLevels ) { for(int i=0;i<numberOfLevels;i++) { for(int j=0;j<numberOfLevels;j++) { if(levelsArray[i]<levelsArray[j]) { int temp1=levelsArray[i]; int temp2=scoresArray[i]; int temp3=starsArray[i]; levelsArray[i]=levelsArray[j]; scoresArray[i]=scoresArray[j]; starsArray[i]=starsArray[j]; levelsArray[j]=temp1; scoresArray[j]=temp2; starsArray[j]=temp3; } } } } int main() { const int MAX=400; int levelsArray[MAX]; int scoresArray[MAX]; int starsArray[MAX]; int numberOfLevels=buildArrays(levelsArray,scoresArray,starsArray); printArrays( "Candy Crush UNSORTED Report", levelsArray, scoresArray, starsArray, numberOfLevels ); sortArrays( levelsArray, scoresArray, starsArray, numberOfLevels); printArrays( "Candy Crush SORTED Report", levelsArray, scoresArray, starsArray, numberOfLevels ); system("pause"); }

    Read the article

  • In this program(Java) I'm trying to make a dice roller. How do I make it so it rolls a bunch of times and adds the rolls?

    - by Mac
    import java.util.Random; public class dice { private int times; private int roll; private int side; Random roller = new Random(); public void setTimes(int sides) { times = sides; } public void setSides(int die) { side = die; } public int getRoll() //this is where the "rolling" happens { int total = 0; int c = 0; while (c <= times) { c = c + 1; int rol = 0; roll = roller.nextInt(side) + 1; rol = rol + roll; total = rol; } return total; } } If you need the GUIWindow and the main, just ask

    Read the article

  • how to stop a javascript loop for a particular interval of time?

    - by Harish
    i am using javascript for loop, to loop through a particular array and alert it's value. I want that after every alert it should stop for 30 seconds and then continue...till the end of loop. my code goes here.. for(var i=0; i<valArray.lenght; i++) { alert("The value ="+valArray[i]); //stop for 30seconds.. } i have used setTimeout() function, but it is not working...as loop end iterating but do not pause for 30seconds interval... is there any other way such as sleep function in PHP??

    Read the article

  • Looping through array in PHP to post several multipart form-data

    - by Léon Pelletier
    I'm trying in an asp web application to code a function that would loop through a list of files in a multiple upload form and send them one by one. Is this something that can be done in ASP? Because I've read some posts about how to attach several files together, but saw nothing about looping through the files. I can easily imagine it in C# via HttpWebRequest or with socket, but in php, I guess there are already function designed to handle it? // This is false/pseudo-code :) for (int index = 0; index < number_of_files; index++) { postfile(file[index]); } And in each iteration, it should send a multipart form-data POST. postfile(TheFileInfos) should make a POST like it: POST /afs.aspx?fn=upload HTTP/1.1 [Header stuff] Content-Type: multipart/form-data; boundary=----------Ef1Ef1cH2Ij5GI3ae0gL6KM7GI3GI3 [Header stuff] ------------Ef1Ef1cH2Ij5GI3ae0gL6KM7GI3GI3 Content-Disposition: form-data; name="Filename" myimage1.png ------------Ef1Ef1cH2Ij5GI3ae0gL6KM7GI3GI3 Content-Disposition: form-data; name="fileid" 58e21ede4ead43a5201206101806420000007667212251 ------------Ef1Ef1cH2Ij5GI3ae0gL6KM7GI3GI3 Content-Disposition: form-data; name="Filedata"; filename="myimage1.png" Content-Type: application/octet-stream [Octet Stream] [Edit] I'll try it: <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <form name="form1" enctype="multipart/form-data" method="post" action="processFiles.php"> <p> <? // start of dynamic form $uploadNeed = $_POST['uploadNeed']; for($x=0;$x<$uploadNeed;$x++){ ?> <input name="uploadFile<? echo $x;?>" type="file" id="uploadFile<? echo $x;?>"> </p> <? // end of for loop } ?> <p><input name="uploadNeed" type="hidden" value="<? echo $uploadNeed;?>"> <input type="submit" name="Submit" value="Submit"> </p> </form> </body> </html>

    Read the article

< Previous Page | 13 14 15 16 17 18 19 20 21 22 23 24  | Next Page >