w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to exit if statement and continue to else
try { //do method one //error occurs during method one, need to exit and continue to else if ($condition != "good") { throw new Exception('foo'); } } catch (Exception $e) { //do method two }

Categories : PHP

How to exit pdb and allow program to continue?
continue should "Continue execution, only stop when a breakpoint is encountered", so you've got a breakpoint set somewhere. To remove the breakpoint (if you inserted it manually): (Pdb) break Num Type Disp Enb Where 1 breakpoint keep yes at /path/to/test.py:5 (Pdb) clear 1 Deleted breakpoint 1 (Pdb) continue Or, if you're using pdb.set_trace(), you can try this (although if you're using pdb in more fancy ways, this may break things...) (Pdb) pdb.set_trace = lambda: None # This replaces the set_trace() function! (Pdb) continue # No more breaks!

Categories : Python

Threads and Interrupts: Continue or exit?
I guess the answer depends on why you are being interrupted? Often threads are interrupted because some other process/thread is trying to cancel or kill it. In those cases, stopping is appropriate. Perhaps when interrupted, you send out all remaining messages and don't accept new ones?

Categories : Java

Conditionally exit or continue the loop in vb.net
Use the Split method to create an array of sentences. It will accept an array of delimiters. Iterate through the array and pass each sentence and the index of the sentence, to your sub routine. In your sub routine add an integer argument to use as the sentence number, and change the output string. Something like this: Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim Sentences() As String = TextBox1.Text.Split({","c,"."c}) For I = 0 to Sentences.Count-1 Calculate(Sentences(I), I+1) Next End Sub Private Sub Calculate(ByVal input As String, ByVal index As Integer) Dim total As Integer = 0 Dim wordTotal As Integer Dim dicLetters As New Dictionary(Of Char, Integer) dicLetters.Add("A", 20) dicLetters.Add("B", 30)

Categories : Vb.Net

process.WaitForExit() never getting exit signal. Does not continue through program
cmd /k ... will launch a command prompt, run the specified command, then leave the command prompt open forever (to accept new commands). Therefore, the process will never exit. You should run your command directly, or use cmd /c.

Categories : C#

How to exit hotkey function and continue the script (AutoHotKey)?
The easiest way is to put the script in a separate file and run it as an external program. Use #SingleInstance Force to be sure only one copy is running, and if you want to kill it use Process, Close with the PID you can get back from the Run statement. I do this all the time with long complicated scripts that fail frequently. I mostly do that so if the script fails I just hit the hotkey again to restart. It kills the first instance and restarts. Interrupting a running script is just another special case. Note that you'll need to run AutoHotkey.exe and pass the name of the script and any parameters. Don't try to run the script itself.

Categories : Misc

Scala, how to access the whole match: X match {case Y(z) as matched =>
You should be able to use the @ syntax: x match { case matched @ Y(z) => // do stuff both with "matched" and "z" here ... ... } From here

Categories : Scala

C/C++ how to run the same switch case till its condition is true and continue with out crashing?
While in C works just like while does in Java. You wrap a section of code with while, and whatever is inside it gets run until the condition is false. However, your scanf is wrong: scanf("%i", tempyear); It should be: scanf("%i", &tempyear); ^ Note the &, which means "pass the address of this variable".

Categories : C

How to exit a console app in C using switch case?
You could call exit() passing the return value as a parameter, this return value can be checked by the calling process / batch file: exit(EXIT_SUCCESS); // = 0 = (standard) success or exit(EXIT_FAILURE); // = 1 = (standard) failure or exit(123); // return a specific value Documentation for MS-Visual Stuidio

Categories : C

Ruby/Thor exit status in case of an error
Good question. I also noticed this when looking a thor to use for a project. As far as I can tell this is expected behavior. This pull request for bundler has an interesting solution that may be appropriate for you. They enabled the thor debug flag so they could catch the error and set the appropriate exit status # bin/bundle Bundler.with_friendly_errors { # Set debug flag so we can rescue Thor::error's # and set the correct exit code. ENV["THOR_DEBUG"] = "1" Bundler::CLI.start } # friendly_errors rescue Thor::UndefinedCommandError => e Bundler.ui.error e.message exit 15 rescue Thor::Error => e Bundler.ui.error e.message exit 1

Categories : Ruby

Continuous input to switch case until i press exit c#
You can just place your code into a loop, and change the return to break statements: while(true) // Loop forever { string strReadKey = Console.ReadKey().KeyChar.ToString(); int.TryParse(strReadKey, out selectionKey); switch (selectionKey) { case 1: DoApps(reqObj); break; // Break, don't return case 2: DoDrivers(reqObj); break; case 3: DoOS(reqObj); break; case 4: DoPackages(reqObj); break; case 5: DoAll(reqObj); break; case 6: Environment.Exit(0); break; default: DoAll(r

Categories : C#

Will Application.Exit() clear memory? Garbage Collector run after exit or before exit
One benefit to use a framework like NET is not to worry about these details. Of course you need to try to keep your memory usage low as possible, but the workload to free the MANAGED memory used by your application is a job reserved to the framework that will not stop to clean the memory references just because your application is terminated by Application.Exit() As for the code of Application.Exit() it is easy to find on internet private static bool ExitInternal() { bool flag = false; lock (internalSyncObject) { if (exiting) { return false; } exiting = true; try { if (forms != null) { foreach (Form form in OpenFormsInternal) { if (form.Raise

Categories : C#

Scala Set match case
Set defines an isEmpty method so the simplest solution is def test(originalSet: Set[Int]): Boolean = originalSet.isEmpty When you match against a List using list match { case Nil => true case x :: y => false } you are matching against the List Nil object and against the :: class i.e. it is equivalent to list match { case Nil => true case ::(x, y) => false } So you can't use this form with Set. When you pattern match against a List using: list match { case List(a, b) => true case _ => false } you are using the List extractor. The List extractor is defined using unapplySeq which matches if the list is of the given format. Set does not define an unapply or unapplySeq method, so you can't match against it in this way either.

Categories : Scala

What should I use the Non-greedy match in this case
Regex might be complicating this problem rather than simplifying it. A simple way to get an eighth item from a | delimited string is using split(): a = '|here|is|some|data|separated|by|bars|hooray!|' print a.split('|')[8] RETURNS hooray! Using regex, one way to get it would be: import re a = '|here|is|some|data|separated|by|bars|hooray!|' pattern = re.compile(r'([^|]+)') match = pattern.findall(a) print match[7] RETURNS hooray!

Categories : Python

How can I match case with shapeless variable?
There is method unapply in object shapeless.::: def unapply[H, T <: HList](x: H :: T): Option[(H, T)] So you could just match on HList like this: scala> val ::(a, ::(b, HNil)) = "1" :: "x" :: HNil a: String = 1 b: String = x Or with alternative syntax for unapply method with Tuple2 result: a :: b instead of ::(a, b): scala> val a :: b :: HNil = "1" :: "x" :: HNil a: String = 1 b: String = x scala> "1" :: "x" :: HNil match { | case a :: b :: HNil => s"$a :: $b :: HNil" | } res0: String = 1 :: x :: HNil In your case: authHeaders.hrequire{ case client_id :: client_secret :: HNil => isAuthorized(client_id, client_secret) } Alternative You could use tupled method to convert function of N arguments to function of single TupleN argument. For functio

Categories : Scala

Case-insensitive match with Boost Xpressive
Try to use boost::xpressive::sregex re = boost::xpressive::sregex_compiler(). compile("foo", boost::xpressive::icase); syntax_options_type (that is boost::xpressive::regex_constants::icase_) is not match_flag_type (3 argument for regex_match should have this type).

Categories : C++

In a vim syntax file, how can I have "syn match" act case-insensitively?
I found the following in the docs: syntax case ignore Maybe that helps. However, I think it applies to all the matching. Also, since /<AC>/$ is just a vim pattern, you should be able to use the standard "ignore case" directives c. The following should work: /c<AC>/$

Categories : Vim

Scala: returning results from a case match
def find(teamId: Int = 0) { = is missing, explaining why your method doesn't return anything (Unit). Should be: def find(teamId: Int = 0) = {

Categories : Scala

How can I match input in a case insensitive manner?
You can use if choice.lower() == 'north': level_01_room_02() (see str.lower())

Categories : Python

Yielding with For-loop and pass to match-case Expression
Just a few symbols away: for (f <- (new File(".")).listFiles() if !f.isDirectory) f match { case x:File => println(x.getAbsoluteFile) case _ => println(_) } The diff is yield f) { f In your case you're first processing (listing|filtering|yielding one-by-one) whole collection and only then match whole result.

Categories : Scala

Scala using regex with or syntax in match case statement
An "anchored" regex for pattern matching matches whole inputs: val aorb = ".*(a|b).*".r "with a " match { case aorb(_) => "have a or b" case _ => "None" } // res0: String = have a or b If you have capturing groups in your regex you should also use or explicitly ignore results: note _ in aorb(_).

Categories : Scala

preg_replace case insensitive using two arrays to replace the first match
Your first variable is not correct, if its an array each value needs to be a regex $arr = array('/(apple)/i', '/(lemon)/i'); $arr2 = array('APPLE', 'LEMON'); preg_replace($arr, $arr2, $string, 1); Edit: I updated this to include word boundries which may help in some instances

Categories : PHP

Regular expression to match a string in incorrect case
my $s = "Supermario"; if ($s =~ /supermario/i and $s !~ /SuperMario/) { print "wrong "; } Another method: /(?:[S](?!uperMario)|s)[Uu][Pp][eE][rR][mM][aA][Rr][iI][oO]/

Categories : Regex

Continue / break out of a loop, continue execution
I run select a little different. Perhaps not the "right" way, but works for me. Example select foo in higher lower do break done if [ $foo = higher ] then (( lb = k )) else (( ub = k )) fi Source

Categories : Bash

Checking for duplicate values across multiple fields with case-insensitive match
I tried to figure out the problem you encounter using the following: class Person < ActiveRecord::Base validates :name, presence: true validates :email, presence: true validates_uniqueness_of :name, :case_sensitive => false, :scope => [ :email ] validates_uniqueness_of :email, :case_sensitive => false, :scope => [ :name ] end and require 'spec_helper' describe Person do context 'with duplicate name and email' do before do @person1 = Person.new(name: 'test@example.com', email: 'TEST@EXAMPLE.COM') end subject { @person1 } it { should be_valid } describe '(I) for case-sensitive match of both' do before do person = @person1.dup person.save end it { should_not be_valid } end describe '(II) for

Categories : Ruby On Rails

JS match method with case insensitive doesn't work properly in IE/Chrome?
To make it work, you either need to write inline like this: /myphrase/gi or pass the RegExp object for phrase.match(), like below: var search = new RegExp(keyword[j], "gi"); phrase.match(search) ? match = true : match = false;

Categories : Javascript

How to match against the pattern of a partial function's case definition in a Scala macro?
First of all, there is a special flavor of quasiquotes specifically for CaseDefs called cq: override def transformCaseDefs(trees: List[CaseDef]) = trees map { case caseDef @ cq"$pattern if $guard => $body" => ... } Secondly, you should use pq to deconstruct patterns: pattern match { case pq"$name @ $nested" => ... case pq"$extractor($arg1, $arg2: _*)" => ... ... } If you are interested in internals of trees that are used for pattern matching they are created by patvarTransformer defined in TreeBuilder.scala On the other hand if you're are working with UnApply trees (that are being produced after typechecking) I have bad news for you: quasiquotes currently don't support them. Follow SI-7789 to get notified when this is fixed.

Categories : Scala

how to make a c console program exit with exit function?
exit causes your program to exit, not the shell that you ran it from. Your program is equivalent to: int main(void) { return 0; } You might want to look into kill(2). Editorial note: main should return int, not void.

Categories : C

Erlang gen_server process does not exit when it does not trap exit
I think it is because the process generated in rpc:multicall exited with the reason normal. When two processes are linked, if one of them exits with the reason normal, the other one without trap_exit won't exist. And when process_flag(trap_exit, true) is not commented, in the source code of gen_server.erl, we can see this: 346 decode_msg(Msg, Parent, Name, State, Mod, Time, Debug, Hib) -> 347 case Msg of 348 {system, From, Req} -> 349 sys:handle_system_msg(Req, From, Parent, ?MODULE, Debug, 350 [Name, State, Mod, Time], Hib); 351 {'EXIT', Parent, Reason} -> 352 terminate(Reason, Name, Msg, Mod, State, Debug); Gen_server will terminate automatically as long as its parent (The process which generates the gen_server

Categories : Linux

vb.net how to check case of label.text i.e lower case, upper case
isUpper and isLower apply to single characters within a string. I think a better solution is to create a temporary string that is formatted the way you want it and return the comparison. As an example (for ProperCase) If String.Format(yourString, vbStrConv.ProperCase) = yourString then 'your code for proper case End If With this, you should be able to get most of your comparisons going. As for toggle case, you are going to have to write an algorithm that does the string conversion for you. See http://www.codeproject.com/Tips/162540/Letter-Case-Conversion-Algorithms-Title-Case-Toggl for a fairly useful algorithm.

Categories : Vb.Net

Switch case, case was not found, but similar to the other case, give suggestion
I can point you in the right direction: http://php.net/manual/en/function.levenshtein.php Is a php function that can be used for your cause, there is a nice example on that page as well. A related stack overflow question has more info on when your strings are longer than 255 characters: String similarity in PHP: levenshtein like function for long strings

Categories : PHP

Bash exit doesn't exit
The while loops are running in their respective shells. Exiting one shell does not exit the containing ones. $? could be your friend here: ... echo "!!!!!!!!!!" exit 1 fi done [ $? == 1 ] && exit 0; done

Categories : Bash

Excel 2007 VBA MATCH function is not finding a match, but a match does exist in that range?
You must use MatchType of 0 to use wild card characters (* or ?) see: http://office.microsoft.com/en-001/excel-help/match-function-HP010062414.aspx Use Application.Match("More items related to*", Range("AZ1:AZ1000"), 0)

Categories : Excel

Remove value from array in match case with other array
Try this. $temp=array(); $arrayone= array([0]=>..,. ......, [40]=>...); foreach($arrayone as $key=>$val) { for($i=0;$i<count($arraytwo);$i++) { $pos = strpos($val, $arraytwo[$i]); if($pos === true) { $temp[$key] = $val; } } } $result = array_diff($arrayone,$temp); print_r($result);

Categories : PHP

Switch case with case 2 equal to case 1 plus case 0
why not something like this: function case0() { print '<tr>'; print '<td align="right">'; print "Sup:"; print '</td>'; print '<td>'; print $sup; print '</td>'; print '</tr>'; } function case1() { print '<tr>'; print '<td align="right">'; print "Inf:"; print '</td>'; print '<td>'; print $inf; print '</td>'; print '</tr>'; } switch($value) { case 0: case0(); break; case 1: case1(); break; case 2: case0(); case1(); break; }

Categories : PHP

Powershell -command's exit code is not the same as a script's exit code
If you look at the part you are sending to -Command as a script you will see it would never work. The script running the foo.ps1 script does not have an exit so it does not return an exit code. If you do return an exit code it will do what you want. Also change it from ' to ", otherwise $lastexitcode will be resolved before you 'send' the string to the second powershell if you run it from powershell. PS C: est> powershell -Command './foo.ps1; exit $LASTEXITCODE' PS C: est> echo $lastexitcode 42 PS: Also check out the -File parameter if you just want to run a script. But also know it does not return 1 if you have a terminating error as -Command does. See here for more on that last topic. PS C: est> powershell -File './foo.ps1' PS C: est> echo $lastexitcode 42

Categories : Powershell

how can I exit from the app without clicking on exit
U want once u saved the details after that u want to open a new activity i hope .See this i have also done the same thing it will help u public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); SharedPreferences shared = getSharedPreferences("shared", MODE_PRIVATE); if(shared.contains("username") && shared.contains("password")){ startingActivity(); } else { //What u want to do here }

Categories : Android

When i use Activity in camel case it gives error but works fine in upper case spelled
You probably want to be defining an intent for a specific component: Intent startUpIntent = new Intent(Startup.this, MainActivity.class); Then you don't need to bother with an <intent-filter> for MainActivity in your manifest.

Categories : Android

This code snippet is not working for both upper case and lower case letters
This modified code will work: def scrabble_score(word): count=0 word = word.lower() #assign the result of word.lower() to word word.lower() returns the modified word, it doesn't modify the string inplace. Strings are immutable in Python. The fact that .lower() returns a string is defined as such: >>> help(str.lower) Help on method_descriptor: lower(...) S.lower() -> string Return a copy of the string S converted to lowercase.

Categories : Python

Making id case-insensitive but case-preserving in endpoints-proto-datastore
Your setter is being called, and it is causing the behavior you don't want. Tearing it down: def IdSet(self, value): if not isinstance(value, basestring): raise TypeError('ID must be a string.') self.caseful_id = value self.UpdateFromKey(ndb.Key(self.__class__, value.lower())) since you call self.caseful_id = value before UpdateFromKey, the caseful_id will always be the one from the most recent request. Bear in mind that UpdateFromKey tries to retrieve an entity by that key and then patches in any missing data from the entity stored in the datastore (and also sets from_datastore to True). Since you set the caseful_id field before UpdateFromKey, there is no missing data. Instead, you could do this to set the value if not already set (and so this wouldn't be relev

Categories : Python



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