w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
RESTKit object BOOL property to true/false JSON
Source type :NSCFBoolean Destination type : NSString Discussion: Boolean literals true and false parsed from JSON are mapped to NSString properties as @"true" and @"false" Source :See This table

Categories : IOS

python how to "negate" value : if true return false, if false return true
Use the not boolean operator: nyval = not myval not returns a boolean value (True or False): >>> not 1 False >>> not 0 True If you must have an integer, cast it back: nyval = int(not myval) However, the python bool type is a subclass of int, so this may not be needed: >>> int(not 0) 1 >>> int(not 1) 0 >>> not 0 == 1 True >>> not 1 == 0 True

Categories : Python

Haskell: Check if all conditions are true. If they are return true otherwise false
You can lose the guards and use and to check your conditions: checkMatch :: Person -> Person -> Bool checkMatch seeker candidate = and [ gender candidate == preferedGender seeker , gender seeker == preferedGender candidate , minAcceptableAge seeker <= age candidate , maxAcceptableAge seeker >= age candidate , minAcceptableAge candidate <= age seeker , maxAcceptableAge candidate >= age seeker ]

Categories : Haskell

What is the meaning of True == True != False in Python and how to find out?
In most languages, a == b != c parses as (a == b) != c. Therefore, what you would expect is that True == True != False would be the same as (True == True) != False, which evaluates to True != False, which evaluates to True. Python has a different meaning, as can be witnessed here: >>> True != False != False False >>> (True != False) != False True In Python, a == b != c is equivalent to (a == b) and (b != c). This means that True == True != False is equivalent to (True == True) and (True != False), which evaluates to True and True, which evaluates to True. Coincidentally, both meanings (Python's and that of other languages) give the same result here, but one should be cautious.

Categories : Python

Factor with 4 levels False, FALSE, True, TRUE but need just 2 levels
Simply use as.logical: d <- c("False", "FALSE", "True", "TRUE") factor(as.logical(d)) # [1] FALSE FALSE TRUE TRUE # Levels: FALSE TRUE From ?as.logical: Character strings c("T", "TRUE", "True", "true") are regarded as true, c("F", "FALSE", "False", "false") as false, and all others as NA.

Categories : R

XSLT Parsing error when using Umbraco GetMedia
For anyone else trying to get an image from an item in a content folder, this is how I got it to work: <xsl:for-each select="umbraco.library:GetXmlNodeById(1123)/* [@isDoc]"> <article> <!-- Store the ID --> <xsl:variable name="mediaId" select="bannerImage" /> <!-- Check the ID is numeric --> <xsl:if test="number($mediaId) &gt; 0"> <xsl:variable name="mediaNode" select="umbraco.library:GetMedia($mediaId, false())" /> <xsl:if test="string-length($mediaNode/umbracoFile) &gt; 0"> <img src="{$mediaNode/umbracoFile}" width="1822" height="600" /> <div class="contents"> <h1> <xsl:value-of select="bannerHeading1"/> </h1&g

Categories : Xslt

Get umbraco property with inline C#
If you know the node ID, you could just use new Node(id).GetProperty("protectContent").Value.ToString() == "1" However, if you are on the page you wish to query, you can just use: Node.GetCurrent().GetProperty("protectContent").Value.ToString() == "1" If I'm using masterpages, I like to have a CurrentNode accessor in my codebehind .cs file that returns Node.GetCurrent() but has a backing field so it is not requested each time I call it, e.g. public partial class BaseMaster : System.Web.UI.MasterPage { public Node CurrentNode { get; set; } protected void Page_Load(object sender, EventArgs e) { CurrentNode = Node.GetCurrent(); } }

Categories : C#

How-to Test if Umbraco property is empty
umbraco.library:GetMedia cannot return null, you may get an error back if no media was matched, in example <error>No media is maching '123123'</error> The thing is that your code works but you dont close the <xsl:attribute name="src"> as you should <xsl:attribute name="src"> <xsl:value-of select="$url" /> </xsl:attribute> If you for some reason really like to ensure that there is an image in there you should write a "test" and count values in the nodeTypeAlias <xsl:variable name="media" select="umbraco.library:GetMedia(sectionImage, 0)" /> <xsl:if test="count($media[@nodeTypeAlias='Image']) > 0"> <xsl:variable name="url" select="$media/umbracoFile" /> <xsl:element name="img"> <xsl:attribute name="src">

Categories : Xslt

Umbraco: Unable to get RelatedLinks property value in code-behind
What data type is your related links set to, assuming its a content picker where you are getting the id of the related page you could first create a node form your current page's id then try and get the value from that node e.g. var current = Node.GetCurrent(); var currentPage = Model.NodeById(current.Id); var relatedLinks = currentPage.RelatedLinks; or var relatedLinks = GetProperty("RelatedLinks").Value; when you debug you should be able to see all the properties of currentpage and check your alias as well to make sure its right (generally aliases dont start with a capital by default).

Categories : C#

What could cause php value to be true and false?
Isset tests if the variable or index has been initialized or not and does not always use booleans. The value could just as well be null and the proper way of testing this (since PHP is loosely coupled) would be: if (isset(self::$_registry[$key]) === true) Or better yet; if (array_key_exists($key, self::$_registry)) I always suggest using array_key_exists instead of isset since the first one is much more reliable for true/false conditions. Edit: Also, like the comments stated - your variable is $registryKey and not $key.

Categories : PHP

Why {} == {} is false, but {} + {} == {} + {} is true
+ here is the string-concatenation operator. This: {} == {} means "if I create one object with {}, and another object with {}, are they the same object?"; and the answer is "no". This: {} + {} == {} + {} means "is the primitive string "[object Object][object Object]" the same as the primitive string "[object Object][object Object]"?"; and the answer is "yes". Edited to add: A number of commenters point out that in Chrome's Web Console, {} + {} performs numeric addition, NaN + NaN, such that {} + {} == {} + {} actually returns false (because it's not true that NaN == NaN). Firefox's Web Console gives the same result as Chrome's, but if you run this inside a page, it gives the same result as node.js. [Redacted: long explanation of how the spec dictates that {} + {} should be strin

Categories : Javascript

Is true && true == false?
What you meant to check is a.include?("foo") && a.size == 3 Your condition is checking if "foo" && a.size == 3 (which is true because "foo" is neither nil nor false) is included in the array. The solution of Zack's comment is correct too, but looking a bit unusual: (a.include? "foo") && a.size == 3 One reason why the whole expression is considered the method's argument in case of missing parentheses is you can do: puts 3 + 4 * 5 - 6

Categories : Ruby

TRUE < FALSE in MS Access?
From This answer: The binary representation of False is 0000000000000000. If you perform a NOT operation (in machine code) to it, it will be changed to 1111111111111111, but this is the binary representation of the 16-bit signed integer -1. Changing the sign of a number happens by inverting all the bits and adding 1. This is called the "two's complement". Let us change the sign of 1111111111111111. First invert; we get: 0000000000000000 Then add one: 0000000000000001, this is 1. This is the proof that 1111111111111111 was the binary representation of -1.

Categories : SQL

Change TRUE and FALSE to Yes and No
As far as I know there is no way to overwrite the fact that R prints TRUE and FALSE for logical objects (personally I think that's good). The closest solution to what you're looking for could be factor conversion: z <- factor(x==y, labels=c("No", "Yes")) > z [1] No Yes Yes Yes Yes No Yes Levels: No Yes

Categories : R

AutoPostBack: true vs false
Warning: I'm no ASP.NET expert... If this turns out to be garbage, I'll delete it :) A) I believe you will see the new values of all the controls, whenever the postback ends up happening, including all the change events, just as you described. The values have changed, after all - the AutoPostBack just affects the timing (and whether the postback occurs at all, of course). B) There's more Javascript in the HTML delivered with AutoPostBack = True on all the controls, but not enough to make that enormous difference. As noted in your edit, it looks like that was a transient issue anyway - we can't really explain transient issues without more diagnostics.

