Questions tagged [control-structure]

Within an imperative programming language, a control flow statement is a statement whose execution results in a choice being made as to which of two or more paths should be followed.

Within an imperative programming language, a control flow statement is a statement whose execution results in a choice being made as to which of two or more paths should be followed.

The kinds of control flow statements supported by different languages vary, but can be categorized by their effect:

  • continuation at a different statement (unconditional branch or jump),
  • executing a set of statements only if some condition is met (choice - i.e., conditional branch),
  • executing a set of statements zero or more times, until some condition is met (i.e., loop the same as conditional branch),
  • executing a set of distant statements, after which the flow of control usually returns (subroutines, coroutines, and continuations),
  • stopping the program, preventing any further execution (unconditional halt).

from Wikipedia

132 questions
0
votes
1 answer

Use namespace within control structure (if-statement)

This works: require_once( $_SERVER["DOCUMENT_ROOT"] . '/fb/FacebookSession.php' ); use Facebook\FacebookSession; This doesn't: if (1 == 1) { require_once( $_SERVER["DOCUMENT_ROOT"] . '/fb/FacebookSession.php' ); use…
user1322720
0
votes
2 answers

Python if else exception over XML parsed with ElementTree

I have the following XML which I have parsed from a webpage: 151 BBa_B0034
Charon
  • 2,104
  • 6
  • 23
  • 40
0
votes
1 answer

Programming Models in R

I asked my original question incorrectly, so here is the better version. I would like to generate a model using R. The gist of the model --> A polymer can grow or shrink at different rates. Every now and then the rate of shrinking increases by 20…
user2813055
  • 273
  • 4
  • 12
0
votes
1 answer

Program simple simulation in R

Editing this post for simplification according to @agstudy I am trying to develop a model that simulates a polymer using a random uniform distribution. The model has 2 states State 1 (probability of state 1 if in state 2 is .003): growth…
user2813055
  • 273
  • 4
  • 12
0
votes
1 answer

Javascript: Assigning a variable and testing it at the same time

In PHP, we can assign a variable AND test it at the same time: find()) { $this->do_something($result); } function find() { if ($this->day == 'Sunday') return '1234'; else return false; } In the…
pbarney
  • 2,172
  • 4
  • 29
  • 44
0
votes
3 answers

Unreachable Code Detected C#

Im trying to Post an unlimited number of likes but looping the cookies and proxies based on the how many cookies are stored in the array. Apparently i++ is unreachable code. What is the reason for that? public void PostLikes() { PostLike postLike…
0
votes
2 answers

How I keep run the program

I'm here again.I'm newbie and I have some questions. I have a code like that, enter = input("Please type something: ") if enter == "1": print("Hello") else: print("Error") How I keep run the program after else. So How I do when I type…
0
votes
3 answers

Basic Java control structure issue.

I'm a college freshmen and I'm having trouble with my programming homework. The homework I got from my lecturer was for me to write a program in Java to take in a student's info, and allow the student to choose how many subject the student takes,…
JLWK
  • 65
  • 1
  • 9
0
votes
1 answer

Bash: Search a script for a block of commands and then execute those commands

I have a script, named bundle, which uses Here-documents to combine text files into a single file. The files, whose names are passed as arguments when calling the bundle script, are placed within a single file (here named filebundle) which can then…
primussucks
  • 283
  • 1
  • 5
0
votes
4 answers

Issue with if /elseif /else

I am creating a whitelist if you will for a user to input data. I am getting stuck on the elseif statements. This is my code : public function is_valid_data($data) { if(strlen($data > 9)) { $this -> set_message('is_valid_data',…
user2406611
  • 35
  • 1
  • 6
0
votes
2 answers

How to evaluate each value in an array all true and do something in that case in Php?

I need to insert more than one row in a table foreach($answers as $answer){ $sql =<<
mko
  • 19,044
  • 43
  • 119
  • 183
0
votes
1 answer

stsClass objects inside array

I var_dumped a variable and got this, how can i show it properly? Like,

Name: Country:

object(stdClass)#19 (3) { …
NestedWeb
  • 1,449
  • 2
  • 14
  • 29
0
votes
3 answers

Perl Case statement for a range of dates

I have this PERL Switch..case statement: switch ($today) { case "14-Aug-2012" { do A } case "15-Aug-2012" { do B } }#end switch My problem is that the "do B" statement is the same for 15-Aug-2012 to like 01-Oct-2012. How do I say case…
user1444664
0
votes
2 answers

jQuery: about booleans in control structures

I have this code: console.log($(domElem).attr('selected')); console.log(typeof $(domElem).attr('selected')); if($(domElem).attr('selected') == true); { alert("there is one element selected"); } The output…
ziiweb
  • 28,757
  • 70
  • 168
  • 290
-1
votes
1 answer

postgresql for loop script in text form can not be executed

I am trying to write function in postgresql, that creates temp_table with columns table_name text, table_rec jsonb and fill it through for loop with table names from my table containing names of tables and records in json. I have the for loop in…
kony51
  • 3
  • 2
1 2 3
8
9