Search Results

Search found 40287 results on 1612 pages for 'try statement'.

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

  • What's the scope of a Python variable declared in an if statement?

    - by froadie
    I'm new to Python, so this is probably a simple scoping question. The following code in a Python file (module) is confusing me slightly: if __name__ == '__main__': x = 1 print x In other languages I've worked in, this code would throw an exception, as the x variable is local to the if statement and should not exist outside of it. But this code executes, and prints 1. Can anyone explain this behavior? Are all variables declared in a module global/available to the entire module?

    Read the article

  • Best way to format if statement with multiple conditions.

    - by Matt690
    If you want to some code to execute based on two or more conditions which is the best way to format that if statement ? first example:- if(ConditionOne && ConditionTwo && ConditionThree) { Code to execute } Second example:- if(ConditionOne) { if(ConditionTwo ) { if(ConditionThree) { Code to execute } } } which is easiest to understand and read bearing in mind that each condition may be a long function name or something.

    Read the article

  • c#: can you use a boolean predicate as the parameter to an if statement?

    - by Craig Johnston
    In C#, can you use a boolean predicate on its own as the parameter for an if statement? eg: string str = "HELLO"; if (str.Equals("HELLO")) { Console.WriteLine("HELLO"); } Will this code output "HELLO", or does it need to be: string str = "HELLO"; if (str.Equals("HELLO") == true) { Console.WriteLine("HELLO"); } If there is anything else wrong with the above code segments, please point it out.

    Read the article

  • Try out Windows Phone 7 on your PC today

    - by Matthew Guay
    Anticipation has been building for the new Windows Phone 7 Series ever since Microsoft unveiled it at the Mobile World Congress in February.  Now, thanks to free developer tools, you can get a first-hand experience of the basic Windows Phone 7 Series devices on your PC. Windows Phone 7 Series represents a huge change in the mobile field for Microsoft, bringing the acclaimed Zune HD UI to an innovative phone platform.  Windows Mobile has often been criticized for being behind other Smartphone platforms, but Microsoft seeks to regain the lead with this new upcoming release.  A platform must have developers behind it to be useful, so they have released a full set of free development tools so anyone can make apps for it today.  Or, if you simply want to play with Windows Phone 7, you can use the included emulator to try out the new Metro UI.  Here’s how to do this today on your Vista or 7 computer. Please note: These tools are a Customer Technology Preview release, so only install them if you’re comfortable using pre-release software. Getting Started First, download the Windows Phone Developer Tools CTP (link below), and run the installer.  This will install the Customer Technology Preview (CTP) versions of Visual Studio 2010 Express for Windows Phone, Windows Phone Emulator, Silverlight for Windows Phone, and XNA 4.0 Game Studio on your computer, all of which are required and cannot be installed individually. Accept the license agreement when prompted. Click “Install Now” to install the tools you need.  The only setup customization option is where to save the files, so choose Customize if you need to do so. Setup will now automatically download and install the components you need, and will additionally download either 32 or 64 bit programs depending on your operating system. About halfway thorough the installation, you’ll be prompted to reboot your system.  Once your computer is rebooted, setup will automatically resume without further input.   When setup is finished, click “Run the Product Now” to get started. Running Windows Phone 7 on your PC Now that you’ve got the Windows Phone Developer tools installed, it’s time to get the Windows Phone emulator running.  If you clicked “Run the Product Now” when the setup finished, Visual Studio 2010 Express for Windows Phone should have already started.   If not, simply enter “visual studio” in your start menu search and select “Microsoft Visual Studio 2010 Express for Windows Phone”. Now, to run the Windows Phone 7 emulator, we have to test an application.  So, even if you don’t know how to program, we can open a phone application template, and then test it to run the emulator.  First, click New Project on the left hand side of the front page. Any of the application templates would work for this, but here let’s select “Windows Phone Application”, and then click Ok. Here’s your new application template, which already contains the basic phone application framework.  This is where you’d start if you want to develop a Windows Phone app, but for now we just want to see Windows Phone 7 in action. So, to run the emulator, click Debug in the menu and then select Start Debugging. Your new application will launch inside the Windows Phone 7 Series emulator.  The default template doesn’t give us much, but it does show an example application running in Windows Phone 7.   Exploring Windows Phone 7 Click the Windows button on the emulator to go to the home screen.  Notice the Zune HD-like transition animation.  The emulator only includes Internet Explorer, your test application, and a few settings. Click the arrow on the right to see the available applications in a list. Settings lets you change the theme, regional settings, and the date and time in your emulator.  It also has an applications settings pane, but this currently isn’t populated. The Time settings shows a unique Windows Phone UI. You can return to the home screen by pressing the Windows button.  Here’s the Internet Explorer app running, with the virtual keyboard open to enter an address.  Please note that this emulator can also accept input from your keyboard, so you can enter addresses without clicking on the virtual keyboard. And here’s Google running in Internet Explorer on Windows Phone 7. Windows Phone 7 supports accelerometers, and you can simulate this in the emulator.  Click one of the rotate buttons to rotate the screen in that direction. Here’s our favorite website in Internet Explorer on Windows Phone 7 in landscape mode. All this, running right inside your Windows 7 desktop… Developer tools for Windows Phone 7 Although it may be fun to play with the Windows Phone 7 emulator, developers will be more excited to actually be able to create new and exciting apps for it.  The Windows Phone Developer Tools download includes Visual Studio Express and XNA Game Studio 4.0 which lets you create enticing games and apps for Windows Phones.  All development for Windows Phones will be in C#, Silverlight, and the XNA game framework.  Visual Studio Express for Windows Phone includes templates for these, and additionally has code samples to help you get started with development. Conclusion Many features are still not functional in this preview version, such as the search button and most of the included applications.  However, this still gives you a great way to experience firsthand the future of the Windows Phone platform.  And, for developers, this is your chance to set your mark on the Windows Phone 7 Series even before it is released to the public.  Happy playing and developing! Links Download Windows Phone Developer Tools CTP Windows Phone Developer Site Similar Articles Productive Geek Tips Keep Track of Homework Assignments with SoshikuWeekend Fun: Watch Television On Your PC With TVUPlayerEasily Manage Your Downloads with Download StatusbarCreate a Shortcut or Hotkey to Mute the System Volume in WindowsHow-To Geek on Lifehacker: How to Make Windows Vista Less Annoying TouchFreeze Alternative in AutoHotkey The Icy Undertow Desktop Windows Home Server – Backup to LAN The Clear & Clean Desktop Use This Bookmarklet to Easily Get Albums Use AutoHotkey to Assign a Hotkey to a Specific Window Latest Software Reviews Tinyhacker Random Tips Revo Uninstaller Pro Registry Mechanic 9 for Windows PC Tools Internet Security Suite 2010 PCmover Professional Convert the Quick Launch Bar into a Super Application Launcher Automate Tasks in Linux with Crontab Discover New Bundled Feeds in Google Reader Play Music in Chrome by Simply Dragging a File 15 Great Illustrations by Chow Hon Lam Easily Sync Files & Folders with Friends & Family

    Read the article

  • Updated ODI Statement of Direction

    - by Robert Schweighardt
    An updated version of the Oracle Data Integration Statement of Direction is available. This document provides an overview of the strategic product plans for Oracle’s data integration products for bulk data movement and transformation, specifically Oracle Data Integrator (ODI) and Oracle Warehouse Builder (OWB). It is intended solely to help you assess the business benefits of investing in Oracle’s data integration solutions ...

    Read the article

  • Else statement to show connection successful [closed]

    - by Craig Smith
    I am trying to write a script to test a database connection, at the moment it will only display text if the connection doesn't work, I am stuck with trying to create an else statement to display "Connection Successful" if it works. Here's my code so far. Any help appreciated :) <? $conn = @mysql_connect("localhost", "root", ""); if (!$conn) { die("Connection failed: " .mysql_error()); } ?>

    Read the article

  • i got mysql error on this statement i don't know why [closed]

    - by John Smiith
    i got mysql error on this statement i don't know why error is: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CONSTRAINT fk_objet_code FOREIGN KEY (objet_code) REFERENCES objet(code) ) ENG' at line 6 sql code is CREATE TABLE IF NOT EXISTS `class` ( `numero` int(11) NOT NULL AUTO_INCREMENT, `type_class` varchar(100) DEFAULT NULL, `images` varchar(200) NOT NULL, PRIMARY KEY (`numero`) CONSTRAINT fk_objet_code FOREIGN KEY (objet_code) REFERENCES objet(code) ) ENGINE=InnoDB;;

    Read the article

  • Sql statement return with zero result [closed]

    - by foodil
    I am trying to choose the row where 1)list.ispublic = 1 2)userlist.userid='aaa' AND userlist.listid=list.listid I need 1)+2) There is a row already but this statement can not get that row, is there any problem? List table: ListID ListName Creator IsRemindSub IsRemindUnSub IsPublic CreateDate LastModified Reminder 1 test2 aaa 0 0 1 2012-03-09 NULL NULL user_list table (No row): UserID ListID UserRights My test version SELECT l.*, ul.* FROM list l INNER JOIN user_list ul ON ul.ListID = l.ListID WHERE l.IsPublic = 1 AND ul.UserID = 'aaa' There is zero result. How can I fix that?

    Read the article

  • Stairway to T-SQL DML Level 9: Adding Records to a table using INSERT Statement

    Not all applications are limited to only retrieving data from a database. Your application might need to insert, update or delete data as well. In this article, I will be discussing various ways to insert data into a table using an INSERT statement. Need to share database changes?Keep database dev teams in sync using your version control system and the SSMS plug-in SQL Source Control. Learn more.

    Read the article

  • SQL: Using a CASE Statement to update a 1000 rows at once, how??

    - by SoLoGHoST
    Ok, I would like to use a CASE STATEMENT for this, but I am lost with this. Basically, I need to update a ton of rows, but just on the "position" column. I need to update all "position" values from 0 - count(position) for each id_layout_position column per id_layout column. Here's what I got for a regular update, but I don't wanna throw this into a foreach loop, as it would take forever to do it. I'm using SMF (Simple Machines Forums), so it might look a little different, but the idea is the same, and CASE statements are supported... $smcFunc['db_query']('', ' UPDATE {db_prefix}dp_positions SET position = {int:position} WHERE id_layout_position = {int:id_layout_position} AND id_layout = {int:id_layout}', array( 'position' => $position++, 'id_layout_position' => (int) $id_layout_position, 'id_layout' => (int) $id_layout, ) ); Anyways, I need to apply some sort of CASE on this so that I can auto-increment by 1 all values that it finds and update to the next possible value. I know I'm doing this wrong, even in this QUERY. But I'm totally lost when it comes to CASES. Here's an example of a CASE being used within SMF, so you can see this and hopefully relate: $conditions = ''; foreach ($postgroups as $id => $min_posts) { $conditions .= ' WHEN posts >= ' . $min_posts . (!empty($lastMin) ? ' AND posts <= ' . $lastMin : '') . ' THEN ' . $id; $lastMin = $min_posts; } // A big fat CASE WHEN... END is faster than a zillion UPDATE's ;). $smcFunc['db_query']('', ' UPDATE {db_prefix}members SET id_post_group = CASE ' . $conditions . ' ELSE 0 END' . ($parameter1 != null ? ' WHERE ' . (is_array($parameter1) ? 'id_member IN ({array_int:members})' : 'id_member = {int:members}') : ''), array( 'members' => $parameter1, ) ); Before I do the update, I actually have a SELECT which throws everything I need into arrays like so: $disabled_sections = array(); $positions = array(); while ($row = $smcFunc['db_fetch_assoc']($request)) { if (!isset($disabled_sections[$row['id_group']][$row['id_layout']])) $disabled_sections[$row['id_group']][$row['id_layout']] = array( 'info' => $module_info[$name], 'id_layout_position' => $row['id_layout_position'] ); // Increment the positions... if (!is_null($row['position'])) { if (!isset($positions[$row['id_layout']][$row['id_layout_position']])) $positions[$row['id_layout']][$row['id_layout_position']] = 1; else $positions[$row['id_layout']][$row['id_layout_position']]++; } else $positions[$row['id_layout']][$row['id_layout_position']] = 0; } Thanks, I know if anyone can help me here it's definitely you guys and gals... Anyways, here is my question: How do I use a CASE statement in the first code example, so that I can update all of the rows in the position column from 0 - total # of rows found, that have that id_layout value and that id_layout_position value, and continue this for all different id_layout values in that table? Can I use the arrays above somehow? I'm sure I'll have to use the id_layout and id_layout_position values for this right? But how can I do this?

    Read the article

  • Can/Should you throw exceptions in a c# switch statement?

    - by Kettenbach
    Hi All, I have an insert query that returns an int. Based on that int I may wish to throw an exception. Is this appropriate to do within a switch statement? switch (result) { case D_USER_NOT_FOUND: throw new ClientException(string.Format("D User Name: {0} , was not found.", dTbx.Text)); case C_USER_NOT_FOUND: throw new ClientException(string.Format("C User Name: {0} , was not found.", cTbx.Text)); case D_USER_ALREADY_MAPPED: throw new ClientException(string.Format("D User Name: {0} , is already mapped.", dTbx.Text)); case C_USER_ALREADY_MAPPED: throw new ClientException(string.Format("C User Name: {0} , is already mapped.", cTbx.Text)); default: break; } I normally add break statements to switches but they will not be hit. Is this a bad design? Please share any opinions/suggestions with me. Thanks, ~ck in San Diego

    Read the article

  • How to create select SQL statement that would produce "merged" dataset from two tables(Oracle DBMS)?

    - by Roman Kagan
    Here's my original question: merging two data sets Unfortunately I omitted some intircacies, that I'd like to elaborate here. So I have two tables events_source_1 and events_source_2 tables. I have to produce the data set from those tables into resultant dataset (that I'd be able to insert into third table, but that's irrelevant). events_source_1 contain historic event data and I have to do get the most recent event (for such I'm doing the following: select event_type,b,c,max(event_date),null next_event_date from events_source_1 group by event_type,b,c,event_date,null events_source_2 contain the future event data and I have to do the following: select event_type,b,c,null event_date, next_event_date from events_source_2 where b>sysdate; How to put outer join statement to fill the void (i.e. when same event_type,b,c found from event_source_2 then next_event_date will be filled with the first date found GREATLY APPRECIATE FOR YOUR HELP IN ADVANCE.

    Read the article

  • Declare 2 types inside using statement gives compile error?

    - by citronas
    I want to use this line of code: using (ADataContext _dc = new ADataContext(ConnectionString), BDataContext _dc2 = new BrDataContext(ConnectionString)){ // ...} This gives a compile error: Cannot use more than one type in a for, using, fixed or declartion statement. I thought this was possible? MSDN says it is: http://msdn.microsoft.com/en-us/library/yh598w02%28VS.80%29.aspx In the MSDN sample code Font is used, which is class and thereby a reference type as well as my two DataContext classes. What went wrong here? How does my attempt differ from the MSDN sample?

    Read the article

  • C++ Long switch statement or look up with a map?

    - by Rachel
    In my C++ application, I have some values that act as codes to represent other values. To translate the codes, I've been debating between using a switch statement or an stl map. The switch would look something like this: int code; int value; switch(code) { case 1: value = 10; break; case 2: value = 15; break; } The map would be an stl::map<int, int> and translation would be a simple lookup with the code used as the key value. Which one is better/more efficient/cleaner/accepted? Why?

    Read the article

  • Is it bad practice to change state inside of an if statement?

    - by Benjamin
    I wrote some code that looks similar to the following: String SKIP_FIRST = "foo"; String SKIP_SECOND = "foo/bar"; int skipFooBarIndex(String[] list){ int index; if (list.length >= (index = 1) && list[0].equals(SKIP_FIRST) || list.length >= (index = 2) && (list[0] + "/" + list[1]).equals(SKIP_SECOND)){ return index; } return 0; } String[] myArray = "foo/bar/apples/peaches/cherries".split("/"); print(skipFooBarIndex(myArray); This changes state inside of the if statement by assigning index. However, my coworkers disliked this very much. Is this a harmful practice? Is there any reason to do it?

    Read the article

  • Why only the constant expression can be used as case expression in Switch statement?

    - by sinec
    Hi, what is bothering me is that I can't found an info regarding the question from the title. I found that assembly form the Switch-case statement is compiled into bunch of (MS VC 2008 compiler) cmp and je calls: 0041250C mov eax,dword ptr [i] 0041250F mov dword ptr [ebp-100h],eax 00412515 cmp dword ptr [ebp-100h],1 0041251C je wmain+52h (412532h) 0041251E cmp dword ptr [ebp-100h],2 00412525 je wmain+5Bh (41253Bh) 00412527 cmp dword ptr [ebp-100h],3 0041252E je wmain+64h (412544h) 00412530 jmp wmain+6Bh (41254Bh) where for above code will in case that if condition (i) is equal to 2, jump to address 41253Bh and do execution form there (at 41253Bh starts the code for 'case 2:' block) What I don't understand is why in case that,for instance, function is used as 'case expression', why first function couldn't be evaluated and then its result compared with the condition? Am I missing something? Thank you in advance

    Read the article

  • Is it a good idea to define a variable in a local block for a case of a switch statement?

    - by Paperflyer
    I have a rather long switch-case statement. Some of the cases are really short and trivial. A few are longer and need some variables that are never used anywhere else, like this: switch (action) { case kSimpleAction: // Do something simple break; case kComplexAction: { int specialVariable = 5; // Do something complex with specialVariable } break; } The alternative would be to declare that variable before going into the switch like this: int specialVariable = 5; switch (action) { case kSimpleAction: // Do something simple break; case kComplexAction: // Do something complex with specialVariable break; } This can get rather confusing since it is not clear to which case the variable belongs and it uses some unnecessary memory. However, I have never seen this usage anywhere else. Do you think it is a good idea to declare variables locally in a block for a single case?

    Read the article

  • Why "constructor-way" of declaring variable in "for-loop" allowed but in "if-statement" not allowed?

    - by PiotrNycz
    Consider this simple example: /*1*/ int main() { /*2*/ for (int i(7); i;){break;} /*3*/ if (int i(7)) {} /*4*/ } Why line-2 compiles just fine, whilst line-3 gives the error? This is little strange to me why if-statement is in this aspect treated worse than for-loop? If this is compiler specific - I tested with gcc-4.5.1: prog.cpp: In function 'int main()': prog.cpp:3:7: error: expected primary-expression before 'int' prog.cpp:3:7: error: expected ')' before 'int' I was inspired by this question [UPDATE] I know this compiles just fine: /*1*/ int main() { /*2*/ for (int i = 7; i;){break;} /*3*/ if (int i = 7) {} /*4*/ }

    Read the article

  • How To Run Chrome OS in VirtualBox and Try Out Chrome OS Before Buying a Chromebook

    - by Chris Hoffman
    With Google’s new Chromebooks out at just $249, many people who once wrote them off as too expensive for their limited functionality are giving them a second look. But will you really find Chrome OS useful? You can easily run Chrome OS in a VirtualBox virtual machine, although you’ll need to tweak a few settings before it will run properly. Once you have, you can run Chrome OS in a window on your computer. How To Play DVDs on Windows 8 6 Start Menu Replacements for Windows 8 What Is the Purpose of the “Do Not Cover This Hole” Hole on Hard Drives?

    Read the article

  • My Ubuntu Touch seems to be broken no matter how many different files I try

    - by zeokila
    So I'm planning on testing out Ubuntu Touch, and developing some applications for it so I thought I would flash it to my Nexus 4 that was already unlocked, and running Paranoid Android and the kernel associated. I headed to Ubuntu's website, browsed around and came across this page: Touch/Install - Ubuntu Wiki I followed Step 1 perfectly, word by word. Its seems to me that everything on that part is fine. I skipped Step 2 having already done that for Paranoid Android, and then I follow 3 and 4 word to word also. Using the command phablet-flash -b everything seemed to be fine. So it booted up and all seemed normal, but it wasn't. Here are some major bugs that only seem to happen to me. So I was greeted with a normal lock screen: But one of the first noticable things on the home screen is that I only have 4 tabs, not 5: Some of the applications that are supposed to work do not (I know some are dummies) like here with the calculator, this is what I get: On the homescreen it is a black box, it will crash a couple of seconds later: Another annoying problem is that when I want to close apps, I have from right to left, if I close an app on the left first it will close it, but it will open the app to it's right, weird: Yet another bug, this one is in the pull down drawer, when you just click on it, you can see that not all the icons are there: Pretty much everything else works as it should, but my main problem is that there is no telephony, I'm not sure how it works exactly, but I'm never asked a SIM code (I'm guessing you need that?), I can't compose SMS's and can't dial numbers, it won't let me select the 'Send' or 'Call' button. I've after tried manual installs all over the place with these files: http://cdimage.ubuntu.com/ubuntu-touch-preview/daily-preinstalled/current/saucy-preinstalled-armel+mako.zip (Says 44MB on site - 46.6MB on my laptop) http://cdimage.ubuntu.com/ubuntu-touch-preview/daily-preinstalled/current/saucy-preinstalled-phablet-armhf.zip (Says 366MB on site - 383.2MB on my laptop) There are some weird size differences between what the site told me and what I downloaded, but I've tried re-downloading just to end up with the same file. And it just alway ends up with the same problems. No telephony and those weird bugs. So my question is, how the hell can I get the same version as everyone else, with the ability to send texts and call and open the calculator and more? Also, definitely running saucy: And maybe useful? This is what's in the device info:

    Read the article

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