Categories : C#

Getting false instead of true in ProLog
This is because code1 & code2 are atoms, and since you’re not passing in the atoms code1 & code2, it doesn’t match and returns false. You want variables (which begin with a capital letter or underscore) instead: sameCode(product(Code1,_,_,_,_), product(Code2,_,_,_,_)) :- Code1 = Code2. This can be simplified to just: sameCode(product(Code,_,_,_,_), product(Code,_,_,_,_)). as Code is, of course, unified with itself.

Categories : Prolog

Is there anything wrong with using T and F instead of TRUE and FALSE?
T and F can be re-defined, but TRUE and FALSE are reserved words and cannot be re-defined. > TRUE <- 1L Error in TRUE <- 1L : invalid (do_set) left-hand side to assignment > FALSE <- 0L Error in FALSE <- 0L : invalid (do_set) left-hand side to assignment > T <- F # yikes, this would be hard to debug! Personally, I sometimes use T and F when I use R interactively, but I never use them in production code or packages.

Categories : R

Why does GTK+ define TRUE and FALSE?
C99 has true and false, earlier versions do not. That is why you often see TRUE and FALSE #defined. As you can read here, true and false are 1 and 0 respectively, same as TRUE and FALSE.

Categories : C

How to implement custom controllers in Umbraco 6
Do you really mean you want a custom controller, or do you actually just want to create a form in Umbraco using MVC? If it's the latter then you need to use a surface controller ie. ensure your controller inherits from Umbraco.Web.Mvc.SurfaceController and has the suffix 'SurfaceController'. public class MySurfaceController : Umbraco.Web.Mvc.SurfaceController { public ActionResult Index() { return Content("hello world"); } } You then need to use the custom Umbraco Html helper to create your form tags: @using(Html.BeginUmbracoForm("CreateComment", "BlogPostSurface")) { // } See http://our.umbraco.org/documentation/Reference/Mvc/forms

