Search Results

Search found 8673 results on 347 pages for 'kvm switch'.

Page 38/347 | < Previous Page | 34 35 36 37 38 39 40 41 42 43 44 45  | Next Page >

  • PHP 5.2.12 - Interesting Switch Statement Bug With Integers and Strings

    - by Levi Hackwith
    <?php $var = 0; switch($var) { case "a": echo "I think var is a"; break; case "b": echo "I think var is b"; break; case "c": echo "I think var is c"; break; default: echo "I know var is $var"; break; } ?> Maybe someone else will find this fascinating and have an answer. If you run this, it outputs I think the var is a when clearly it's 0. Now, I'm most certain this has something to do with the fact that we're using strings in our switch statement but the variable we're checking is an integer. Does anyone know why PHP behaves this way? It's nothing too major, but it did give me a bit of a headache today. Thanks folks!

    Read the article

  • free switch : what is tls_port ?

    - by kiruthika
    Hi all, I am beginner to free switch.I have gone through the configuration file vars.xml in free switch. In this I have seen the following configurations. <X-PRE-PROCESS cmd="set" data="internal_auth_calls=true"/> <X-PRE-PROCESS cmd="set" data="internal_sip_port=5070"/> <X-PRE-PROCESS cmd="set" data="internal_tls_port=5071"/> <X-PRE-PROCESS cmd="set" data="internal_ssl_enable=false"/> <X-PRE-PROCESS cmd="set" data="internal_ssl_dir=$${base_dir}/conf/ssl"/> In the above I am having the doubt with tls_port. What is the use of tls_port .I have searched about this in net and I have read that tls protocol is used for secure data transfer in network. So please explain me about the communication in freeswitch. Thanks in advance.

    Read the article

  • If-elseif-else Logic Question

    - by Changeling
    I have a set of three values, call them x, y, and z. If value A happens to match only one in the set x, y, and z, then that means we have a proper match and we stop searching for a match, even if it is at y. It can match any one in that set. These values x, y, and z are non-constant so I cannot use a switch-case statement. How do I do this with an if-elseif-else statements without having to use GOTO. I am using C++ (no boost or any of that other fancy stuff). Now, I am trying to do this in code and it is racking my brain this morning (not enough coffee?)

    Read the article

  • iPhone switch statement using enum

    - by Boris
    I have defined an enum in a header file of a class : typedef enum{ RED = 0, BLUE, Green } Colors; - (void) switchTest:(Colors)testColor; and in the implementation file I have : - (void) switchTest:(Colors)testColor{ if(testColor == RED){ NSLog(@"Red selected"); } switch(testColor){ case RED: NSLog(@"Red selected again !"); break; default: NSLog(@"default selected"); break; } } My code compiles correctly without warrnings. When calling the switchTest method with RED, the output is : "Red selected" but once the first line of the switch runs, the application quits unexpectedly and without warrnings/errors. I don't mind using if/else syntax but I would like to understand my mistake.

    Read the article

  • Switch case assembly level code

    - by puffadder
    Hi All, I am programming C on cygwin windows. After having done a bit of C programming and getting comfortable with the language, I wanted to look under the hood and see what the compiler is doing for the code that I write. So I wrote down a code block containing switch case statements and converted them into assembly using: gcc -S foo.c Here is the C source: switch(i) { case 1: { printf("Case 1\n"); break; } case 2: { printf("Case 2\n"); break; } case 3: { printf("Case 3\n"); break; } case 4: { printf("Case 4\n"); break; } case 5: { printf("Case 5\n"); break; } case 6: { printf("Case 6\n"); break; } case 7: { printf("Case 7\n"); break; } case 8: { printf("Case 8\n"); break; } case 9: { printf("Case 9\n"); break; } case 10: { printf("Case 10\n"); break; } default: { printf("Nothing\n"); break; } } Now the resultant assembly for the same is: movl $5, -4(%ebp) cmpl $10, -4(%ebp) ja L13 movl -4(%ebp), %eax sall $2, %eax movl L14(%eax), %eax jmp *%eax .section .rdata,"dr" .align 4 L14: .long L13 .long L3 .long L4 .long L5 .long L6 .long L7 .long L8 .long L9 .long L10 .long L11 .long L12 .text L3: movl $LC0, (%esp) call _printf jmp L2 L4: movl $LC1, (%esp) call _printf jmp L2 L5: movl $LC2, (%esp) call _printf jmp L2 L6: movl $LC3, (%esp) call _printf jmp L2 L7: movl $LC4, (%esp) call _printf jmp L2 L8: movl $LC5, (%esp) call _printf jmp L2 L9: movl $LC6, (%esp) call _printf jmp L2 L10: movl $LC7, (%esp) call _printf jmp L2 L11: movl $LC8, (%esp) call _printf jmp L2 L12: movl $LC9, (%esp) call _printf jmp L2 L13: movl $LC10, (%esp) call _printf L2: Now, in the assembly, the code is first checking the last case (i.e. case 10) first. This is very strange. And then it is copying 'i' into 'eax' and doing things that are beyond me. I have heard that the compiler implements some jump table for switch..case. Is it what this code is doing? Or what is it doing and why? Because in case of less number of cases, the code is pretty similar to that generated for if...else ladder, but when number of cases increases, this unusual-looking implementation is seen. Thanks in advance.

    Read the article

  • How do I switch between Navigation Controllers?

    - by RexOnRoids
    Situation: I have an Xcode project based on the "Navigation-Based-Application" template. So that means I have a SINGLE UINavigationController that manages a UIViewController. What I want To Do: What I want to do is add one more UINavigationController to my project -- and be able to switch back and forth between them. (I want to do this to make space for some seperate unrelated content so that it does not have a back button pointing back to the root view controller.) Question: How do I add one more UINavigationController to my project and switch between the two UINavigationControllers?

    Read the article

  • Switch case in jquery

    - by Jasl
    Am I writing the correct switch case? var cnt = $("#div1 p").length; alert(cnt); switch (cnt) { case (cnt >= 10 && cnt <= 20): alert('10'); break; case (cnt >= 21 && cnt <= 30): alert('21'); break; case (cnt >= 31 && cnt <= 40): alert('31'); break; default: alert('>41'); } For some reason, the alert does not occur when the conditions are matched!

    Read the article

  • why switch will expect statement before loading nib

    - by kiran kumar
    In Switch statement Example switch (indexPath.row) case 0: Loading my nib file; break; case 1: Loading another nib file; break default: break ........ Before loading my nib file. It expects any one statement. example case 0: NSLog(@""); Loading Nib file.... My its expect the statement NSLog(@"");....... If i need not put NSLog... or any other statement its gives me error..... I want to know why its like that.

    Read the article

  • Python comparing string against several regular expressions

    - by maerics
    I'm pretty experienced with Perl and Ruby but new to Python so I'm hoping someone can show me the Pythonic way to accomplish the following task. I want to compare several lines against multiple regular expressions and retrieve the matching group. In Ruby it would be something like this: STDIN.each_line do |line| case line when /^A:(.*?)$/ then puts "FOO: #{$1}" when /^B:(.*?)$/ then puts "BAR: #{$1}" # when ... else puts "NO MATCH: #{line}" end end My attempts in Python are turning out pretty ugly because the matching group is returned from a call to match/search on a regular expression and Python has no assignment in conditionals or switch statements. What's the Pythonic way to do (or think!) about this problem?

    Read the article

  • Switch to BigInteger if necessary

    - by fahdshariff
    I am reading a text file which contains numbers in the range [1, 10^100]. I am then performing a sequence of arithmetic operations on each number. I would like to use a BigInteger only if the number is out of the int/long range. One approach would be to count how many digits there are in the string and switch to BigInteger if there are too many. Otherwise I'd just use primitive arithmetic as it is faster. Is there a better way? Is there any reason why Java could not do this automatically i.e. switch to BigInteger if an int was too small? This way we would not have to worry about overflows.

    Read the article

  • C#: reflection alternative for switch on enum in order to select namespace/class

    - by Am
    Hi, I have an interface named IHarvester. There are 3 implementations of that interface, each under their own namespace: Google Yahoo Bing A HarvesterManager uses the given harvester. It knows the interface and all 3 implementations. I want some way of letting the class user say in which harvester it wants to use. And in the code select that implementation, without a switch-case implementation. Can reflection save my day? Here is the code bits: // repeat for each harvester namespace Harvester.Google { public abstract class Fetcher : BaseHarvester, IInfoHarvester {...} } public enum HarvestingSource { Google, Yahoo, Bing, } class HarvesterManager { public HarvestingSource PreferedSource {get;set;} public HarvestSomthing() { switch (PreferedSource) .... // awful... } } Thanks.

    Read the article

  • Java Switch Incompatible Types Boolean Int

    - by ikurtz
    i have the following class: public class NewGameContract { public boolean HomeNewGame = false; public boolean AwayNewGame = false; public boolean GameContract(){ if (HomeNewGame && AwayNewGame){ return true; } else { return false; } } } when i try to use it like so: if (networkConnection){ connect4GameModel.newGameContract.HomeNewGame = true; boolean status = connect4GameModel.newGameContract.GameContract(); switch (status){ case true: break; case false: break; } return; } i am getting the error: incompatible types found: boolean required: int on the following switch (status) code. what am i doing wrong please?

    Read the article

  • Java application if/case recommendation

    - by Jesse
    I am writing an application for a Java course. I am a complete beginner and am just going off material I have learned from the course and from the web. The application is exhibiting some behavior and I am not sure what is causing it. The application is GUI based and does calculations on user input. For the action listener section, I have a set of If statements such as: "if this button do this if this button do this" All in a row like that. It seems as if the application is running ALL the if statements instead of running the one that corresponds with the button pressed. Would I be better off using a case/switch structure for this sort of thing? I can post my code if necessary, I am new around this site and am not sure if that thing is acceptable.

    Read the article

  • Is there a way to refactor this javascript/jquery?

    - by whyzee
    switch (options.effect) { case 'h-blinds-fadein': $('.child').each(function (i) { $(this).stop().css({opacity:0}).delay(100 * i).animate({ 'opacity': 1 }, { duration: options.speed, complete: (i !== r * c - 1) || function () { $(this).parent().replaceWith(prev); options.cp.bind('click',{effect: options.effect},options.ch); } }); }); break; case 'h-blinds-fadein-reverse': $('.child').each(function (i) { $(this).stop().css({opacity:0}).delay(100 * (r * c - i)).animate({ 'opacity': 1 }, { duration: options.speed, complete: (i !== 0) || function () { $(this).parent().replaceWith(prev); options.cp.bind('click',{effect: options.effect},options.ch); } }); }); break; ....more cases } I have alot of similiar other cases. One way i could think of is to write functions ? i'm not sure i'm still fairly new to the language

    Read the article

  • Tune cindent "switch" indentation

    - by Don Reba
    Nemerle is a C-like language and mostly works very well with cindent. However, its construct analogous to switch is called match: match (x) { | "Hello World" => ... | _ => ... } Is it possible to get the cinoptions for switch statements to apply to this construct, instead? Maybe there is a regular expression I can set somewhere. If not, can I get the vertical bars to align with the braces another way?

    Read the article

  • Eclipse bug? Switching on a null with only default case

    - by polygenelubricants
    I was experimenting with enum, and I found that the following compiles and runs fine on Eclipse (Build id: 20090920-1017, not sure exact compiler version): public class SwitchingOnAnull { enum X { ,; } public static void main(String[] args) { X x = null; switch(x) { default: System.out.println("Hello world!"); } } } When compiled and run with Eclipse, this prints "Hello world!" and exits normally. With the javac compiler, this throws a NullPointerException as expected. So is there a bug in Eclipse Java compiler?

    Read the article

  • Switch/Case statements in C++

    - by vgoklani
    Regarding the switch/case statement in the C++ code below: "Case 1" is obviously false, so how/why does it enter the do-while loop? #include <iostream> using namespace std; int main() { int test = 4; switch(test) { case 1: do { case 2: test++; case 3: test++; case 4: cout << "How did I get inside the do-while loop?" << endl; break; case 5: test++; } while(test > 0); cout << test << endl; } }

    Read the article

  • Switch role after connecting to database

    - by Chris Gow
    Is it possible to change the postgresql role a user is using when interacting with postgres after the initial connection? The database(s) will be used in a web application and I'd like to employ database level rules on tables and schemas with connection pooling. From reading the postgresql documentation it appears I can switch roles if I originally connect as a user with the superuser role, but I would prefer to initially connect as a user with minimal permissions and switch as necessary. Having to specify the user's password when switching would be fine (in fact I'd prefer it). What am I missing?

    Read the article

  • can I put the break on the same line

    - by brett
    I have a switch statement that has over 300 case statements. case 'hello': { $say = 'some text'; } break; case 'hi': { $say = 'some text'; } break; Why is it that the break is always on a separate line? Is this required? Is there anything syntactically incorrect about me doing this: case 'hello': { $say = 'some text'; } break; case 'hi': { $say = 'some text'; } break;

    Read the article

  • c# converting select case VBA to c# SWITCH

    - by herrow
    i have some vba code that i need to convert to c# Select Case letter0 Case "A01" Cells(rownum, 2).Value = "1" Case "B01" Cells(rownum, 2).Value = "2" Case "C01" Cells(rownum, 2).Value = "3" Case "D01" Cells(rownum, 2).Value = "4" Case "E01" Cells(rownum, 2).Value = "5" Case "F01" Cells(rownum, 2).Value = "6" Case "G01" Cells(rownum, 2).Value = "7" Case "H01" Cells(rownum, 2).Value = "8" Case "A02" Cells(rownum, 2).Value = "9" Case "B02" ... .. i understand how to do a switch on this, but is there an easier method? i will not be checking CELLS(rownum.........) instead of will be doing switch(somestring) is there an easier way to do this than explicitly write every single case?

    Read the article

  • Reflection alternative for switch on enum in order to select namespace/class

    - by Am
    Hi, I have an interface named IHarvester. There are 3 implementations of that interface, each under their own namespace: Google Yahoo Bing A HarvesterManager uses the given harvester. It knows the interface and all 3 implementations. I want some way of letting the class user say in which harvester it wants to use. And in the code select that implementation, without a switch-case implementation. Can reflection save my day? Here is the code bits: // repeat for each harvester namespace Harvester.Google { public abstract class Fetcher : BaseHarvester, IInfoHarvester {...} } public enum HarvestingSource { Google, Yahoo, Bing, } class HarvesterManager { public HarvestingSource PreferedSource {get;set;} public HarvestSomthing() { switch (PreferedSource) .... // awful... } } Thanks. I will give my 2 cents of why I want to change this. There several people writing harvesters, I want them to focus only on building more harvesters, without ever needing to update the enum, or at worst, update only the enum.

    Read the article

  • Programmatically get valid switch/case values

    - by craigim
    When MATLAB scans through cases in a switch/case block, does it remember the values that it skips, and is it possible to access that list? I have a few functions with long switch\case block and I would like to have them return a list of valid case values if they make it down to otherwise. For instance, I have a function that returns a set of optical constants for a material. It currently has about 20 different materials and it is growing as I consider new ones. I realize I can brute-force it and just re-type all of the valid cases into a cell array under otherwise and have the function throw an error and return the list of valid responses, but maintaining both lists without errors or laziness creeping in over time is challenging.

    Read the article

  • Iterate through main function in C?

    - by Mohit Deshpande
    Here is my main function: int main(int argc, char **argv) { LoadFile(); Node *temp; char *key; switch (GetUserInput()) { case 1: temp = malloc(sizeof(Node)); printf("\nEnter the key of the new node: "); scanf("%s", temp->key); printf("\nEnter the value of the new node: "); scanf("%s", temp->value); AddNode(temp); free(temp); break; case 2: key = malloc(sizeof(char *)); printf("Enter the key of the node you want to delete: "); scanf("%s", key); DeleteNode(key); free(key); break; case 3: PrintAll(); break; case 4: SaveFile(); break; case 5: return 0; break; default: printf("\nWrong choice!\n"); break; } return 0; } The only problem with it is that after any case statement breaks, the program just exits out. I understand why, but I don't know how to fix it. I want the program to repeat itself each time even after the case statements. Would I just say: main(argc, argv); before every break statement?

    Read the article

  • Finding part of a string that a user has sent via POST

    - by blerh
    My users can send links from popular file hosts like Rapidshare, Megaupload, Hotfile and FileFactory. I need to somehow find out what filehost they sent the link from and use the correct class for it appropriately. For example, if I sent a Rapidshare link in a form on my web page, I need to somehow cycle through each file host that I allow until I find the text rapidshare.com, then I know the user has posted a Rapidshare link. Perhaps a PHP example: switch($_POST['link']) { case strstr($_POST['link'], 'rapidshare.com'): // the link is a Rapidshare one break; case strstr($_POST['link'], 'megaupload.com'): // the link is a Megaupload one break; case strstr($_POST['link'], 'hotfile.com'): // the link is a Hotfile one break; case strstr($_POST['link'], 'filefactory.com'): // the link is a Filefactory one break; } However, I know for a fact this isn't correct and I'd rather not use a huge IF statement if I can help it. Does anyone have any solution to this problem? If you need me to explain more I can try, English isn't my native language so it's kinda hard. Thanks all.

    Read the article

< Previous Page | 34 35 36 37 38 39 40 41 42 43 44 45  | Next Page >