There is an interesting post over here about this, in relation to cross-application flow of control.
Well, recently, I've come across an interesting problem. Generating the nth value in a potentially (practically) endless recursive sequence. This particular algorithm WILL be in atleast 10-15 stack references deep at the point that it s...
Given the following code (that doesn't work):
while True:
#snip: print out current state
while True:
ok = get_input("Is this ok? (y/n)")
if ok == "y" or ok == "Y": break 2 #this doesn't work :(
if ok == "n" or ok == "N": break
#do more processing with menus and stuff
Is there a way to make this work...
I have been assigned a project to develop a set of classes that act as an interface to a storage system. A requirement is that the class support a get method with the following signature:
public CustomObject get(String key, Date ifModifiedSince)
Basically the method is supposed to return the CustomObject associated with the key if an...
I want to re-write a method that has way too many nested if statements.
I came up with this approach and wanted your opinions:
public void MyMethod()
{
bool hasFailed = false;
try
{
GetNewOrders(out hasFailed);
if(!hasFailed)
CheckInventory(out hasFailed);
if(!hasFailed)
PreOrder(out ha...
Hi,
I have been trying to find a way for some time to automate the progress in GDB of tracing the control flow of a program.
Even just a simple way of automating the 'n' command so you can see what order routines are called.
I realise that you can issues 'n x' where x is the number of times GDB steps through, but the trouble with that...
Hi,
I am trying to find way to break / exit from FOR loop, if there are any error occured.
Below is content of batch file.
@echo on
set myfile=D:\sample.txt
FOR /F "tokens=1,2 delims=," %%i in (%myfile%) do call :process "%%i"
:process
set recfile=%1%
echo %recfile%
echo "Step in Test1"
echo %errorlevel%
pause;
exit /B 0
If %errorl...
I need a tool to generate a control flow graph from java source code. Are there such tools available? Is there a possibility to also generate source code if I have a control flow graph?
...
I've heard that using exceptions for control flow is bad practice. What do you think of this?
public static findStringMatch(g0, g1) {
int g0Left = -1;
int g0Right = -1;
int g1Left = -1;
int g1Right = -1;
//if a match is found, set the above ints to the proper indices
//...
//if not, the ints remain -1
try {
...
I feel like this is a pile of you know what I mean. It works but I feel like I'm way overdoing this in terms of the page lifecycle (load and postbacks) and even the redundancy I have in each of the if statements here.
What happens is this:
This method is called on very
page load (no matter if postback or
whatever)
If the user submits...
I am basically trying to return from a method which reads user input from the standard input stream. Since the user has the option to quit the application, I am trying to figure out the best way to do this exit. Ideally I will be able to return from begin() and let main() finish, thus quiting the applicaiton.
public static void main(Str...
I am an autodidact so dont know much about conventional web development however, I have wrote a complete social networking website yet I dont know how to debug. My website has some problems and I need to learn debuggin things around/
First of all I need instructions how to install Xdebug on WAMP (since I use phpDesigner). I tried a lot ...
What sorts of methods exist for prematurely exiting an if clause?
There are times when I'm writing code and want to put a break statement inside of an if clause, only to remember that those can only be used for loops.
Lets take the following code as an example:
if some_condition:
...
if condition_a:
# do something
...
XmlHttpRequest works through callbacks. So how can I return a value? I tried to set a global variable, but that doesn't seem to be working.
var response = null; // contains the most recent XmlHttpRequest response
// loads the info for this username on the page
function loadUsernameInfo(username) {
getUserInfo(username);
var pro...
How can I do this cleanly without gotos?
loop:
if(condition1){
something();
} else if (condition2) {
somethingDifferent();
} else {
mostOfTheWork();
goto loop;
}
I'd prefer not to use breaks as well. Furthermore, it is expected to loop several (adv 40) times before doing something else, so the mostOfTheWork pa...
In my application I am using a third-party API. It is a non-blocking method which returns immediately. I have a collection of elements over which I have to invoke this method.
Now, my problem is that I have to find a way till all the method execution gets completed and do my next operation. How can I handle this? I cannot modify the thi...
Imagine I have a stack-based toy language that comes with the operations Push, Pop, Jump and If.
I have a program and its input is the toy language. For instance I get the sequence
Push 1
Push 1
Pop
Pop
In that case the maximum stack would be 2. A more complicated example would use branches.
Push 1
Push true
If .success
Pop
Jump ....
One thing I've sometimes wondered is which is the better style out of the two shown below (if any)? Is it better to return immediately if a guard condition hasn't been satisfied, or should you only do the other stuff if the guard condition is satisfied?
For the sake of argument, please assume that the guard condition is a simple test th...
I'll admit right up front that the following is a pretty terrible description of what I want to do. Apologies in advance. Please ask questions to help me explain. :-)
I've written ETLs (Extract, Transform, Load) in other languages that consist of individual operations that look something like:
// in class CountOperation
IEnumerable<...
Hello all!
This question is the result of two other questions I've asked in the last few days.
I'm creating a new question because I think it's related to the "next step" in my understanding of how to control the flow of my send/receive, something I didn't get a full answer to yet.
The other related questions are:
http://stackoverflow.c...
I am writing a recursive function to print out the differences between 2 multildimensional php arrays. The purpose of this code is to see the difference between jpeg headers to deteremine how adobe bridge cs3 is saving rating information within the jpg file.
When I am single-stepping through the code using my eclipse - zend debugger i...