Categories : C#

In Umbraco 6.1.1 MVC 4, how can I do a form post back to a surface controller using a model that inherits from Umbraco's RenderModel?
Ok, I've had no responses to this question but am now in a position to answer it myself. Maybe it was a fundamental oversight, but not that obvious imho, and information on the Umbraco forum etc about inheriting from RenderModel is fairly limited. Essentially the answer, as was my first instinct, is to solve the original exception "No parameterless constructor defined for this object" by providing a paramaterless constructor. The difficulty is working out what to put inside the parameterless constructor for my model, since it inherits from the Umbraco RenderModel which requires an IPublishedContent instance passed to it's constructor. Luckily while browsing around I happened across this post on the Umbraco forum: http://our.umbraco.org/forum/developers/api-questions/40754-Getting-Curre

Categories : Asp Net Mvc

show Yes/NO instead True/False in datagridview
When it comes to custom formatting, two possible solutions comes in my mind. 1.Handle CellFormatting event and format your own. void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { if (e.ColumnIndex == yourcolumnIndex) { if (e.Value is bool) { bool value = (bool)e.Value; e.Value = (value) ? "Yes" : "No"; e.FormattingApplied = true; } } } 2.Use Custom Formatter public class BoolFormatter : ICustomFormatter, IFormatProvider { public object GetFormat(Type formatType) { if (formatType == typeof(ICustomFormatter)) { return this; } return null; } public string Format(string format, object arg, IFormatProvider form

Categories : C#

How to change div contenteditable from true to false
This work in all browser var arr=document.getElementsByTagName("div"); for(var i=0;i<document.getElementsByTagName("div").length;i++) document.getElementsByTagName("div")[i].removeAttribute("contenteditable"); Working Demonstration This will work in modern browser(but too much versatile) for(var i=0;i<document.querySelectorAll("div").length;i++) document.querySelectorAll("div")[i].removeAttribute("contenteditable"); Working Demonstration

Categories : Javascript

How to get DBGrid to draw Yes/No rather than True/False
I would say that you're working at the wrong level of abstraction. Use two calculated columns (AFlag and OFlag in the example below) and define an OnCalcFields event for your clientdataset. The below code is attached to a dataset called 'qCpap'. procedure TView.qCpapCalcFields(DataSet: TDataSet); begin if qCpapApproved.AsBoolean then qCpapAFlag.AsString:= 'Yes' else qCpapAFlag.AsString:= 'No'; if qCpapObsolete.AsBoolean then qCpapOFlag.AsString:= 'Yes' else qCpapOFlag.AsString:= 'No'; end; Incidentally, there's no point in using the 'uppercase' function on a string constant: you may as well write the string in uppercase yourself.

Categories : Delphi

Comparing two lists for true and false
You should make at acceptItem a set. Then you can do >>> acceptItem = {"Combat Knife","Flares","Compass","silver bar","a cloth","a stick","some rope"} >>> pla_back = ["Combat Knife","Flares","Compass"] >>> all(item in acceptItem for item in pla_back) True (This also works if acceptItem remains a list, but set lookup is much faster).

Categories : Python

Conversion from bool to int (true -> 1 and false -> 0)
System.Convert.ToInt32(bool) -- I'm not too familiar with F#, but I believe that using a function is the same whether it is built in or not: function(arg0, arg1, ...). So, in this case you'd simply call System.Convert.ToInt32(myBool).

Categories : F#

Comparing True False confusion
use not: if not a: .... # If a is the empty value like '', [], (), {}, or 0, 0.0, ..., False # control flow also reach here. or == False: if a == False: ....

Categories : Python

Javascript function true/false
Basically if-else cannot chose third path to follow, it will always be on of the two. With your code, however, I think the problem is with the instructions order, it should be: // Return from server xhr.onload = function() { var data = JSON.parse(this.responseText); Ti.API.info(data); if (data.success == true) { Ti.API.info('Logged In'); return true; // If not flag an error } else { Ti.API.info('Failed Registration'); return false; }; }; So that either Logged In or Failed Registration will be called. In your original post success=0 was evaluated as false, but due to return statement being first one - Ti.API.info('Failed Registration'); was never executed.

Categories : Javascript

PHP Expression: Why var_dump(false < -1) = true?
False is boolean type, and from PHP maunal: -1 is considered TRUE, like any other non-zero (whether negative or positive) number! Resource: http://php.net/bool

Categories : PHP

if statement running regardless of true false
Instead of verbal explanations, wouldn't be it better to post either the debugging code var_dump($cliqid); $tmp = $this->logic_m->cliqidcheck($cliqid); if (!$tmp) { $cliqid = 6; } var_dump($tmp, $cliqid); die; and it's output. Even without posting it here it will convince you that if statement actually never "running regardless of true false" Setting full error reporting also helps (with finding typos and such) ini_set('display_errors',1); error_reporting(E_ALL); Also a note on excessive code. This statement if (condition) { return true; } else { return false; } can (and should, in my opinion) be shortened to return (condition); Same goes for insert id. Why not to make it just return $this->db->insert_id(); without all that windy if ($newcliqid)

Categories : PHP

True & False Boolean in Python
while True: will continue indefinitely (unless you put in a break - usually break is bad design in languages like Python)). You probably want to do: while something == True: #Or - as has been pointed out, `while something` - which is equivalent and more Pythonic ... some code which eventually sets something to False ...

Categories : Python

PHP isset returns true but should be false
String offsets provide a mechanism to use strings as if they were an array of characters: $string = 'abcde'; echo $string[2]; // c $model is indeed a string for all keys except discontinued. As for the isset($model['Service'][0]) return value, I'm a bit surprised. This is a simplified test case: $model = '2'; var_dump(isset($model['Service'])); // bool(false) var_dump(isset($model['Service'][0])); // bool(true) There must be a reason somewhere. Will have a dig..

Categories : PHP

GridBooleanColumn with data first by 0 and 1 but no true and false
I have similar situation and for work with 0 and 1 from db I use not boolean column. From db I send 0 and 1, in my column renderer I check this and make some conversions. Check my example(here's actioncolumn - it's for show icons in cells). It's one way to decision your situation. My view: xtype: 'actioncolumn', width: 55, align: 'center', dataIndex: 'Actif', menuDisabled: 'true' text: '', sortable: false, fixed: 'true', renderer: function (value, metadata, record) { if (value == '0') { //some code } else { //some code } }, getTip: function (value, metadata, record) { if (value == '0') { return 'here 0'; } else { return 'here 1'; } } You don't need to change model. In your example I think you should add type of you'r field in

Categories : Javascript

Return Bit Value as 1/0 and NOT True/False in SQL Server
Modify your query to generate the output that you want. Try casting them to int: select cast(bitFlag as int) Or, if you like, use case: select (case when bitFlag = 0 then 0 else 1 end)

Categories : SQL

Any difference between returning False or True first?
The difference is that both the loops are checking for different results. The 1st loop is checking whether the $regexp matches all the elements of the array - In this case, it returns false as soon as a match fails and if the return statement after the for loop is reached, that means all the elements match. To be honest, not having the braces around the for loop can often be confusing (like it confused me first). I would suggest to add relevant brace: for ($i=0; $i<2; $i++) { if (preg_match($regexp, $names[$i])) { return true; } } return false; The 2nd loop is checking whether the $regexp matches any element of the array - In this case, it return true as soon as a match succeeds, and if the return statement after the for loop is reached, that means none of the eleme

Categories : PHP

Check if boolean is true or false
Hope this should work elseif(!isset($value[1]) || $value[1] === FALSE){ echo "Company NOT blocked"; } After reading your comment I made this solution. Look stupid but hopefully can work if ($value[1] == "True"){ echo "Company blocked"; } elseif($value[1] == "False"){ echo "Company NOT blocked"; }

Categories : PHP

comparing two SQL tables set cut-set to true and else to false
You have no join condition, so your query is simply creating a cartesian product between the two tables. It then reports true or false depending on whether the users match in a particular pairing. You would see this if you included s.user in your SELECT clause. To do what you want, you should use an outer join. SELECT s.user, r.user IS NOT NULL AS flag FROM s LEFT JOIN r ON r.user = s.user

Categories : Mysql

True/False to Yes/No in Jquery DataTable
Follow this Datatable Usage if you will use newest version of datatable i suggest used mRender or mData. if the older version use fnRender. // Create a comma separated list from an array of objects $(document).ready( function() { var oTable = $('#example').dataTable( { "sAjaxSource": "sources/deep.txt", "aoColumns": [ { "mData": "engine" }, { "mData": "browser" }, { "mData": "platform", "mRender": "[, ].name" } ] } ); } ); // Use as a function to create a link from the data source $(document).ready( function() { var oTable = $('#example').dataTable( { "aoColumnDefs": [ { "aTargets": [ 0 ], "mData": "download_link", "mRender": function ( data, type, full ) { return '<a href="'+data+'">Download&

Categories : Jquery

Printing all permutations of True and False
Just implement it using addition because that's what you'd be reimplementing. Then implement a way to map a binary number to a true, false values based on the value of the bit values at each position. Using long would limit you to length of 63 (signed numbers). If you need more than that use BigInteger (homework left to the reader of course). for( long i = 0; i < permutations; i++ ) { printBinary( i, l ); } public void printBinary( long number, int length ) { long current = 1 << length; while( current > 0 ) { System.out.print( number & current == current ? "true " : "false " ); current >>> 1; } }

Categories : Java

Umbraco MVC Implementation - View does not depend on Umbraco implementations
No you can't. Simply because all requests pass through a single action. In order to retrieve a path to a CMS-managed page, you need to use the node/content traversal the @Model provides. See here for more details on this. Edit To clarify, the author of the article is suggesting that the Umbraco implementation should be more in line with a traditional MVC implementation with little or no logic in the views. Therefore, any querying of node data should happen prior to the view (e.g. in the Mappers). So this is where you would have to retrieve the links. Umbraco's default MVC implementation forces all requests to go via a single action on a single controller. The author's implementation allows the requests to be shared across one controller per document type - which is better IMO. But it st

Categories : Asp Net Mvc

Why were True and False changed to keywords in Python 3
Possibly because Python 2.6 not only allowed True = False but also allowed you to say funny things like: __builtin__.True = False which would reset True to False for the entire process. It can lead to really funny things happening: >>> import __builtin__ >>> __builtin__.True = False >>> True False >>> False False >>> __builtin__.False = True >>> True False >>> False False EDIT: As pointed out by Mike, the Python wiki also states the following under Core Language Changes: Make True and False keywords. Reason: make assignment to them impossible.

Categories : Python



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.