Search Results

Search found 8776 results on 352 pages for 'boolean logic'.

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

  • How to check a bool setting in my iphone app

    - by dusk
    I have a setting in Root.plist with Key = 'latestNews' of type PSToggleSwitchSpecifier and DefaultValue as a boolean that is checked. If I understand that correctly, it should = YES when I pull it in to my code. I'm trying to check that value and set an int var to pass it to my php script. What is happening is that my boolean is either nil or NO and then my int var = 0. What am I doing wrong? int latestFlag; NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; BOOL latestNews = [prefs boolForKey:@"latestNews"]; if (latestNews) latestFlag = 1; else latestFlag = 0; NSString *urlstr = [[NSString alloc] initWithFormat:@"http://www.mysite.com/folder/iphone-test.php?latest=%d", latestFlag]; NSURL *url = [[NSURL alloc] initWithString:urlstr]; //these are auto-released NSString *ans = [NSString stringWithContentsOfURL:url]; NSArray *listItems = [ans componentsSeparatedByString:@","]; self.listData = listItems; [urlstr release]; [url release];

    Read the article

  • How to use Boolean variable in c:if

    - by Patriks
    I am using this code in jsf <c:if test="#{sV.done.booleanValue()}"> <option value="#{sV.id}" selected="selected">#{sV.text}</option> </c:if> <c:if test="#{not sV.done.booleanValue()}"> <option value="#{sV.id}">#{sV.text}</option> </c:if> sv is my class containing data (pojo), done is an Boolean variable, I want to display option tag with selected attribute if sV.done is true. But I couldn't make it. Don't know where I am wrong. Otherwise there can be something worong with c? because c:forEach was not working before some time in my case in same page. it can be the reason? Where I am wrong?

    Read the article

  • Three boolean values saved in one tinyint

    - by Casper
    Hello, probably a simple question but I seem to be suffering from programmer's block. :) I have three boolean values: A, B, and C. I would like to save the state combination as an unsigned tinyint (max 255) into a database and be able to derive the states from the saved integer. Even though there are only a limited number of combinations, I would like to avoid hard-coding each state combination to a specific value (something like if A=true and B=true has the value 1). I tried to assign values to the variables so (A=1, B=2, C=3) and then adding, but I can't differentiate between A and B being true from i.e. only C being true. I am stumped but pretty sure that it is possible. Thanks

    Read the article

  • Using preg_match as boolean AND array

    - by silow
    I have this code where preg_match is used to break up a string into $pmarr array. Index 1 of that array is then being used to set a value $val = $pmarr[1]. $pmarr = array(); if (preg_match($expression, $orig, $pmarr)) { $val = $pmarr[1]; } What I'm wondering about is why the preg_match itself is being used as a boolean. If the expression doesn't match, does the array stay empty and therefore equate to false? Is the above code the same as saying preg_match($expression, $orig, $pmarr); if(isset($pmarr[1]) AND !empty($pmarr[1])){ $val = $pmarr[1]; }

    Read the article

  • Django snippet with logic

    - by etam
    Hi, is there a way to create a Django snippet that has logic? I think about something like contact template tag: {% contact_form %} with template: <form action="send_contact_form" method="POST">...</form> with logic: def send_contact_form(): ... I want to be able to use it anywhere in my projects. It should work only by specifying 1 template tag... Do you know what I mean? Is it possible? Thanks in advance, Etam.

    Read the article

  • iPHone: Unit/Logic Tests initWithNibName

    - by pion
    I have setup my Logic Tests following the instructions on http://developer.apple.com/iphone/library/documentation/Xcode/Conceptual/iphone_development/135-Unit_Testing_Applications/unit_testing_applications.html. I could test a couple classes successfully. But I got error when testing the following: - (id)init { if (self = [super initWithNibName:@"Foo" bundle:nil]) { ... } return self; } The error message is -[UIViewController _loadViewFromNibNamed:bundle:] was unable to load a nib named "Foo" My question: Did I do something wrong? Missed something? or I cannot test -initWithNibName using Logic Tests technique. Thanks in advance for your help.

    Read the article

  • Easiest way to retrofit retry logic on LINQ to SQL migration to SQL Azure

    - by Pat James
    I have a couple of existing ASP .NET web forms and MVC applications that currently use LINQ to SQL with a SQL Server 2008 Express database on a Windows VPS: one VPS for both IIS and SQL. I am starting to outgrow the VPS's ability to effectively host both SQL and IIS and am getting ready to split them up. I am considering migrating the database to SQL Azure and keeping IIS on the VPS. After doing initial research it sounds like implementing retry logic in the data access layer is a must-do when adopting SQL Azure. I suspect this is even more critical to implement in my situation where IIS will be on a VPS outside of the Azure infrastructure. I am looking for pointers on how to do this with the least effort and impact on my existing code base. Is there a good retry pattern that can be applied once at the LINQ to SQL data access layer, as opposed to having to wrap all of my LINQ to SQL operations in try/catch/wait/retry logic?

    Read the article

  • logic of button to be disabled or not in mvc

    - by rod
    Hi All, Here's an excerpt from a book I'm reading about application design with MVC: Ideally, the view is so simple and logic-free as to need virtually no testing. Users (and developers before users) can reasonably test the view by simply looking at the pixels on the screen. Anything else beyond pure graphical rendering should ideally be taken out of the view and placed in the controller and model. This includes, for example, the logic that determines whether a certain button should be enabled or grayed out at some point. what does the bold statement mean to you? what would this look like? thanks, rod.

    Read the article

  • Logic for controll concurrent in block or funciton

    - by Hlex
    1)My environment is web application, I accept large request from selvets. A) In some block/method i want to control concurrent to not greater than 5 B) if there are 5 request in that block , the new coming must wait up to 60 second then throws error C) if there are sleep/waiting request most then 30,throws error How I do this? 2)(Optional Question) from above I have to distribute control logic to all clustered host. I plan to use hazelcast to share the control logic (e.g. current counter) I see they provide BlockingQueue & ExectorService but I have no idea how to use in my case. Please recommend if you have idea.

    Read the article

  • Pros and Cons on where to place business logic: app level or DB

    - by Juri
    Hi, I always again encounter discussions about where to place the business logic: inside a business layer in the application code or down in the DB in terms of stored procedures. Personally I'd tend to the 1st approach, but I'd like to hear some opinions from your part first, without influencing you with my personal views. I know there doesn't exist a one-size-fits-all solution and it often depends on many factors, but we can discuss about that. Btw, we are in the context of web applications and our current approach is to have UI layer which accepts UI input and does a first, client-side validation Business layer with a number of service-classes which contains the business logic including validation for user input (server-side) Data Access Layer which calls stored procedures from the DB for doing persistency/read operations Many people however tend to move the business layer stuff (especially regarding the validation) down to the DB in terms of stored procedures. What do you think about it? I'd like to discuss.

    Read the article

  • Logic for controll concurrent in block/method

    - by Hlex
    1)My environment is web application, I develop servlet to receive request. A) In some block/method i want to control concurrent to not greater than 5 B) if there are 5 request in that block , the new coming must wait up to 60 second then throws error C) if there are sleep/waiting request more then 30, the 31th request will be throwed an error How I do this? 2)(Optional Question) from above I have to distribute control logic to all clustered host. I plan to use hazelcast to share the control logic (e.g. current counter) I see they provide BlockingQueue & ExectorService but I have no idea how to use in my case. Please recommend if you have idea.

    Read the article

  • Put logic behind generated LinqToSql fields

    - by boris callens
    In a database I use throughout several projects, there is a field that should actually be a boolean but is for reasons nobody can explain to me a field duplicated over two tables where one time it is a char ('Y'/'N') and one time an int (1/0). When I generate a datacontext with LinqToSql the fields off course gets these datatypes. It would be nice if I don't have to drag this stupid choice of datatype throughout the rest of my application. Is there a way to give the generated classes a little bit of logic that just return me return this.equals('Y'); and return this==1; Preferably without having to make an EXTRA field in my partial class. It would be a solution to give the generated field a totally different name that can only be accessed through the partial class and then generate the extra field with the original name with my custom logic in the partial class. I don't know how to alter the accesibility level in my generated class though.. Any suggestions?

    Read the article

  • How can I separate Logic/UI in Android

    - by Ungureanu Liviu
    Hi, I want as my application to be structured in 2 parts: the logic code and the UI. I've tried to implement that using a controller class(here I keep the logic code) inside of each activity. The activity send messages to controller and receive the answer in two ways: the answer is returned immediately (if the action is not complex and it can be done in a verry short time) the activity set some listeners and the controller fire this listener when the action is complete. The problems appears when the controller have a lot of objects(each object should handle a set of actions and for each action I have to set & trigger a listener): it is hard to keep the code syncronized. I'm asking if you know a better way to implement this mechanism. Thank you.

    Read the article

  • <html:select> inside <logic:iterate>

    - by TPT Gin
    I have an itemList and for each item, a dropdown list of ratings is displayed. After user rates each item in itemList, i want to store those rates in an array. How can I do it? selectedRate below is of Integer type, and the code failed to solve the problem. <logic:iterate id="item" name="itemList"> <tr> <td> <html:select name="aForm" property="selectedRate"> <html:optionsCollection name="allRates" label="description" value="value" /> </html:select> </td> </tr> </logic:iterate>

    Read the article

  • where to put business logic in a library?

    - by fayer
    i'm going to create a library that consists of a lot of separate classes. i'm very familiar with mvc but have never created a pure library before. i wonder where i should put the business logic? the logic that is in the controller in a mvc. should it be in a class? or in a "bootstrap" file? and should one file include every class, or should only one class include its classes it uses? thanks!

    Read the article

  • Putting logic in ViewModel get'ers

    - by Yngvebn
    What do you think about putting Get-logic in the getters of a ViewModel? Something like: public class DummyViewModel { public int Id { get; set; } private DummyObject myObject; public DummyObject MyObject { get { if (MyObject == null) { DummyRepository repo = new DummyRepository(); myObject = repo.Get(Id); } return myObject; } } } Is this bad practice, or totally fine? I find my controllers getting really bloated by doing all the get-logic there, but I'm really torn as to where I should put it... My reason for doing it this way, is that I can pass the ViewModel to different types of view, and only the neccessary DB-lookup will be performed based on what property is requested.

    Read the article

  • Why can't I set boolean columns with update?

    - by Benjamin Oakes
    I'm making a user administration page. For the system I'm creating, users need to be approved. Sometimes, there will be many users to approve, so I'd like to make that easy. I'm storing this as a boolean column called approved. I remembered the Edit Multiple Individually Railscast and thought it would be a great fit. However, I'm running into problems which I traced back to ActiveRecord::Base#update. update works fine in this example: >> User.all.map(&:username) => ["ben", "fred"] >> h = {"1"=>{'username'=>'benjamin'}, "2"=>{"username"=>'frederick'}} => {"1"=>{"username"=>"benjamin"}, "2"=>{"username"=>"frederick"}} >> User.update(h.keys, h.values) => ... >> User.all.map(&:username) => ["benjamin", "frederick"] But not this one: >> User.all.map(&:approved) => [true, nil] >> h = {"1"=>{'approved'=>'1'}, "2"=>{'approved'=>'1'}} >> User.update(h.keys, h.values) => ... >> User.all.map(&:approved) => [true, nil] Chaging from '1' to true didn't make a difference when I tested. What am I doing wrong?

    Read the article

  • C++ : Avoid lot of boolean variable for multiple verification conditions in trading app

    - by Naveen
    Hi i am a junior dev in trading app... we have a order refresh verification unit. It has to verify order confirmation from exchange. We send a bunch of different request in bulk ( NEW, MODIFY, CANCEL ) to exchange... Verification has to happen for max N times with each T intervals for all orders. if verification successful for all the order before N retry then fine.. otherwise we need to indicate as verification unsuccessfull. i hv done a basic coding done in very urgent like below for( N times ) { for_each ( sent_request_order ) // SENT { 1) get all the refreshed order from DB or shared mem i.e REFRESHED 2) find current sent order in REFRESHED if( not_found ) not refreshed from exchange, continue to next order if( found ) case NEW : //check for new status, mark verification done case MODIFY : //check for modified status.. //if not mark pending, go to next order, //revisit the same after T time case CANCEL : //check for cancelled status.. //if not mark pending, go to next order, //revisit the same after T time } if( all_verified ) exit from verification. wait ( T sec ) } order_verification_pending, order_verification_done, order_visited, order_not_visited, all_verified, all_not_verified ... lot of boolean flags used for indication.. is there any better approach for doing this.... splitting responsibilities across the classes......???? i know this is not a general question.... but still flags are making me tidious to handle...

    Read the article

  • Elegantly determine if more than one boolean is "true"

    - by Ola Tuvesson
    I have a set of five boolean values. If more than one of these are true I want to excecute a particular function. What is the most elegant way you can think of that would allow me to check this condition in a single if() statement? Target language is C# but I'm interested in solutions in other languages as well (as long as we're not talking about specific built-in functions). One interesting option is to store the booleans in a byte, do a right shift and compare with the original byte. Something like if(myByte && (myByte 1)) But this would require converting the separate booleans to a byte (via a bitArray?) and that seems a bit (pun intended) clumsy... [edit]Sorry, that should have been if(myByte & (myByte - 1)) [/edit] Note: This is of course very close to the classical "population count", "sideways addition" or "Hamming weight" programming problem - but not quite the same. I don't need to know how many of the bits are set, only if it is more than one. My hope is that there is a much simpler way to accomplish this.

    Read the article

  • C++ Boolean problem (comparison between two arrays)

    - by Martin
    Hello! I have a problem to do. I already did some part of it, however I stuck and don't know exactly what to do next. The question: " You are given two arrays of ints, named A and B. One contains AMAXELEMENTS and the other contains BMAXELEMENTS. Write a Boolean-valued function that returns true if there is at least one point in A that is the same as a point in B, and false if there is no match between two arrays. " The two arrays are made up by me, I think if I know how to compare two arrays I will be fine, and I will be able to finish my problem. This is what I have so far (I changed AMAXELEMENTS to AMAX, and BMAXELEMENTS to BMAX): #include <iostream> using namespace std; int main(){ const int AMAX=5, BMAX=6; int i; bool c1=true,c2=false; int A[AMAX]={2,4,1,5,9}; int B[BMAX]={9,12,32,43,23,11}; for(i=0;i<BMAX;i++) if (B[i]==A[i]) // <---- I think this part has to look different, but I can't figure it out. cout<<c1<<endl; else cout<< c2<<endl; return 0; }

    Read the article

  • Is it safe to use a boolean flag to stop a thread from running in C#

    - by Lirik
    My main concern is with the boolean flag... is it safe to use it without any synchronization? I've read in several places that it's atomic. class MyTask { private ManualResetEvent startSignal; private CountDownLatch latch; private bool running; MyTask(CountDownLatch latch) { running = false; this.latch = latch; startSignal = new ManualResetEvent(false); } // A method which runs in a thread public void Run() { startSignal.WaitOne(); while(running) { startSignal.WaitOne(); //... some code } latch.Signal(); } public void Stop() { running = false; startSignal.Set(); } public void Start() { running = true; startSignal.Set(); } public void Pause() { startSignal.Reset(); } public void Resume() { startSignal.Set(); } } Is this a safe way to design a task? Any suggestions, improvements, comments? Note: I wrote my custom CountDownLatch class in case you're wondering where I'm getting it from.

    Read the article

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