Search Results

Search found 2819 results on 113 pages for 'conditional expressions'.

Page 9/113 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • Gridview - Conditional Images

    This Gridview sample shows how to, for each row, based on other data within that row, to show a different image. We do this by creating a TemplateField, and putting an ASP.Net Image control within it, called 'Image1'. Then, inside the RowDataBound event of the Gridview, we put code, which first, checks and finds the Image control in that row, and then assigning a different JPG file to the ImageURL property of that image. One other thing here, you'll notice, is that when the criteria is matched, we set the Image control's Visible property to 'True'. That's because, one extra criteria is, that if the Units In Stock is larger than 80, we set the Image control's Visible property to 'False'. Naturally, since we're checking one particular column in the Gridview for this data, we're using a Select Case statement.

    Read the article

  • Conditional checks against a list

    - by AnnaSexyChick
    I was wondering how computers do this. The most logical way I can think is that they are iterating trough all elements of the list until they find one that matches the condition :) For example if you call function_exists(), PHP should iterate trough all defined functions until it meets the one that matches the name you're looking for. Is this true that this is the only way? If it is, it sounds like it's not very efficient :s

    Read the article

  • Finding the html tag value with Python [on hold]

    - by MrWho
    Consider a html page, which contains a line like below: file: 'http://google.com/video.mp4' I want to search for google.com/video.mp4 in that file and save it in a variable.I want to code it with python. Shortly, I want to elicit a link from a html page, so I need to get the link by using regular expressions or the other techniques in which I'm asking about. PS: What should I exactly try to clarify?it's really annoying that the administrators don't even say what is exactly unclear about the question, they've just learned to close or on hold the topics!

    Read the article

  • What are some examples of MemberBinding linq expressions?

    - by michielvoo
    There are three possibilities, but I can't find examples: System.Linq.Expressions.MemberAssignment System.Linq.Expressions.MemberListBinding System.Linq.Expressions.MemberMemberBinding I want to write some unit tests to see if I can handle them, but I don't know how to write them except for the first one, which seems to be new Foo { Property = "value" } where Property = "value" is an expression of type MemberAssignment. See also this MSDN article.

    Read the article

  • Freely-available, well-debugged regular expressions

    - by fsb
    I was reading ICU documentation and came across this fine advice: For common tasks like this there are libraries of freely available regular expressions that have been well debugged. It's worth making a quick search before writing a new expression. To which libraries of well-debugged regular expressions do you commonly refer? I'm not much taken with http://regexlib.com where the expressions don't seem all that well debugged. It appears to have no QA process besides user comments and ratings.

    Read the article

  • Java: how to have try-catch as conditional in for-loop?

    - by HH
    I know how to solve the problem by comparing size to an upper bound but I want a conditional that look for an exception. If an exception occur in conditinal, I want to exit. import java.io.*; import java.util.*; public class listTest{ public static void main(String[] args){ Stack<Integer> numbs=new Stack<Integer>(); numbs.push(1); numbs.push(2); for(int count=0,j=0;try{((j=numbs.pop())<999)}catch(Exception e){break;}&& !numbs.isEmpty(); ){ System.out.println(j); } // I waited for 1 to be printed, not 2. } } Some Errors javac listTest.java listTest.java:10: illegal start of expression for(int count=0,j=0;try{((j=numbs.pop())<999)}catch(Exception e){break;}&& ^ listTest.java:10: illegal start of expression for(int count=0,j=0;try{((j=numbs.pop())<999)}catch(Exception e){break;}&& ^

    Read the article

  • Practice of checking 'trueness' or 'equality' in conditional statements - does it really make sense?

    - by Senthil
    I remember many years back, when I was in school, one of my computer science teachers taught us that it was better to check for 'trueness' or 'equality' of a condition and not the negative stuff like 'inequality'. Let me elaborate - If a piece of conditional code can be written by checking whether an expression is true or false, we should check the 'trueness'. Example: Finding out whether a number is odd - it can be done in two ways: if ( num % 2 != 0 ) { // Number is odd } or if ( num % 2 == 1 ) { // Number is odd } When I was beginning to code, I knew that num % 2 == 0 implies the number is even, so I just put a ! there to check if it is odd. But he was like 'Don't check NOT conditions. Have the practice of checking the 'trueness' or 'equality' of conditions whenever possible.' And he recommended that I use the second piece of code. I am not for or against either but I just wanted to know - what difference does it make? Please don't reply 'Technically the output will be the same' - we ALL know that. Is it a general programming practice or is it his own programming practice that he is preaching to others?

    Read the article

  • Conditional compilation hackery in C# - is there a way to pull this off?

    - by Chris
    I have an internal API that I would like others to reference in their projects as a compiled DLL. When it's a standalone project that's referenced, I use conditional compilation (#if statements) to switch behavior of a key web service class depending on compilation symbols. The problem is, once an assembly is generated, it appears that it's locked into whatever the compilation symbols were when it was originally compiled - for instance, if this assembly is compiled with DEBUG and is referenced by another project, even if the other project is built as RELEASE, the assembly still acts as if it was in DEBUG as it doesn't need recompilation. That makes sense, just giving some background. Now I'm trying to work around that so I can switch the assembly's behavior by some other means, such as scanning the app/web config file for a switch. The problem is, some of the assembly's code I was switching between are attributes on methods, for example: #if PRODUCTION [SoapDocumentMethodAttribute("https://prodServer/Service_Test", RequestNamespace = "https://prodServer", ResponseNamespace = "https://prodServer")] #else [SoapDocumentMethodAttribute("https://devServer/Service_Test", RequestNamespace = "https://devServer", ResponseNamespace = "https://devServer")] #endif public string Service_Test() { // test service } Though there might be some syntactical sugar that allows me to flip between two attributes of the same type in another fashion, I don't know it. Any ideas? The alternative method would be to reference the entire project instead of the assembly, but I'd rather stick with just referencing the compiled DLL if I can. I'm also completely open to a whole new approach to solve the problem if that's what it takes.

    Read the article

  • Practice of checking 'trueness' or 'equality' of conditional statements - does it really make sense?

    - by senthilkumar1033
    I remember many years back, when I was in school, one of my computer science teachers taught us that it was better to check for 'trueness' or 'equality' of a condition and not the negative stuff like 'inequality'. Let me elaborate - If a piece of conditional code can be written by checking whether an expression is true or false, we should check the 'trueness'. Example: Finding out whether a number is odd - it can be done in two ways: if ( num % 2 != 0 ) { // Number is odd } or if ( num % 2 == 1 ) { // Number is odd } When I was beginning to code, I knew that num % 2 == 0 implies the number is even, so I just put a ! there to check if it is odd. But he was like 'Don't check NOT conditions. Have the practice of checking the 'trueness' or 'equality' of conditions whenever possible.' And he recommended that I use the second piece of code. I am not for or against either but I just wanted to know - what difference does it make? Please don't reply 'Technically the output will be the same' - we ALL know that. Is it a general programming practice or is it his own programming practice that he is preaching to others?

    Read the article

  • C#: Is it possible to use expressions or functions as keys in a dictionary?

    - by Svish
    Would it work to use Expression<Func<T>> or Func<T> as keys in a dictionary? For example to cache the result of heavy calculations. For example, changing my very basic cache from a different question of mine a bit: public static class Cache<T> { // Alternatively using Expression<Func<T>> instead private static Dictionary<Func<T>, T> cache; static Cache() { cache = new Dictionary<Func<T>, T>(); } public static T GetResult(Func<T> f) { if (cache.ContainsKey(f)) return cache[f]; return cache[f] = f(); } } Would this even work? Edit: After a quick test, it seems like it actually works. But I discovered that it could probably be more generic, since it would now be one cache per return type... not sure how to change it so that wouldn't happen though... hmm Edit 2: Noo, wait... it actually doesn't. Well, for regular methods it does. But not for lambdas. They get various random method names even if they look the same. Oh well c",)

    Read the article

  • Building a regex builder

    - by i.h4d35
    I am a beginner in programming in general and web development in particular. I am especially bad at regular expressions. Recently I was involved in building a couple of cPanel plugins(Perl-CGI) and that's when I realized how bad I am in regex. As a result, I have decided to build an online regex builder - this will help me to learn regex and help other struggling with regex. I have checked out GSkinner, Rubular and a couple of others like regexpal. It seemed to be a little difficult to use, hence i thought of writing another one. I do not know which tool is best suited for the job. should I write it in Perl or Python? My skill level is between beginner and intermediate in both those languages. What would be a good starting point - building it for the CLI or for the browser? I plan to get a string as an input, ask if the user want to search or search and replace, enter the search string (and the replace string where applicable) and then generate a regex. Would this be the right way to go?

    Read the article

  • Documentation often ommits to specify which flavour of regular expression to use, so is there a default flavour that we should all be familiar with?

    - by JW01
    Often I come across documentation that says "use a regular expression here" I have to spend quite some time digging around trying to work out which regular expression format they are expecting. As far as I can tell, there are many types of regular expression. But, at my last place of work I was made to feel stupid when I suggested adding some text to our User Documentation to specify the type of regular expression to be used. When someone says "a regular expression" what is the regular expression syntax most people expect and where is it documented? Update: I was prompted to single-out some examples - but no disrespect to these great projects: eregi docs page is not particularly helpful in explaining expected syntax. Nor can I easily work out the syntax expected here if i just land on the page from a search. No explicit mention of the regular expression pattern expected by PatternExpectation() on the SimpleTest page. etc. etc. here is a highly voted SO answer that seems to assume there is only one flavour of regular expressions.

    Read the article

  • Perl: Negative look behind regex question [migrated]

    - by James
    The Perlre in Perldoc didn't go into much detail on negative look around but I tried testing it, and didn't work as expected. I want to see if I can differentiate a C preprocessor macro definition (e.g. #define MAX(X) ....) from actual usage (y = MAX(x);), but it didn't work as expected. my $macroName = 'MAX'; my $macroCall = "y = MAX(X);"; my $macroDef = "# define MAX(X)"; my $boundary = qr{\b$macroName\b}; my $bstr = " MAX(X)"; if($bstr =~ /$boundary/) { print "boundary: $bstr matches: $boundary\n"; } else { print "Error: no match: boundary: $bstr, $boundary\n"; } my $negLookBehind = qr{(?<!define)\b$macroName\b}; if($macroCall =~ /$negLookBehind/) # "y = MAX(X)" matches "(?<!define)\bMAX\b" { print "negative look behind: $macroCall matches: $negLookBehind\n"; } else { print "no match: negative look behind: $macroCall, $negLookBehind\n"; } if($macroDef =~ /$negLookBehind/) # "#define MAX(X)" should not match "(?<!define)\bMAX\b" { print "Error: negative look behind: $macroDef matches: $negLookBehind\n"; } else { print "no match: negative look behind: $macroDef, $negLookBehind\n"; } It seems that both $macroDef and $macroCall seem to match regex /(?<!define)\b$macroName\b/. I backed off from the original /(?<\#)\s*(?<!define)\b$macroName\b/ since that didn't work either. So what did I screw up? Also does Perl allow chaining of multiple look around expressions?

    Read the article

  • Lambda expressions in C#?

    - by user30457
    Hey I'm rather new to these could someone explain the significance or prehaps give a link to some useful information on lambda expressions? I encounter the following code in a test and I am wondering why someone would do this: foo.MyEvent += (o, e) = { fCount++; Console.WriteLine(fCount); }; foo.MyEvent -= (o, e) = { fCount++; Console.WriteLine(fCount); }; My instinct tells me it is something simple and not a mistake, but I don't know enough about these expressions to understand why this is being done. Regards,

    Read the article

  • Excel Conditional Formatting Multiple Data Bars and Data Icons in one cell

    - by wbeard52
    I am using Excel 2007 on a windows machine. I am attempting to place one data bar and one data icon into a cell under the conditional formatting. The issue is that I don't really want to have data icons or data bars for cells that have dates in the future and I only want to have data icons for dates in the at least one month in the past. This is what I have: This is what I want: I am using the EOMONTH function to determine the last day of the month for the conditional formatting calculations. For the data bar the formula is =EOMONTH(Now(), 4) and =EOMONTH(Now(), -1). The data icons formulas are =EOMONTH(Now(), -1) and =EOMONTH(Now(), -2) Is there a way in Excel 2007 to get rid of the data icons for all the dates in the future and lose the data bars when the date has past. Thanks

    Read the article

  • Conditional Directory Index In Htaccess

    - by icelizard
    This relates to the question in: http://stackoverflow.com/questions/1599717/conditional-directoryindex-in-htaccess The answer states that the following should work: SetEnvIf Remote_Addr ^127\.0\.0\.0$ owner <IfDefine owner> DirectoryIndex index.html </IfDefine> <IfDefine !owner> DirectoryIndex index.php </IfDefine> I am not sure this works, the setting of the Env var deffinately does, but no matter what IP I visit the site from the DirectoryIndex is always index.php Is there something wrong with the conditional or should I be using something else? Thanks in advance

    Read the article

  • CCNet 1.6 Conditional Plugin Help Needed!

    - by Mike M
    Hi all, I cannot get the conditional plugin to work that has been added to CCNet as of version 1.6 - clicky. I am running the latest version of CCNet (1.6.7258.1) and have the following code in my ccnet.config: <project name="9iCompile"> <sourcecontrol type="svn"> <trunkUrl>http://bis-build:81/svn/Oracle/oas_forms/COPEN</trunkUrl> <workingDirectory>C:\OAS\COPEN</workingDirectory> <username>*</username> <password>*</password> <executable>C:\Program Files\VisualSVN\bin\svn.exe</executable> </sourcecontrol> <conditional> <conditions> <compareCondition> <value1>$[ProjectType]</value1> <value2>copen</value2> <evaluation>equal</evaluation> <ignoreCase>true</ignoreCase> </compareCondition> </conditions> <tasks> <nant> <executable>C:\Program Files\nant-0.85\bin\nant.exe</executable> <baseDirectory>C:\OAS</baseDirectory> <buildFile>Oracle9i_Automation_v2.build</buildFile> <targetList> <target>build</target> </targetList> </nant> </tasks> </conditional> <!-- more conditional statements would be here for different project types if I can get it to work --> <parameters> <selectParameter name="ProjectType"> <description>The type of project to operate on.</description> <allowedValues> <value name="COPEN">copen</value> <value name="BCS">bcs</value> <value name="FCDD">fcdd</value> </allowedValues> </parameters> <security type="defaultProjectSecurity" defaultRight="Deny"> <permissions> <rolePermission name="Developers" ref="Developers"/> <rolePermission name="Accepters" ref="Accepters"/> <rolePermission name="Releasers" ref="Releasers"/> <rolePermission name="Administrators" ref="Administrators"/> </permissions> </security> </project> The CCNet server crashes whenever I try to run this config though with the following output: [14:ERROR] Exception: Unused node detected: <conditional> <conditions> <compareCondition> <value1>$[ProjectType]</value1> <value2>copen</value2> <evaluation>equal</evaluation> <ignoreCase>true</ignoreCase> </compareCondition> </conditions> <tasks> <nant> <executable>C:\Program Files\nant-0.85\bin\nant.exe</executable> <baseDirectory>C:\OAS</baseDirectory> <buildFile>Oracle9i_Automation_v2.build</buildFile> <targetList> <target>build</target> </targetList> </nant> </tasks> </conditional> ---------- ThoughtWorks.CruiseControl.Core.Config.ConfigurationException: Unused node detected: <conditional> <conditions> <compareCondition> <value1>$[ProjectType]</value1> <value2>copen</value2> <evaluation>equal</evaluation> <ignoreCase>true</ignoreCase> </compareCondition> </conditions> <tasks> <nant> <executable>C:\Program Files\nant-0.85\bin\nant.exe</executable> <baseDirectory>C:\OAS</baseDirectory> <buildFile>Oracle9i_Automation_v2.build</buildFile> <targetList> <target>build</target> </targetList> </nant> </tasks> </conditional> at ThoughtWorks.CruiseControl.Core.Config.NetReflectorConfigurationReader.Defa­ultErrorProcesser.ProcessError(String message) at ThoughtWorks.CruiseControl.Core.Config.NetReflectorConfigurationReader.<>c_­_DisplayClass1.<Read>b__0(InvalidNodeEventArgs args) at Exortech.NetReflector.InvalidNodeEventHandler.Invoke(InvalidNodeEventArgsar­gs) at Exortech.NetReflector.NetReflectorTypeTable.OnInvalidNode(InvalidNodeEventA­rgs args) at Exortech.NetReflector.XmlTypeSerialiser.HandleUnusedNode(NetReflectorTypeTa­ble table, XmlNode orphan) at Exortech.NetReflector.XmlTypeSerialiser.ReadMembers(XmlNode node, Object instance, NetReflectorTypeTable table) at Exortech.NetReflector.XmlTypeSerialiser.Read(XmlNode node, NetReflectorTypeTable table) at Exortech.NetReflector.NetReflectorReader.Read(XmlNode node) at ThoughtWorks.CruiseControl.Core.Config.NetReflectorConfigurationReader.Read­(XmlDocument document, IConfigurationErrorProcesser errorProcesser) at ThoughtWorks.CruiseControl.Core.Config.DefaultConfigurationFileLoader.Load(­FileInfo configFile) at ThoughtWorks.CruiseControl.Core.Config.FileConfigurationService.Load() at ThoughtWorks.CruiseControl.Core.Config.FileWatcherConfigurationService.Load­() at ThoughtWorks.CruiseControl.Core.Config.CachingConfigurationService.Load() at ThoughtWorks.CruiseControl.Core.CruiseServer.Restart() at ThoughtWorks.CruiseControl.Core.Config.ConfigurationUpdateHandler.Invoke() at ThoughtWorks.CruiseControl.Core.Config.FileWatcherConfigurationService.Hand­leConfigurationFileChanged(Object source, FileSystemEventArgs args) ---------- Can someone please help?? I have no idea what I'm doing wrong here or if this is a bug :( I have also posted on the ccnet-user group several days ago but have not received any response :(

    Read the article

  • ASP.NET MVC Conditional validation

    - by Peter Stegnar
    How to use data annotations to do a conditional validation on model? For example, lets say we have the following model (Person and Senior): public class Person { [Required(ErrorMessage = "*")] public string Name { get; set; } public bool IsSenior { get; set; } public Senior Senior { get; set; } } public class Senior { [Required(ErrorMessage = "*")]//this should be conditional validation, based on the "IsSenior" value public string Description { get; set; } } And the following view: <%= Html.EditorFor(m => m.Name)%> <%= Html.ValidationMessageFor(m => m.Name)%> <%= Html.CheckBoxFor(m => m.IsSenior)%> <%= Html.ValidationMessageFor(m => m.IsSenior)%> <%= Html.CheckBoxFor(m => m.Senior.Description)%> <%= Html.ValidationMessageFor(m => m.Senior.Description)%> I would like to be the "Senior.Description" property conditional required field based on the selection of the "IsSenior" propery (true - required). How to implement conditional validation in ASP.NET MVC 2 with data annotations? UPDATE Found nice solution. Look below.

    Read the article

  • How can I use a conditional TextField in JasperReports?

    - by Jonas
    I would like to have a TextField depenging on a value. When the value is "0" I would like to hide the TextField. I.e. I would like to hide the staticText and the textField if the parameter red is equal to "0" in the jrxml-code below: <staticText> <reportElement x="100" y="30" width="100" height="30"/> <text><![CDATA[Red items:]]></text> </staticText> <textField> <reportElement x="200" y="30" width="40" height="30"/> <textFieldExpression> <![CDATA[$P{red}]]> </textFieldExpression> </textField> How can I do this?

    Read the article

  • How to find out exact version of iPhone SDK for conditional compilation?

    - by Jochen
    I'm looking for a macro that specified the exact version of the iPhone SDK used for compilation. This is needed because when compiling with (and only with) SDK 3.0, I need to add some additional code. __IPHONE_OS_VERSION_MIN_REQUIRED is not the right choice here, since it can be set by the user with parameter -mmacosx-version-min. For example, a user can compile with min version -mmacosx-version-min=3.0 in SDK 3.1, so a check for __IPHONE_OS_VERSION_MIN_REQUIRED == 30000 would be true, even if the user is compiling with SDK 3.1. Any help is appreciated. Regards, Jochen

    Read the article

  • Is it considered bad form to execute a function within a conditional statement?

    - by michael
    Consider a situation in which you need to call successive routines and stop as soon as one returns a value that could be evaluated as positive (true, object, 1, str(1)). It's very tempting to do this: if (fruit = getOrange()) elseif (fruit = getApple()) elseif (fruit = getMango()) else fruit = new Banana(); return fruit; I like it, but this isn't a very recurrent style in what can be considered professional production code. One is likely to rather see more elaborate code like: fruit = getOrange(); if(!fruit){ fruit = getApple(); if(!fruit){ fruit = getMango(); if(!fruit){ fruit = new Banana(); } } } return fruit; According to the dogma on basic structures, is the previous form acceptable? Would you recommend it?

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >