goto

Best practice for using goto

▼魔方 西西 提交于 2019-12-10 13:18:51
问题 Is it right to use goto in this code? Are there any alternatives? return ExecuteReader(cmd, reader => { List<BEPartnership> partnerhip = null; //Partnership if (!((SqlDataReader) reader).HasRows) goto exit; partnerhip = new List<BEPartnership>{new BEPartnership().GetFromReader(reader)}; //Customers if (!reader.NextResult() && !((SqlDataReader) reader).HasRows) goto exit; foreach (BEPartnership p in partnerhip) p.Partner = new BECustomer().GetFromReader(reader); //Contracts if (!reader

check if a button is available? if not wait 5 seconds and check again?

血红的双手。 提交于 2019-12-10 09:25:51
问题 Basically I'm trying to see if a button is able to be clicked at the moment. If not I would like to try again. So I need some kind of a goto function to return to an earlier line of my code. Although I suspect I written this extremely poorly and it could have been done much easier. try { driver.findElement(By.xpath("//button[@id='btn_ok']")).click(); }catch (Exception e) { driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); } for context, here is the button culprit in question.

Are goto statements efficient when compared to calling functions? [closed]

纵然是瞬间 提交于 2019-12-09 18:33:47
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . I have the following code in C++ here: #include <iostream> int main(int argc, const char * argv[]) { goto line2; line1: std::cout <<

What could be the substitute to handle the flow control of go-to in SHELL script [duplicate]

↘锁芯ラ 提交于 2019-12-08 14:15:54
问题 This question already has answers here : Is there a “goto” statement in bash? (12 answers) Closed 3 years ago . We do not have any goto statement in bash, hence I used the below function to implement goto for abrupt jump in the code. Can we handle this condition without using jumpto function? Based on the solution in this earlier answer to a related question I have the following code: #!/bin/bash function jumpto { label=$1 cmd=$(sed -n "/$label:/{:a;n;p;ba};" $0 | grep -v ':$') eval "$cmd"

Go to in Python 3

旧城冷巷雨未停 提交于 2019-12-08 09:46:02
问题 Python 3 have no GOTO or something like this. But I have some algoritm, that need GOTO type functionality. May be someone can suggest way out? Main menu 1-New Game 2-Options 3-Exit User actions - enter to main menu - enter to options menu - enter to main menu AGAIN and so on. So in code I don't know how turn back and teleport to upper code with main menu. 回答1: You could use a dictionary: 'user choice' -> 'corresponding action' e.g.: import sys def foo(): print('foo') actions = {'1': foo, '2':

Batch file goto not working in for loop

最后都变了- 提交于 2019-12-08 08:16:53
问题 I have a for loop in my batch file that loops through folders. I want to skip particular folders. I can do this with an IF statement, but would prefer a GOTO like I'm showing below. for /d %%F in (*) do ( if /i "%%F"=="Archive" goto nextFolder REM do stuff here :nextFolder ) But the above is giving me errors: ) was unexpected at this time 回答1: This won't work - you can't jump into a control-flow construct and expect everything to be fine. Please take a look at (Windows batch) Goto within if

Java JTable Goto Row Bug

北城余情 提交于 2019-12-08 04:34:37
问题 I have a find function that locates a string in a JTable with quite a few thousand entries. Michael Meyers was kind enough to help me out with the goto portion of the function. There appears to be a bug though... When the user searches for the string the application correctly finds the line in the JTable and highlights it. It also attempts to focus on it, but does not always. Sometimes it will jump 10+ lines short of the line I am looking for and I need to scroll down to see it. As I said,

Batch file goto not working in for loop

怎甘沉沦 提交于 2019-12-08 03:53:25
I have a for loop in my batch file that loops through folders. I want to skip particular folders. I can do this with an IF statement, but would prefer a GOTO like I'm showing below. for /d %%F in (*) do ( if /i "%%F"=="Archive" goto nextFolder REM do stuff here :nextFolder ) But the above is giving me errors: ) was unexpected at this time RB. This won't work - you can't jump into a control-flow construct and expect everything to be fine. Please take a look at (Windows batch) Goto within if block behaves very strangely for a good discussion of why this is a terrible idea. Rather than using GOTO

How do you implement goto in F#?

好久不见. 提交于 2019-12-07 05:04:17
问题 All my favorite languages have a goto command. That is, you can create a label, and then later interrupt the flow of the program to go to the label. One of the more useful applications of this construct is to create an infinite loop, like this: start: goto start Unfortunately, if I undertstand the compiler errors correctly, I can't use this same syntax in F#. So, since it doesn't seem to be supported natively, how can I implement the goto command in F#? Surely, F# is a powerful enough

Algorithm for rewriting modified goto semantics

坚强是说给别人听的谎言 提交于 2019-12-07 04:46:27
问题 I've got an large bunch of legacy code in an old self-conceived scripting language that we compile/translate into javascript. That language has a conditional jump, jumping to a label. Difference to common goto statement is, that no backward jumps are possible. There are no nested if statements nor loops in that language. As goto does not exist in javascript, I'm looking for an algorithm that transforms goto mylabel and mylabel: into semantically equivalent structure. I thought of using ifs