Search Results

Search found 2221 results on 89 pages for 'equal'.

Page 12/89 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • friendship and operator overloading help

    - by sil3nt
    hello there, I have the following class #ifndef Container_H #define Container_H #include <iostream> using namespace std; class Container{ friend bool operator==(const Container &rhs,const Container &lhs); public: void display(ostream & out) const; private: int sizeC; // size of Container int capacityC; // capacity of dynamic array int * elements; // pntr to dynamic array }; ostream & operator<< (ostream & out, const Container & aCont); #endif and this source file #include "container.h" /*----------------------------********************************************* note: to test whether capacityC and sizeC are equal, must i add 1 to sizeC? seeing as sizeC starts off with 0?? */ Container::Container(int maxCapacity){ capacityC = maxCapacity; elements = new int [capacityC]; sizeC = 0; } Container::~Container(){ delete [] elements; } Container::Container(const Container & origCont){ //copy constructor? int i = 0; for (i = 0; i<capacityC; i++){ //capacity to be used here? (*this).elements[i] = origCont.elements[i]; } } bool Container::empty() const{ if (sizeC == 0){ return true; }else{ return false; } } void Container::insert(int item, int index){ if ( sizeC == capacityC ){ cout << "\n*** Next: Bye!\n"; return; // ? have return here? } if ( (index >= 0) && (index <= capacityC) ){ elements[index] = item; sizeC++; } if ( (index < 0) && (index > capacityC) ){ cout<<"*** Illegal location to insert--"<< index << ". Container unchanged. ***\n"; }//error here not valid? according to original a3? have i implemented wrong? } void Container::erase(int index){ if ( (index >= 0) && (index <= capacityC) ){ //correct here? legal location? int i = 0; while (i<capacityC){ //correct? elements[index] = elements[index+1]; //check if index increases here. i++; } sizeC=sizeC-1; //correct? updated sizeC? }else{ cout<<"*** Illegal location to be removed--"<< index << ". Container unchanged. ***\n"; } } int Container::size()const{ return sizeC; //correct? } /* bool Container::operator==(const Container &rhs,const Container &lhs){ int equal = 0, i = 0; for (i = 0; i < capacityC ; i++){ if ( rhs.elements[i] == lhs.elements[i] ){ equal++; } } if (equal == sizeC){ return true; }else{ return false; } } ostream & operator<< (ostream & out, const Container & aCont){ int i = 0; for (i = 0; i<sizeC; i++){ out<< aCont.elements[i] << " " << endl; } } */ I dont have the other functions in the header file (just a quikie). Anyways, the last two functions in "/* */" I cant get to work, what am I doing wrong here? the first function is to see whether the two arrays are equal to one another

    Read the article

  • Newbie: How to set attribute of the relative layout in my case??

    - by Leem
    I would like to divide my screen into 4 equal areas like ?.Each one of the four area is a linear layout. I tried to use relative layout to hold four linear layout like below: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:id="@+id/up_left_area" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#ffff66" > <TextView android:id="@+id/label1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="UP LEFT"/> </LinearLayout> <LinearLayout android:id="@+id/up_right_area" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_toRightOf="@id/up_left_area" android:background="#ccffff"> <TextView android:id="@+id/label2" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="UP RIGHT"/> </LinearLayout> <LinearLayout android:id="@+id/down_left_area" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_below="@id/up_left_area" android:background="#66cc33" > <TextView android:id="@+id/label3" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="DOWN LEFT"/> </LinearLayout> <LinearLayout android:id="@+id/down_right_area" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_below="@id/up_right_area" android:layout_toRightOf="@id/down_left_area" android:background="#cc6600"> <TextView android:id="@+id/label4" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="DOWN RIGHT"/> </LinearLayout> </RelativeLayout> With the above xml layout code, I do get 4 areas on the screen, but they are not equal sized. How to modify my code to have equal sized 4 areas on the screen like ? ?

    Read the article

  • Dojo Datagrid Filtering Issue

    - by Zoom Pat
    I am having hard time filtering a datagrid. Please help! This is how I draw a grid. var jsonStore = new dojo.data.ItemFileWriteStore({data:columnValues}); gridInfo = { store: jsonStore, queryOptions: {ignoreCase: true}, structure: layout }; grid = new dojox.grid.DataGrid(gridInfo, "gridNode"); grid.startup(); Now if i try something like this, it works fine and gives me the rows which has the column (AGE_FROM) value equal to 63. grid.filter({AGE_FROM:63}); but I need all kinds of filtering and not just 'equal to' So how do I try to obtain all the rows which have AGE_FROM 63, and < 63 and <= 63 and =63. because grid.filter({AGE_FROM:<63}); does not work Also One other way I was thingking was to use the following filteredStore = new dojox.jsonPath.query(filterData,"[?(@.AGE_FROM = 63]"); and then draw the grid with the filteredStore, but the above is not working for a != operator. Once I figure a good way to filter grid I need to see a way to filter out dates. I am trying to find a good example for filtering dataGrid but most of the examples are just filtering based on the 'equal to' criteria. Any help is highly appreciated.

    Read the article

  • Xpath that evaluates -all- attributes?

    - by Tres
    I maybe be trying to do something invalid here, but maybe someone smarter than me knows the correct syntax to solve my problem. Given: <group code="vehicle"> <line code="car"> <cell> <box code="price">1000.00</box> </cell> </line> <line code="car"> <cell code="sports"> <box code="price">500.00</box> </cell> </line> </group> If I use //*[@code="vehicle"]//*[@code="car"]//*[@code="price"], I will get both boxes returned (1000.00 and 500.00)--as expected but not what I want. Is there an xpath syntax that will evaluate against all nodes that have an attribute of @code rather than skipping it if it doesn't match with the end result being that I only get back the first box (price of 1000.00)? Like asking, choose the first node with @code and that @code must equal "vehicle", then choose the next node with @code and that @code must equal "car", then choose the next node with @code and @code must equal "price".

    Read the article

  • c# Most efficient way to combine two objects

    - by Dested
    I have two objects that can be represented as an int, float, bool, or string. I need to perform an addition on these two objects with the results being the same thing c# would produce as a result. For instance 1+"Foo" would equal the string "1Foo", 2+2.5 would equal the float 5.5, and 3+3 would equal the int 6 . Currently I am using the code below but it seems like incredible overkill. Can anyone simplify or point me to some way to do this efficiently? private object Combine(object o, object o1) { float left = 0; float right = 0; bool isInt = false; string l = null; string r = null; if (o is int) { left = (int)o; isInt = true; } else if (o is float) { left = (float)o; } else if (o is bool) { l = o.ToString(); } else { l = (string)o; } if (o1 is int) { right = (int)o1; } else if (o is float) { right = (float)o1; isInt = false; } else if (o1 is bool) { r = o1.ToString(); isInt = false; } else { r = (string)o1; isInt = false; } object rr; if (l == null) { if (r == null) { rr = left + right; } else { rr = left + r; } } else { if (r == null) { rr = l + right; } else { rr = l + r; } } if (isInt) { return Convert.ToInt32(rr); } return rr; }

    Read the article

  • Most efficient way to combine two objects in C#

    - by Dested
    I have two objects that can be represented as an int, float, bool, or string. I need to perform an addition on these two objects with the results being the same thing c# would produce as a result. For instance 1+"Foo" would equal the string "1Foo", 2+2.5 would equal the float 5.5, and 3+3 would equal the int 6 . Currently I am using the code below but it seems like incredible overkill. Can anyone simplify or point me to some way to do this efficiently? private object Combine(object o, object o1) { float left = 0; float right = 0; bool isInt = false; string l = null; string r = null; if (o is int) { left = (int)o; isInt = true; } else if (o is float) { left = (float)o; } else if (o is bool) { l = o.ToString(); } else { l = (string)o; } if (o1 is int) { right = (int)o1; } else if (o is float) { right = (float)o1; isInt = false; } else if (o1 is bool) { r = o1.ToString(); isInt = false; } else { r = (string)o1; isInt = false; } object rr; if (l == null) { if (r == null) { rr = left + right; } else { rr = left + r; } } else { if (r == null) { rr = l + right; } else { rr = l + r; } } if (isInt) { return Convert.ToInt32(rr); } return rr; }

    Read the article

  • How to pass multiple different records (not class due to delphi limitations) to a function?

    - by mingo
    Hi to all. I have a number of records I cannot convert to classes due to Delphi limitation (all of them uses class operators to implement comparisons). But I have to pass to store them in a class not knowing which record type I'm using. Something like this: type R1 = record begin x :Mytype; class operator Equal(a,b:R1) end; type R2 = record begin y :Mytype; class operator Equal(a,b:R2) end; type Rn = record begin z :Mytype; class operator Equal(a,b:Rn) end; type TC = class begin x : TObject; y : Mytype; function payload (n:TObject) end; function TC.payload(n:TObject) begin x := n; end; program: c : TC; x : R1; y : R2; ... c := TC.Create(): n:=TOBject(x); c.payload(n); Now, Delphi do not accept typecast from record to TObject, and I cannot make them classes due to Delphi limitation. Anyone knows a way to pass different records to a function and recognize their type when needed, as we do with class: if x is TMyClass then TMyClass(x) ... ???

    Read the article

  • Using javascript and php together

    - by EmmyS
    I have a PHP form that needs some very simple validation on submit. I'd rather do the validation client-side, as there's quite a bit of server-side validation that happens to deal with writing form values to a database. So I just want to call a javascript function onsubmit to compare values in two password fields. This is what I've got: function validate(form){ var password = form.password.value; var password2 = form.password2.value; alert("password:"+password+" password2:" + password2); if (password != password2) { alert("not equal"); document.getElementByID("passwordError").style.display="inline"; return false; } alert("equal"); return true; } The idea being that a default-hidden div containing an error message would be displayed if the two passwords don't match. The alerts are just to display the values of password and password2, and then again to indicate whether they match or not (will not be used in production code). I'm using an input type=submit button, and calling the function in the form tag: <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" onsubmit="return validate(this);"> Everything is alerting as expected when entering non-matching values. I would have hoped (and assumed, based on past use) that if the function returned false, the actual submit would not occur. And yet, it is. I'm testing by entering non-matching values in the password fields, and the alerts clearly show me the values and the not equal result, but the actual form action is still occurring and it's trying to write to my database. I'm pretty new at PHP; is there something about it that will not let me combine with javascript this way? Would it be better to use an input type=button and include submit() in the function itself if it returns true?

    Read the article

  • ArrayList.Sort should be a stable sort with an IComparer but is not?

    - by Kaleb Pederson
    A stable sort is a sort that maintains the relative ordering of elements with the same value. The docs on ArrayList.Sort say that when an IComparer is provided the sort is stable: If comparer is set to null, this method performs a comparison sort (also called an unstable sort); that is, if two elements are equal, their order might not be preserved. In contrast, a stable sort preserves the order of elements that are equal. To perform a stable sort, you must implement a custom IComparer interface. Unless I'm missing something, the following testcase shows that ArrayList.Sort is not using a stable sort: internal class DisplayOrdered { public int ID { get; set; } public int DisplayOrder { get; set; } public override string ToString() { return string.Format("ID: {0}, DisplayOrder: {1}", ID, DisplayOrder); } } internal class DisplayOrderedComparer : IComparer { public int Compare(object x, object y) { return ((DisplayOrdered)x).DisplayOrder - ((DisplayOrdered)y).DisplayOrder; } } [TestFixture] public class ArrayListStableSortTest { [Test] public void TestWeblinkCallArrayListIsSortedUsingStableSort() { var call1 = new DisplayOrdered {ID = 1, DisplayOrder = 0}; var call2 = new DisplayOrdered {ID = 2, DisplayOrder = 0}; var call3 = new DisplayOrdered {ID = 3, DisplayOrder = 2}; var list = new ArrayList {call1, call2, call3}; list.Sort(new DisplayOrderedComparer()); // expected order (by ID): 1, 2, 3 (because the DisplayOrder // is equal for ID's 1 and 2, their ordering should be // maintained for a stable sort.) Assert.AreEqual(call1, list[0]); // Actual: ID=2 ** FAILS Assert.AreEqual(call2, list[1]); // Actual: ID=1 Assert.AreEqual(call3, list[2]); // Actual: ID=3 } } Am I missing something? If not, would this be a documentation bug or a library bug? Apparently using an OrderBy in Linq gives a stable sort.

    Read the article

  • mysql query help, take total sum from a table, and based on discount value on another table calcula

    - by vegatron
    hi I have a table called invoices: CREATE TABLE IF NOT EXISTS `si_invoices` ( `id` int(10) NOT NULL AUTO_INCREMENT, `biller_id` int(10) NOT NULL DEFAULT '0', `customer_id` int(10) NOT NULL DEFAULT '0', `type_id` int(10) NOT NULL DEFAULT '0', `inv_tax_id` int(10) NOT NULL, `date` date NOT NULL DEFAULT '0000-00-00', `unreg_customer` tinyint(1) NOT NULL DEFAULT '0', `discount` decimal(10,2) NOT NULL DEFAULT '0.00', `discount_type` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=20 ; each invoice has items that are stored in invoice_items table : CREATE TABLE IF NOT EXISTS `si_invoice_items` ( `id` int(10) NOT NULL AUTO_INCREMENT, `invoice_id` int(10) NOT NULL DEFAULT '0', `quantity` int(10) unsigned NOT NULL DEFAULT '0', `product_id` int(10) DEFAULT '0', `warehouse_id` int(10) NOT NULL, `unit_price` decimal(25,2) DEFAULT '0.00', `total` decimal(25,2) DEFAULT '0.00', `description` text, PRIMARY KEY (`id`), KEY `invoice_id` (`invoice_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=56 ; and tax table CREATE TABLE IF NOT EXISTS `si_tax` ( `tax_id` int(11) NOT NULL AUTO_INCREMENT, `tax_description` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `tax_percentage` decimal(25,6) DEFAULT '0.000000', `type` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, `tax_enabled` varchar(1) COLLATE utf8_unicode_ci NOT NULL DEFAULT '1', PRIMARY KEY (`tax_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=5 ; here is what I want to do step 1: get the sum_total of the invoice Items for a speciefic invoice step 2: calculate the discount, in the invoice table I have a discount_type field : if its equal to 0 , then there will be no discount if its equal to 1 , the discount value will be stored in the discount field if its equal to 2 , the discount is a percentage of sum_total step 3: calculate the taxes based on inv_tax_id based on the tax id , I will look in the tax table , get the tax_percentage and multiply it by the (sum_total - discount) in short here is the equation $gross_total = $sum_total - $disount + taxes

    Read the article

  • MySQL SELECT combining 3 SELECTs INTO 1

    - by Martin Tóth
    Consider following tables in MySQL database: entries: creator_id INT entry TEXT is_expired BOOL other: creator_id INT entry TEXT userdata: creator_id INT name VARCHAR etc... In entries and other, there can be multiple entries by 1 creator. userdata table is read only for me (placed in other database). I'd like to achieve a following SELECT result: +------------+---------+---------+-------+ | creator_id | entries | expired | other | +------------+---------+---------+-------+ | 10951 | 59 | 55 | 39 | | 70887 | 41 | 34 | 108 | | 88309 | 38 | 20 | 102 | | 94732 | 0 | 0 | 86 | ... where entries is equal to SELECT COUNT(entry) FROM entries GROUP BY creator_id, expired is equal to SELECT COUNT(entry) FROM entries WHERE is_expired = 0 GROUP BY creator_id and other is equal to SELECT COUNT(entry) FROM other GROUP BY creator_id. I need this structure because after doing this SELECT, I need to look for user data in the "userdata" table, which I planned to do with INNER JOIN and select desired columns. I solved this problem with selecting "NULL" into column which does not apply for given SELECT: SELECT creator_id, COUNT(any_entry) as entries, COUNT(expired_entry) as expired, COUNT(other_entry) as other FROM ( SELECT creator_id, entry AS any_entry, NULL AS expired_entry, NULL AS other_enry FROM entries UNION SELECT creator_id, NULL AS any_entry, entry AS expired_entry, NULL AS other_enry FROM entries WHERE is_expired = 1 UNION SELECT creator_id, NULL AS any_entry, NULL AS expired_entry, entry AS other_enry FROM other ) AS tTemp GROUP BY creator_id ORDER BY entries DESC, expired DESC, other DESC ; I've left out the INNER JOIN and selecting other columns from userdata table on purpose (my question being about combining 3 SELECTs into 1). Is my idea valid? = Am I trying to use the right "construction" for this? Are these kind of SELECTs possible without creating an "empty" column? (some kind of JOIN) Should I do it "outside the DB": make 3 SELECTs, make some order in it (let's say python lists/dicts) and then do the additional SELECTs for userdata? Solution for a similar question does not return rows where entries and expired are 0. Thank you for your time.

    Read the article

  • URL equals and checking Internet access

    - by James P.
    On http://java.sun.com/j2se/1.5.0/docs/api/java/net/URL.html it states that: Compares this URL for equality with another object. If the given object is not a URL then this method immediately returns false. Two URL objects are equal if they have the same protocol, reference equivalent hosts, have the same port number on the host, and the same file and fragment of the file. Two hosts are considered equivalent if both host names can be resolved into the same IP addresses; else if either host name can't be resolved, the host names must be equal without regard to case; or both host names equal to null. Since hosts comparison requires name resolution, this operation is a blocking operation. Note: The defined behavior for equals is known to be inconsistent with virtual hosting in HTTP. According to this, equals will only work if name resolution is possible. Since I can't be sure that a computer has internet access at a given time, should I just use Strings to store addresses instead? Also, how do I go about testing if access is available when requested?

    Read the article

  • algorithm - How to sort a 0/1 array with 2n/3 comparisons?

    - by Jackson Tale
    In Algorithm Design Manual, there is such an excise 4-26 Consider the problem of sorting a sequence of n 0’s and 1’s using comparisons. For each comparison of two values x and y, the algorithm learns which of x < y, x = y, or x y holds. (a) Give an algorithm to sort in n - 1 comparisons in the worst case. Show that your algorithm is optimal. (b) Give an algorithm to sort in 2n/3 comparisons in the average case (assuming each of the n inputs is 0 or 1 with equal probability). Show that your algorithm is optimal. For (a), I think it is fairly easy. I can choose a[n-1] as pivot, then do something like in quicksort partition, scan 0 to n - 2, find the middle point where left side is all 0 and right side is all 1, this take n - 1 comparisons. But for (b), I can't get a clue. It says "each of the n inputs is 0 or 1 with equal probability", so I guess I can assume the numbers of 0 and 1 equal? But how can I get a result which is related to 1/3? divide the whole array into 3 groups? Thanks

    Read the article

  • Arduino variable going blank after the first pass

    - by user541597
    I have an Arduino sketch that takes a timet and when that timet is equal to the current time it sets the new timet to timet + 2. For example: char* convert(char* x, String y) { int hour; int minute; sscanf(x, "%d:%d", &hour, &minute); char buf[6]; if (y == "6") { if (hour > 17) { hour = (hour+6)%24; snprintf(buf, 10, "%d:%d", hour, minute ); } else if (hour < 18) { //hour = hour + 6; minute = (minute + 2); snprintf(buf, 10, "%d:%d", hour, minute); } } if (y == "12") { if (hour > 11) { hour = (hour+12)%24; snprintf(buf, 10, "%d:%d", hour, minute ); } else if (hour < 12) { hour = hour + 12; snprintf(buf, 10, "%d:%d", hour, minute); } } if (y == "24") { hour = (hour+24)%24; snprintf(buf, 10, "%d:%d", hour, minute ); } return buf; } The sketch starts for example at 1:00am. timet is set to 1:02, at system time 1:02 timet is equal to the system time. My loops looks like this: if (timet == currenttime) { timet = convert(timet) } Whenever I check the value of timet it should equal 1:04, however I get the correct value at the first run after the execution of convert, however every time after that my timet value is blank. I tried changing the code instead of using the if loop. I only run the convert function when I send for example t through the serial monitor. This works fine and outputs the correct timet after the execution of the convert function, So I figured the problem is in the if loop... Any ideas?

    Read the article

  • "end()" iterator for back inserters?

    - by Thanatos
    For iterators such as those returned from std::back_inserter(), is there something that can be used as an "end" iterator? This seems a little nonsensical at first, but I have an API which is: template<typename InputIterator, typename OutputIterator> void foo( InputIterator input_begin, InputIterator input_end, OutputIterator output_begin, OutputIterator output_end ); foo performs some operation on the input sequence, generating an output sequence. (Who's length is known to foo but may or may not be equal to the input sequence's length.) The taking of the output_end parameter is the odd part: std::copy doesn't do this, for example, and assumes you're not going to pass it garbage. foo does it to provide range checking: if you pass a range too small, it throws an exception, in the name of defensive programming. (Instead of potentially overwriting random bits in memory.) Now, say I want to pass foo a back inserter, specifically one from a std::vector which has no limit outside of memory constraints. I still need a "end" iterator - in this case, something that will never compare equal. (Or, if I had a std::vector but with a restriction on length, perhaps it might sometimes compare equal?) How do I go about doing this? I do have the ability to change foo's API - is it better to not check the range, and instead provide an alternate means to get the required output range? (Which would be needed anyways for raw arrays, but not required for back inserters into a vector.) This would seem less robust, but I'm struggling to make the "robust" (above) work.

    Read the article

  • Looping through NSArray while subtracting values from each object? [on hold]

    - by Julian
    I have NSNumber objects stored in an NSMutableArray. I am attempting to perform a calculation on each object in the array. What I want to do is: 1) Take a random higher number variable and keep subtracting a smaller number variable in increments until the value of the variable is equal to the value in the array. For example: NSMutableArray object is equal to 2.50. I have an outside variable of 25 that is not in the array. I want to subtract 0.25 multiple times from the variable until I reach less than or equal to 2.50. I also need a parameter so if the number does not divide evenly and goes below the array value, it resorts to the original array value of 2.50. Lastly, for each iteration, I want to print the values as they are counting down as a string. I was going to provide code, but I don't want to make this more confusing than it has to be. So my output would be: VALUE IS: 24.75 VALUE IS: 24.50 VALUE IS: 24.25 … VALUE IS: 2.50 END

    Read the article

  • Trouble recording unique regex output to array in perl

    - by Structure
    The goal of the following code sample is to read the contents of $target and assign all unique regex search results to an array. I have confirmed my regex statement works so I am simplifying that so as not to focus on it. When I execute the script I get a list of all the regex results, however, the results are not unique which leads me to believe that my manipulation of the array or my if (grep{$_ eq $1} @array) { check is causing a problem(s). #!/usr/bin/env perl $target = "string to search"; $inc = 0; $once = 1; while ($target =~ m/(regex)/g) { #While a regex result is returned if ($once) { #If $once is not equal to zero @array[$inc] = $1; #Set the first regex result equal to @array[0] $once = 0; #Set $once equal to zero so this is not executed more than once } else { if (grep{$_ eq $1 } @array ) { #From the second regex result, check to see if the result is already in the array #If so, do nothing } else { @array[$inc] = $1; #If it is not, then assign the regex search result to the next unused position in the array in any position. $inc++; #Increment to next unused array position. } } } print @array; exit 0;

    Read the article

  • Syntax Problems of if Statement (php)

    - by MxmastaMills
    I need a little help with an if statement in php. I'm trying to set a variable called offset according to a page that I am loading in WordPress. Here's the variable: $offset = ($paged * 6); What it does is it loads the first page, which is: http://example.com/blog and $offset is thus set to 0 because $paged is referring to the appending number on the URL. The second page, for example is: http://example.com/blog/2/ which makes $offset set to 12. The problem is, I need the second page to define $offset as 6, the third page to define $offset as 12, etc. I tried using: $offset = ($paged * 6 - 6) which works except on the first page. On the first page it defines $offset as -6. SO, I wanted to create an if statement that says if $paged is equal to 0 then $offset is equal to 0, else $offset is equal to ($paged * 6 - 6). I struggle with syntax, even though I understand what needs to be done here. Any help would be greatly appreciated. Thanks!

    Read the article

  • Why is this removing all elements from my LinkedList?

    - by Brian
    Why is my remove method removing every element from my Doubly Linked List? If I take out that if/else statements then I can successfully remove middle elements, but elements at the head or tail of the list still remain. However, I added the if/else statements to take care of elements at the head and tail, unfortunately this method now removes every element in my list. What am I do wrong? public void remove(int n) { LinkEntry<E> remove_this = new LinkEntry<E>(); //if nothing comes before remove_this, set the head to equal the element after remove_this if (remove_this.previous == null) head = remove_this.next; //otherwise set the element before remove_this equal to the element after remove_this else remove_this.previous.next = remove_this.next; //if nothing comes after remove_this, set the tail equal to the element before remove_this if (remove_this.next == null) tail = remove_this.previous; //otherwise set the next element's previous pointer to the element before remove_this else remove_this.next.previous = remove_this.previous; //if remove_this is located in the middle of the list, enter this loop until it is //found, then remove it, closing the gap afterwards. int i = 0; for (remove_this = head; remove_this != null; remove_this = remove_this.next) { //if i == n, stop and delete 'remove_this' from the list if (i == n) { //set the previous element's next to the element that comes after remove_this remove_this.previous.next = remove_this.next; //set the element after remove_this' previous pointer to the element before remove_this remove_this.next.previous = remove_this.previous; break; } //if i != n, keep iterating through the list i++; } }

    Read the article

  • Apple Mail authentication failure to Apache James while Thunderbird connects

    - by dacracot
    I have an Apache James 2.3.2 email server running on RHEL 5. I have been connecting to it successfully for months using Thunderbird (currently version 12.0.1). I am attempting to connect to the same account using Apple's Mail 6.5. On the first dialog, to add an account to Apple's Mail, it asks for full name, email address, and password. It then asks for an incoming mail server. I put account type equal to POP, the incoming mail server equal to the host in my email address, and my username and password. It comes back with the error: "Logging in to the POP server "" failed. Make sure the user name and password you entered are correct, then click Continue. If the information isn't correct, you cannot receive messages." While the dialogs are different in Thunderbird, I believe that I am giving it exactly the same parameters, and succeeding with authentication.

    Read the article

  • Apple Mail authentication failure to Apache James while Thunderbird connects

    - by dacracot
    I have an Apache James 2.3.2 email server running on RHEL 5. I have been connecting to it successfully for months using Thunderbird (currently version 12.0.1). I am attempting to connect to the same account using Apple's Mail 6.5. On the first dialog, to add an account to Apple's Mail, it asks for full name, email address, and password. It then asks for an incoming mail server. I put account type equal to POP, the incoming mail server equal to the host in my email address, and my username and password. It comes back with the error: "Logging in to the POP server "" failed. Make sure the user name and password you entered are correct, then click Continue. If the information isn't correct, you cannot receive messages." While the dialogs are different in Thunderbird, I believe that I am giving it exactly the same parameters, and succeeding with authentication.

    Read the article

  • BES 5.0 and MAPI calls to exchange system

    - by nysingh
    We have been using BES 4.1(5) for a while now and it has been a resource hog on exchange due to high number of MAPI calls. I have heard that BES 5.0 is even worse. the comparison i heard is that BES 4.1 is makes MAPI calls equal to 5 outlook clients per BB user and BES 5.0 makes MAPI calls equal to 10 outlook clients per BB user. can someone confirm if it is true? is BES 5.0 is really that bad in MAPI calls and for exchange performance. ? thanks

    Read the article

  • How soon does nginx's token bucket replenish when limiting at requests per minute?

    - by Michael Gorsuch
    Hi all. We've decided that we want to experiment and limit requests per minute instead of requests per second on our sites. However, I am confused by the burst parameter in this context. I am under the impression that when you use the 'nodelay' flag, the rate limiting facility acts like a token bucket instead of a leaky bucket. That being the case, the bucket size is equal to the burst parameter, and every time that you violate the policy (say 1 req/s), you have to put a token in the bucket. Once the bucket is full (being equal to the burst setting), you are given a 503 error page. I am also under the impression that once a violator stops going against the policy, a token is removed from the bucket at a rate of 1 token/s allowing him to regain access to the site. Assuming that I have the above correct, my question is what happens when I start regulating access per minute? If we chose 60 requests per minute, at what rate does the token bucket replenish?

    Read the article

  • Dynamically reference a Named Table Column via cell content in Excel

    - by rcphq
    How do I reference an Excel Table column dynamically in Excel 2007? ie: i wanna reference a named column of a named table and what table it is will vary with the value of a cell. I have a Table in Excel (Let's call it Table1). I want to reference one of its columns (Let's call it column1) dynamically from a value in another cell (A1) so that I can achieve the following result: When I change A1, the formula that counts Table1[DynamicallyReferencedColumnName] gets updated to the new reference. I tried using =Count(Table1[INDIRECT("$A$1")]) but Excel says the formula contains an error. Example: A1 = names then the formula would equal Count(Table1[names]). A1 = lastname then the formula would equal Count(Table1[lastname]).

    Read the article

  • Criteria strings, how many different criteria can be entered to retrieve specific data?

    - by Janet
    For our membership database we are currently using an old DOS program "Arclist". The program is old but the one feature we desperately need in a database program is to be able to enter multiple criteria at one time for more of a "one time" extraction of the data meeting all the various criteria entered in what I call a "criteria string". An example may be extracting only those records with zip codes matching (67893, 54235, 54323, 54201, 54302, 54303, 54301, 67894, 67895). Another set of criteria might be to omit records, not equal to, one type of criteria in one field and also extract records matching criteria in another field. So we would want records "not equal to" in one field, but whose information equals requested information in another field.

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >